]>
Commit | Line | Data |
---|---|---|
74db920c | 1 | /* |
af8b38b0 | 2 | * 9p |
74db920c GS |
3 | * |
4 | * Copyright IBM, Corp. 2010 | |
5 | * | |
6 | * Authors: | |
7 | * Aneesh Kumar K.V <[email protected]> | |
8 | * | |
9 | * This work is licensed under the terms of the GNU GPL, version 2. See | |
10 | * the COPYING file in the top-level directory. | |
11 | * | |
12 | */ | |
121d0712 MA |
13 | |
14 | #ifndef FILE_OP_9P_H | |
15 | #define FILE_OP_9P_H | |
16 | ||
74db920c | 17 | #include <dirent.h> |
74db920c | 18 | #include <utime.h> |
758e8e38 | 19 | #include <sys/vfs.h> |
b8bbdb88 | 20 | #include "qemu-fsdev-throttle.h" |
0174fe73 | 21 | |
758e8e38 VJ |
22 | #define SM_LOCAL_MODE_BITS 0600 |
23 | #define SM_LOCAL_DIR_MODE_BITS 0700 | |
24 | ||
1a8d0bb3 | 25 | typedef struct FsCred { |
758e8e38 VJ |
26 | uid_t fc_uid; |
27 | gid_t fc_gid; | |
28 | mode_t fc_mode; | |
29 | dev_t fc_rdev; | |
30 | } FsCred; | |
74db920c | 31 | |
1a8d0bb3 GK |
32 | typedef struct FsContext FsContext; |
33 | typedef struct V9fsPath V9fsPath; | |
e06a765e | 34 | |
1a8d0bb3 GK |
35 | typedef struct ExtendedOps { |
36 | int (*get_st_gen)(FsContext *, V9fsPath *, mode_t, uint64_t *); | |
37 | } ExtendedOps; | |
fc22118d | 38 | |
d3ab98e6 | 39 | /* export flags */ |
c98f1d4a AK |
40 | #define V9FS_IMMEDIATE_WRITEOUT 0x00000001 |
41 | #define V9FS_PATHNAME_FSCONTEXT 0x00000002 | |
b97400ca AK |
42 | /* |
43 | * uid/gid set on fileserver files | |
44 | */ | |
45 | #define V9FS_SM_PASSTHROUGH 0x00000004 | |
46 | /* | |
47 | * uid/gid part of xattr | |
48 | */ | |
49 | #define V9FS_SM_MAPPED 0x00000008 | |
50 | /* | |
51 | * Server will try to set uid/gid. | |
52 | * On failure ignore the error. | |
53 | */ | |
54 | #define V9FS_SM_NONE 0x00000010 | |
2c30dd74 AK |
55 | /* |
56 | * uid/gid part of .virtfs_meatadata namespace | |
57 | */ | |
58 | #define V9FS_SM_MAPPED_FILE 0x00000020 | |
59 | #define V9FS_RDONLY 0x00000040 | |
60 | #define V9FS_PROXY_SOCK_FD 0x00000080 | |
61 | #define V9FS_PROXY_SOCK_NAME 0x00000100 | |
1a6ed33c AM |
62 | /* |
63 | * multidevs option (either one of the two applies exclusively) | |
64 | */ | |
65 | #define V9FS_REMAP_INODES 0x00000200 | |
66 | #define V9FS_FORBID_MULTIDEVS 0x00000400 | |
b97400ca | 67 | |
2c30dd74 | 68 | #define V9FS_SEC_MASK 0x0000003C |
d3ab98e6 | 69 | |
2c74c2cb | 70 | |
99519f0a | 71 | typedef struct FileOperations FileOperations; |
01847522 GK |
72 | typedef struct XattrOperations XattrOperations; |
73 | ||
99519f0a AK |
74 | /* |
75 | * Structure to store the various fsdev's passed through command line. | |
76 | */ | |
77 | typedef struct FsDriverEntry { | |
78 | char *fsdev_id; | |
79 | char *path; | |
80 | int export_flags; | |
81 | FileOperations *ops; | |
b8bbdb88 | 82 | FsThrottle fst; |
b96feb2c TS |
83 | mode_t fmode; |
84 | mode_t dmode; | |
99519f0a | 85 | } FsDriverEntry; |
2c74c2cb | 86 | |
1a8d0bb3 | 87 | struct FsContext { |
74db920c | 88 | uid_t uid; |
b97400ca | 89 | char *fs_root; |
d3ab98e6 | 90 | int export_flags; |
01847522 | 91 | XattrOperations **xops; |
1a8d0bb3 | 92 | ExtendedOps exops; |
b8bbdb88 | 93 | FsThrottle *fst; |
532decb7 AK |
94 | /* fs driver specific data */ |
95 | void *private; | |
b96feb2c TS |
96 | mode_t fmode; |
97 | mode_t dmode; | |
1a8d0bb3 | 98 | }; |
74db920c | 99 | |
1a8d0bb3 | 100 | struct V9fsPath { |
2f008a8c | 101 | uint16_t size; |
2289be19 | 102 | char *data; |
1a8d0bb3 | 103 | }; |
2289be19 | 104 | |
cc720ddb AK |
105 | typedef union V9fsFidOpenState V9fsFidOpenState; |
106 | ||
64b85a8f | 107 | void cred_init(FsCred *); |
758e8e38 | 108 | |
99519f0a | 109 | struct FileOperations |
74db920c | 110 | { |
91cda4e8 | 111 | int (*parse_opts)(QemuOpts *, FsDriverEntry *, Error **errp); |
65603a80 | 112 | int (*init)(FsContext *, Error **errp); |
1a8d0bb3 | 113 | void (*cleanup)(FsContext *); |
2289be19 AK |
114 | int (*lstat)(FsContext *, V9fsPath *, struct stat *); |
115 | ssize_t (*readlink)(FsContext *, V9fsPath *, char *, size_t); | |
116 | int (*chmod)(FsContext *, V9fsPath *, FsCred *); | |
117 | int (*chown)(FsContext *, V9fsPath *, FsCred *); | |
118 | int (*mknod)(FsContext *, V9fsPath *, const char *, FsCred *); | |
119 | int (*utimensat)(FsContext *, V9fsPath *, const struct timespec *); | |
5bae1900 | 120 | int (*remove)(FsContext *, const char *); |
2289be19 AK |
121 | int (*symlink)(FsContext *, const char *, V9fsPath *, |
122 | const char *, FsCred *); | |
123 | int (*link)(FsContext *, V9fsPath *, V9fsPath *, const char *); | |
131dcb25 | 124 | int (*setuid)(FsContext *, uid_t); |
cc720ddb AK |
125 | int (*close)(FsContext *, V9fsFidOpenState *); |
126 | int (*closedir)(FsContext *, V9fsFidOpenState *); | |
127 | int (*opendir)(FsContext *, V9fsPath *, V9fsFidOpenState *); | |
128 | int (*open)(FsContext *, V9fsPath *, int, V9fsFidOpenState *); | |
129 | int (*open2)(FsContext *, V9fsPath *, const char *, | |
130 | int, FsCred *, V9fsFidOpenState *); | |
131 | void (*rewinddir)(FsContext *, V9fsFidOpenState *); | |
132 | off_t (*telldir)(FsContext *, V9fsFidOpenState *); | |
635324e8 | 133 | struct dirent * (*readdir)(FsContext *, V9fsFidOpenState *); |
cc720ddb AK |
134 | void (*seekdir)(FsContext *, V9fsFidOpenState *, off_t); |
135 | ssize_t (*preadv)(FsContext *, V9fsFidOpenState *, | |
136 | const struct iovec *, int, off_t); | |
137 | ssize_t (*pwritev)(FsContext *, V9fsFidOpenState *, | |
138 | const struct iovec *, int, off_t); | |
2289be19 | 139 | int (*mkdir)(FsContext *, V9fsPath *, const char *, FsCred *); |
8b888272 | 140 | int (*fstat)(FsContext *, int, V9fsFidOpenState *, struct stat *); |
8cf89e00 | 141 | int (*rename)(FsContext *, const char *, const char *); |
2289be19 | 142 | int (*truncate)(FsContext *, V9fsPath *, off_t); |
8b888272 | 143 | int (*fsync)(FsContext *, int, V9fsFidOpenState *, int); |
2289be19 AK |
144 | int (*statfs)(FsContext *s, V9fsPath *path, struct statfs *stbuf); |
145 | ssize_t (*lgetxattr)(FsContext *, V9fsPath *, | |
fa32ef88 | 146 | const char *, void *, size_t); |
2289be19 AK |
147 | ssize_t (*llistxattr)(FsContext *, V9fsPath *, void *, size_t); |
148 | int (*lsetxattr)(FsContext *, V9fsPath *, | |
10b468bd | 149 | const char *, void *, size_t, int); |
2289be19 AK |
150 | int (*lremovexattr)(FsContext *, V9fsPath *, const char *); |
151 | int (*name_to_path)(FsContext *, V9fsPath *, const char *, V9fsPath *); | |
152 | int (*renameat)(FsContext *ctx, V9fsPath *olddir, const char *old_name, | |
153 | V9fsPath *newdir, const char *new_name); | |
154 | int (*unlinkat)(FsContext *ctx, V9fsPath *dir, const char *name, int flags); | |
99519f0a | 155 | }; |
fc22118d | 156 | |
74db920c | 157 | #endif |