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.
14 #include "qemu/osdep.h"
16 #include "fsdev/file-op-9p.h"
20 static ssize_t
mp_user_getxattr(FsContext
*ctx
, const char *path
,
21 const char *name
, void *value
, size_t size
)
26 if (strncmp(name
, "user.virtfs.", 12) == 0) {
28 * Don't allow fetch of user.virtfs namesapce
29 * in case of mapped security
34 buffer
= rpath(ctx
, path
);
35 ret
= lgetxattr(buffer
, name
, value
, size
);
40 static ssize_t
mp_user_listxattr(FsContext
*ctx
, const char *path
,
41 char *name
, void *value
, size_t size
)
43 int name_size
= strlen(name
) + 1;
44 if (strncmp(name
, "user.virtfs.", 12) == 0) {
46 /* check if it is a mapped posix acl */
47 if (strncmp(name
, "user.virtfs.system.posix_acl_", 29) == 0) {
48 /* adjust the name and size */
53 * Don't allow fetch of user.virtfs namesapce
54 * in case of mapped security
63 if (size
< name_size
) {
68 /* name_size includes the trailing NUL. */
69 memcpy(value
, name
, name_size
);
73 static int mp_user_setxattr(FsContext
*ctx
, const char *path
, const char *name
,
74 void *value
, size_t size
, int flags
)
79 if (strncmp(name
, "user.virtfs.", 12) == 0) {
81 * Don't allow fetch of user.virtfs namesapce
82 * in case of mapped security
87 buffer
= rpath(ctx
, path
);
88 ret
= lsetxattr(buffer
, name
, value
, size
, flags
);
93 static int mp_user_removexattr(FsContext
*ctx
,
94 const char *path
, const char *name
)
99 if (strncmp(name
, "user.virtfs.", 12) == 0) {
101 * Don't allow fetch of user.virtfs namesapce
102 * in case of mapped security
107 buffer
= rpath(ctx
, path
);
108 ret
= lremovexattr(buffer
, name
);
113 XattrOperations mapped_user_xattr
= {
115 .getxattr
= mp_user_getxattr
,
116 .setxattr
= mp_user_setxattr
,
117 .listxattr
= mp_user_listxattr
,
118 .removexattr
= mp_user_removexattr
,
121 XattrOperations passthrough_user_xattr
= {
123 .getxattr
= pt_getxattr
,
124 .setxattr
= pt_setxattr
,
125 .listxattr
= pt_listxattr
,
126 .removexattr
= pt_removexattr
,