1
2
3
4
5
6
7
8
9
10
11
12
13
14#include "qemu/osdep.h"
15#include "9p.h"
16#include "fsdev/file-op-9p.h"
17#include "9p-xattr.h"
18
19
20static ssize_t mp_user_getxattr(FsContext *ctx, const char *path,
21 const char *name, void *value, size_t size)
22{
23 if (strncmp(name, "user.virtfs.", 12) == 0) {
24
25
26
27
28 errno = ENOATTR;
29 return -1;
30 }
31 return local_getxattr_nofollow(ctx, path, name, value, size);
32}
33
34static ssize_t mp_user_listxattr(FsContext *ctx, const char *path,
35 char *name, void *value, size_t size)
36{
37 int name_size = strlen(name) + 1;
38 if (strncmp(name, "user.virtfs.", 12) == 0) {
39
40
41 if (strncmp(name, "user.virtfs.system.posix_acl_", 29) == 0) {
42
43 name += 12;
44 name_size -= 12;
45 } else {
46
47
48
49
50 return 0;
51 }
52 }
53 if (!value) {
54 return name_size;
55 }
56
57 if (size < name_size) {
58 errno = ERANGE;
59 return -1;
60 }
61
62
63 memcpy(value, name, name_size);
64 return name_size;
65}
66
67static int mp_user_setxattr(FsContext *ctx, const char *path, const char *name,
68 void *value, size_t size, int flags)
69{
70 if (strncmp(name, "user.virtfs.", 12) == 0) {
71
72
73
74
75 errno = EACCES;
76 return -1;
77 }
78 return local_setxattr_nofollow(ctx, path, name, value, size, flags);
79}
80
81static int mp_user_removexattr(FsContext *ctx,
82 const char *path, const char *name)
83{
84 if (strncmp(name, "user.virtfs.", 12) == 0) {
85
86
87
88
89 errno = EACCES;
90 return -1;
91 }
92 return local_removexattr_nofollow(ctx, path, name);
93}
94
95XattrOperations mapped_user_xattr = {
96 .name = "user.",
97 .getxattr = mp_user_getxattr,
98 .setxattr = mp_user_setxattr,
99 .listxattr = mp_user_listxattr,
100 .removexattr = mp_user_removexattr,
101};
102
103XattrOperations passthrough_user_xattr = {
104 .name = "user.",
105 .getxattr = pt_getxattr,
106 .setxattr = pt_setxattr,
107 .listxattr = pt_listxattr,
108 .removexattr = pt_removexattr,
109};
110