1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef _QEMU_VIRTIO_9P_XATTR_H
14#define _QEMU_VIRTIO_9P_XATTR_H
15
16#include "qemu-xattr.h"
17
18typedef struct xattr_operations
19{
20 const char *name;
21 ssize_t (*getxattr)(FsContext *ctx, const char *path,
22 const char *name, void *value, size_t size);
23 ssize_t (*listxattr)(FsContext *ctx, const char *path,
24 char *name, void *value, size_t size);
25 int (*setxattr)(FsContext *ctx, const char *path, const char *name,
26 void *value, size_t size, int flags);
27 int (*removexattr)(FsContext *ctx,
28 const char *path, const char *name);
29} XattrOperations;
30
31
32extern XattrOperations mapped_user_xattr;
33extern XattrOperations passthrough_user_xattr;
34
35extern XattrOperations mapped_pacl_xattr;
36extern XattrOperations mapped_dacl_xattr;
37extern XattrOperations passthrough_acl_xattr;
38extern XattrOperations none_acl_xattr;
39
40extern XattrOperations *mapped_xattr_ops[];
41extern XattrOperations *passthrough_xattr_ops[];
42extern XattrOperations *none_xattr_ops[];
43
44ssize_t v9fs_get_xattr(FsContext *ctx, const char *path, const char *name,
45 void *value, size_t size);
46ssize_t v9fs_list_xattr(FsContext *ctx, const char *path, void *value,
47 size_t vsize);
48int v9fs_set_xattr(FsContext *ctx, const char *path, const char *name,
49 void *value, size_t size, int flags);
50int v9fs_remove_xattr(FsContext *ctx, const char *path, const char *name);
51ssize_t pt_listxattr(FsContext *ctx, const char *path, char *name, void *value,
52 size_t size);
53
54static inline ssize_t pt_getxattr(FsContext *ctx, const char *path,
55 const char *name, void *value, size_t size)
56{
57 char buffer[PATH_MAX];
58 return lgetxattr(rpath(ctx, path, buffer), name, value, size);
59}
60
61static inline int pt_setxattr(FsContext *ctx, const char *path,
62 const char *name, void *value,
63 size_t size, int flags)
64{
65 char buffer[PATH_MAX];
66 return lsetxattr(rpath(ctx, path, buffer), name, value, size, flags);
67}
68
69static inline int pt_removexattr(FsContext *ctx,
70 const char *path, const char *name)
71{
72 char buffer[PATH_MAX];
73 return lremovexattr(rpath(ctx, path, buffer), name);
74}
75
76static inline ssize_t notsup_getxattr(FsContext *ctx, const char *path,
77 const char *name, void *value,
78 size_t size)
79{
80 errno = ENOTSUP;
81 return -1;
82}
83
84static inline int notsup_setxattr(FsContext *ctx, const char *path,
85 const char *name, void *value,
86 size_t size, int flags)
87{
88 errno = ENOTSUP;
89 return -1;
90}
91
92static inline ssize_t notsup_listxattr(FsContext *ctx, const char *path,
93 char *name, void *value, size_t size)
94{
95 return 0;
96}
97
98static inline int notsup_removexattr(FsContext *ctx,
99 const char *path, const char *name)
100{
101 errno = ENOTSUP;
102 return -1;
103}
104
105#endif
106