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