Statistics
| Branch: | Revision:

root / hw / virtio-9p-xattr.h @ 15d7dc4f

History | View | Annotate | Download (3.2 kB)

1 fc22118d Aneesh Kumar K.V
/*
2 fc22118d Aneesh Kumar K.V
 * Virtio 9p
3 fc22118d Aneesh Kumar K.V
 *
4 fc22118d Aneesh Kumar K.V
 * Copyright IBM, Corp. 2010
5 fc22118d Aneesh Kumar K.V
 *
6 fc22118d Aneesh Kumar K.V
 * Authors:
7 fc22118d Aneesh Kumar K.V
 *  Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
8 fc22118d Aneesh Kumar K.V
 *
9 fc22118d Aneesh Kumar K.V
 * This work is licensed under the terms of the GNU GPL, version 2.  See
10 fc22118d Aneesh Kumar K.V
 * the COPYING file in the top-level directory.
11 fc22118d Aneesh Kumar K.V
 *
12 fc22118d Aneesh Kumar K.V
 */
13 fc22118d Aneesh Kumar K.V
#ifndef _QEMU_VIRTIO_9P_XATTR_H
14 fc22118d Aneesh Kumar K.V
#define _QEMU_VIRTIO_9P_XATTR_H
15 fc22118d Aneesh Kumar K.V
16 fc22118d Aneesh Kumar K.V
#include <attr/xattr.h>
17 fc22118d Aneesh Kumar K.V
18 fc22118d Aneesh Kumar K.V
typedef struct xattr_operations
19 fc22118d Aneesh Kumar K.V
{
20 fc22118d Aneesh Kumar K.V
    const char *name;
21 fc22118d Aneesh Kumar K.V
    ssize_t (*getxattr)(FsContext *ctx, const char *path,
22 fc22118d Aneesh Kumar K.V
                        const char *name, void *value, size_t size);
23 fc22118d Aneesh Kumar K.V
    ssize_t (*listxattr)(FsContext *ctx, const char *path,
24 fc22118d Aneesh Kumar K.V
                         char *name, void *value, size_t size);
25 fc22118d Aneesh Kumar K.V
    int (*setxattr)(FsContext *ctx, const char *path, const char *name,
26 fc22118d Aneesh Kumar K.V
                    void *value, size_t size, int flags);
27 fc22118d Aneesh Kumar K.V
    int (*removexattr)(FsContext *ctx,
28 fc22118d Aneesh Kumar K.V
                       const char *path, const char *name);
29 fc22118d Aneesh Kumar K.V
} XattrOperations;
30 fc22118d Aneesh Kumar K.V
31 fc22118d Aneesh Kumar K.V
32 fc22118d Aneesh Kumar K.V
extern XattrOperations mapped_user_xattr;
33 fc22118d Aneesh Kumar K.V
extern XattrOperations passthrough_user_xattr;
34 fc22118d Aneesh Kumar K.V
35 70fc55eb Aneesh Kumar K.V
extern XattrOperations mapped_pacl_xattr;
36 70fc55eb Aneesh Kumar K.V
extern XattrOperations mapped_dacl_xattr;
37 70fc55eb Aneesh Kumar K.V
extern XattrOperations passthrough_acl_xattr;
38 70fc55eb Aneesh Kumar K.V
extern XattrOperations none_acl_xattr;
39 70fc55eb Aneesh Kumar K.V
40 fc22118d Aneesh Kumar K.V
extern XattrOperations *mapped_xattr_ops[];
41 fc22118d Aneesh Kumar K.V
extern XattrOperations *passthrough_xattr_ops[];
42 fc22118d Aneesh Kumar K.V
extern XattrOperations *none_xattr_ops[];
43 fc22118d Aneesh Kumar K.V
44 64b85a8f Blue Swirl
ssize_t v9fs_get_xattr(FsContext *ctx, const char *path, const char *name,
45 64b85a8f Blue Swirl
                       void *value, size_t size);
46 64b85a8f Blue Swirl
ssize_t v9fs_list_xattr(FsContext *ctx, const char *path, void *value,
47 64b85a8f Blue Swirl
                        size_t vsize);
48 64b85a8f Blue Swirl
int v9fs_set_xattr(FsContext *ctx, const char *path, const char *name,
49 fc22118d Aneesh Kumar K.V
                          void *value, size_t size, int flags);
50 64b85a8f Blue Swirl
int v9fs_remove_xattr(FsContext *ctx, const char *path, const char *name);
51 64b85a8f Blue Swirl
ssize_t pt_listxattr(FsContext *ctx, const char *path, char *name, void *value,
52 64b85a8f Blue Swirl
                     size_t size);
53 fc22118d Aneesh Kumar K.V
54 fc22118d Aneesh Kumar K.V
static inline ssize_t pt_getxattr(FsContext *ctx, const char *path,
55 fc22118d Aneesh Kumar K.V
                                  const char *name, void *value, size_t size)
56 fc22118d Aneesh Kumar K.V
{
57 fc22118d Aneesh Kumar K.V
    return lgetxattr(rpath(ctx, path), name, value, size);
58 fc22118d Aneesh Kumar K.V
}
59 fc22118d Aneesh Kumar K.V
60 fc22118d Aneesh Kumar K.V
static inline int pt_setxattr(FsContext *ctx, const char *path,
61 fc22118d Aneesh Kumar K.V
                              const char *name, void *value,
62 fc22118d Aneesh Kumar K.V
                              size_t size, int flags)
63 fc22118d Aneesh Kumar K.V
{
64 fc22118d Aneesh Kumar K.V
    return lsetxattr(rpath(ctx, path), name, value, size, flags);
65 fc22118d Aneesh Kumar K.V
}
66 fc22118d Aneesh Kumar K.V
67 fc22118d Aneesh Kumar K.V
static inline int pt_removexattr(FsContext *ctx,
68 fc22118d Aneesh Kumar K.V
                                 const char *path, const char *name)
69 fc22118d Aneesh Kumar K.V
{
70 fc22118d Aneesh Kumar K.V
    return lremovexattr(rpath(ctx, path), name);
71 fc22118d Aneesh Kumar K.V
}
72 fc22118d Aneesh Kumar K.V
73 70fc55eb Aneesh Kumar K.V
static inline ssize_t notsup_getxattr(FsContext *ctx, const char *path,
74 70fc55eb Aneesh Kumar K.V
                                      const char *name, void *value,
75 70fc55eb Aneesh Kumar K.V
                                      size_t size)
76 70fc55eb Aneesh Kumar K.V
{
77 70fc55eb Aneesh Kumar K.V
    errno = ENOTSUP;
78 70fc55eb Aneesh Kumar K.V
    return -1;
79 70fc55eb Aneesh Kumar K.V
}
80 70fc55eb Aneesh Kumar K.V
81 70fc55eb Aneesh Kumar K.V
static inline int notsup_setxattr(FsContext *ctx, const char *path,
82 70fc55eb Aneesh Kumar K.V
                                  const char *name, void *value,
83 70fc55eb Aneesh Kumar K.V
                                  size_t size, int flags)
84 70fc55eb Aneesh Kumar K.V
{
85 70fc55eb Aneesh Kumar K.V
    errno = ENOTSUP;
86 70fc55eb Aneesh Kumar K.V
    return -1;
87 70fc55eb Aneesh Kumar K.V
}
88 70fc55eb Aneesh Kumar K.V
89 70fc55eb Aneesh Kumar K.V
static inline ssize_t notsup_listxattr(FsContext *ctx, const char *path,
90 70fc55eb Aneesh Kumar K.V
                                       char *name, void *value, size_t size)
91 70fc55eb Aneesh Kumar K.V
{
92 70fc55eb Aneesh Kumar K.V
    return 0;
93 70fc55eb Aneesh Kumar K.V
}
94 70fc55eb Aneesh Kumar K.V
95 70fc55eb Aneesh Kumar K.V
static inline int notsup_removexattr(FsContext *ctx,
96 70fc55eb Aneesh Kumar K.V
                                     const char *path, const char *name)
97 70fc55eb Aneesh Kumar K.V
{
98 70fc55eb Aneesh Kumar K.V
    errno = ENOTSUP;
99 70fc55eb Aneesh Kumar K.V
    return -1;
100 70fc55eb Aneesh Kumar K.V
}
101 70fc55eb Aneesh Kumar K.V
102 fc22118d Aneesh Kumar K.V
#endif