2 * 9p user. xattr callback
4 * Copyright IBM, Corp. 2010
7 * Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
15 * Not so fast! You might want to read the 9p developer docs first:
16 * https://wiki.qemu.org/Documentation/9p
19 #include "qemu/osdep.h"
21 #include "fsdev/file-op-9p.h"
25 static ssize_t
mp_user_getxattr(FsContext
*ctx
, const char *path
,
26 const char *name
, void *value
, size_t size
)
28 if (strncmp(name
, "user.virtfs.", 12) == 0) {
30 * Don't allow fetch of user.virtfs namesapce
31 * in case of mapped security
36 return local_getxattr_nofollow(ctx
, path
, name
, value
, size
);
39 static ssize_t
mp_user_listxattr(FsContext
*ctx
, const char *path
,
40 char *name
, void *value
, size_t size
)
42 int name_size
= strlen(name
) + 1;
43 if (strncmp(name
, "user.virtfs.", 12) == 0) {
45 /* check if it is a mapped posix acl */
46 if (strncmp(name
, "user.virtfs.system.posix_acl_", 29) == 0) {
47 /* adjust the name and size */
52 * Don't allow fetch of user.virtfs namesapce
53 * in case of mapped security
62 if (size
< name_size
) {
67 /* name_size includes the trailing NUL. */
68 memcpy(value
, name
, name_size
);
72 static int mp_user_setxattr(FsContext
*ctx
, const char *path
, const char *name
,
73 void *value
, size_t size
, int flags
)
75 if (strncmp(name
, "user.virtfs.", 12) == 0) {
77 * Don't allow fetch of user.virtfs namesapce
78 * in case of mapped security
83 return local_setxattr_nofollow(ctx
, path
, name
, value
, size
, flags
);
86 static int mp_user_removexattr(FsContext
*ctx
,
87 const char *path
, const char *name
)
89 if (strncmp(name
, "user.virtfs.", 12) == 0) {
91 * Don't allow fetch of user.virtfs namesapce
92 * in case of mapped security
97 return local_removexattr_nofollow(ctx
, path
, name
);
100 XattrOperations mapped_user_xattr
= {
102 .getxattr
= mp_user_getxattr
,
103 .setxattr
= mp_user_setxattr
,
104 .listxattr
= mp_user_listxattr
,
105 .removexattr
= mp_user_removexattr
,
108 XattrOperations passthrough_user_xattr
= {
110 .getxattr
= pt_getxattr
,
111 .setxattr
= pt_setxattr
,
112 .listxattr
= pt_listxattr
,
113 .removexattr
= pt_removexattr
,