]>
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 | ||
758e8e38 VJ |
25 | typedef struct FsCred |
26 | { | |
27 | uid_t fc_uid; | |
28 | gid_t fc_gid; | |
29 | mode_t fc_mode; | |
30 | dev_t fc_rdev; | |
31 | } FsCred; | |
74db920c | 32 | |
fc22118d | 33 | struct xattr_operations; |
e06a765e HPB |
34 | struct FsContext; |
35 | struct V9fsPath; | |
36 | ||
37 | typedef struct extended_ops { | |
38 | int (*get_st_gen)(struct FsContext *, struct V9fsPath *, | |
39 | mode_t, uint64_t *); | |
40 | } extended_ops; | |
fc22118d | 41 | |
d3ab98e6 | 42 | /* export flags */ |
c98f1d4a AK |
43 | #define V9FS_IMMEDIATE_WRITEOUT 0x00000001 |
44 | #define V9FS_PATHNAME_FSCONTEXT 0x00000002 | |
b97400ca AK |
45 | /* |
46 | * uid/gid set on fileserver files | |
47 | */ | |
48 | #define V9FS_SM_PASSTHROUGH 0x00000004 | |
49 | /* | |
50 | * uid/gid part of xattr | |
51 | */ | |
52 | #define V9FS_SM_MAPPED 0x00000008 | |
53 | /* | |
54 | * Server will try to set uid/gid. | |
55 | * On failure ignore the error. | |
56 | */ | |
57 | #define V9FS_SM_NONE 0x00000010 | |
2c30dd74 AK |
58 | /* |
59 | * uid/gid part of .virtfs_meatadata namespace | |
60 | */ | |
61 | #define V9FS_SM_MAPPED_FILE 0x00000020 | |
62 | #define V9FS_RDONLY 0x00000040 | |
63 | #define V9FS_PROXY_SOCK_FD 0x00000080 | |
64 | #define V9FS_PROXY_SOCK_NAME 0x00000100 | |
b97400ca | 65 | |
2c30dd74 | 66 | #define V9FS_SEC_MASK 0x0000003C |
d3ab98e6 | 67 | |
2c74c2cb | 68 | |
99519f0a AK |
69 | typedef struct FileOperations FileOperations; |
70 | /* | |
71 | * Structure to store the various fsdev's passed through command line. | |
72 | */ | |
73 | typedef struct FsDriverEntry { | |
74 | char *fsdev_id; | |
75 | char *path; | |
76 | int export_flags; | |
77 | FileOperations *ops; | |
b8bbdb88 | 78 | FsThrottle fst; |
99519f0a | 79 | } FsDriverEntry; |
2c74c2cb | 80 | |
74db920c GS |
81 | typedef struct FsContext |
82 | { | |
74db920c | 83 | uid_t uid; |
b97400ca | 84 | char *fs_root; |
d3ab98e6 | 85 | int export_flags; |
fc22118d | 86 | struct xattr_operations **xops; |
e06a765e | 87 | struct extended_ops exops; |
b8bbdb88 | 88 | FsThrottle *fst; |
532decb7 AK |
89 | /* fs driver specific data */ |
90 | void *private; | |
74db920c GS |
91 | } FsContext; |
92 | ||
2289be19 | 93 | typedef struct V9fsPath { |
2f008a8c | 94 | uint16_t size; |
2289be19 AK |
95 | char *data; |
96 | } V9fsPath; | |
97 | ||
cc720ddb AK |
98 | typedef union V9fsFidOpenState V9fsFidOpenState; |
99 | ||
64b85a8f | 100 | void cred_init(FsCred *); |
758e8e38 | 101 | |
99519f0a | 102 | struct FileOperations |
74db920c | 103 | { |
99519f0a | 104 | int (*parse_opts)(QemuOpts *, struct FsDriverEntry *); |
0174fe73 | 105 | int (*init)(struct FsContext *); |
702dbcc2 | 106 | void (*cleanup)(struct FsContext *); |
2289be19 AK |
107 | int (*lstat)(FsContext *, V9fsPath *, struct stat *); |
108 | ssize_t (*readlink)(FsContext *, V9fsPath *, char *, size_t); | |
109 | int (*chmod)(FsContext *, V9fsPath *, FsCred *); | |
110 | int (*chown)(FsContext *, V9fsPath *, FsCred *); | |
111 | int (*mknod)(FsContext *, V9fsPath *, const char *, FsCred *); | |
112 | int (*utimensat)(FsContext *, V9fsPath *, const struct timespec *); | |
5bae1900 | 113 | int (*remove)(FsContext *, const char *); |
2289be19 AK |
114 | int (*symlink)(FsContext *, const char *, V9fsPath *, |
115 | const char *, FsCred *); | |
116 | int (*link)(FsContext *, V9fsPath *, V9fsPath *, const char *); | |
131dcb25 | 117 | int (*setuid)(FsContext *, uid_t); |
cc720ddb AK |
118 | int (*close)(FsContext *, V9fsFidOpenState *); |
119 | int (*closedir)(FsContext *, V9fsFidOpenState *); | |
120 | int (*opendir)(FsContext *, V9fsPath *, V9fsFidOpenState *); | |
121 | int (*open)(FsContext *, V9fsPath *, int, V9fsFidOpenState *); | |
122 | int (*open2)(FsContext *, V9fsPath *, const char *, | |
123 | int, FsCred *, V9fsFidOpenState *); | |
124 | void (*rewinddir)(FsContext *, V9fsFidOpenState *); | |
125 | off_t (*telldir)(FsContext *, V9fsFidOpenState *); | |
635324e8 | 126 | struct dirent * (*readdir)(FsContext *, V9fsFidOpenState *); |
cc720ddb AK |
127 | void (*seekdir)(FsContext *, V9fsFidOpenState *, off_t); |
128 | ssize_t (*preadv)(FsContext *, V9fsFidOpenState *, | |
129 | const struct iovec *, int, off_t); | |
130 | ssize_t (*pwritev)(FsContext *, V9fsFidOpenState *, | |
131 | const struct iovec *, int, off_t); | |
2289be19 | 132 | int (*mkdir)(FsContext *, V9fsPath *, const char *, FsCred *); |
8b888272 | 133 | int (*fstat)(FsContext *, int, V9fsFidOpenState *, struct stat *); |
8cf89e00 | 134 | int (*rename)(FsContext *, const char *, const char *); |
2289be19 | 135 | int (*truncate)(FsContext *, V9fsPath *, off_t); |
8b888272 | 136 | int (*fsync)(FsContext *, int, V9fsFidOpenState *, int); |
2289be19 AK |
137 | int (*statfs)(FsContext *s, V9fsPath *path, struct statfs *stbuf); |
138 | ssize_t (*lgetxattr)(FsContext *, V9fsPath *, | |
fa32ef88 | 139 | const char *, void *, size_t); |
2289be19 AK |
140 | ssize_t (*llistxattr)(FsContext *, V9fsPath *, void *, size_t); |
141 | int (*lsetxattr)(FsContext *, V9fsPath *, | |
10b468bd | 142 | const char *, void *, size_t, int); |
2289be19 AK |
143 | int (*lremovexattr)(FsContext *, V9fsPath *, const char *); |
144 | int (*name_to_path)(FsContext *, V9fsPath *, const char *, V9fsPath *); | |
145 | int (*renameat)(FsContext *ctx, V9fsPath *olddir, const char *old_name, | |
146 | V9fsPath *newdir, const char *new_name); | |
147 | int (*unlinkat)(FsContext *ctx, V9fsPath *dir, const char *name, int flags); | |
74db920c | 148 | void *opaque; |
99519f0a | 149 | }; |
fc22118d | 150 | |
74db920c | 151 | #endif |