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