root / fsdev / file-op-9p.h @ 72daa72e
History | View | Annotate | Download (4.7 kB)
1 | 74db920c | Gautham R Shenoy | /*
|
---|---|---|---|
2 | 74db920c | Gautham R Shenoy | * Virtio 9p
|
3 | 74db920c | Gautham R Shenoy | *
|
4 | 74db920c | Gautham R Shenoy | * Copyright IBM, Corp. 2010
|
5 | 74db920c | Gautham R Shenoy | *
|
6 | 74db920c | Gautham R Shenoy | * Authors:
|
7 | 74db920c | Gautham R Shenoy | * Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
|
8 | 74db920c | Gautham R Shenoy | *
|
9 | 74db920c | Gautham R Shenoy | * This work is licensed under the terms of the GNU GPL, version 2. See
|
10 | 74db920c | Gautham R Shenoy | * the COPYING file in the top-level directory.
|
11 | 74db920c | Gautham R Shenoy | *
|
12 | 74db920c | Gautham R Shenoy | */
|
13 | 74db920c | Gautham R Shenoy | #ifndef _FILEOP_H
|
14 | 74db920c | Gautham R Shenoy | #define _FILEOP_H
|
15 | 74db920c | Gautham R Shenoy | #include <sys/types.h> |
16 | 74db920c | Gautham R Shenoy | #include <dirent.h> |
17 | 74db920c | Gautham R Shenoy | #include <sys/time.h> |
18 | 74db920c | Gautham R Shenoy | #include <utime.h> |
19 | 74db920c | Gautham R Shenoy | #include <sys/stat.h> |
20 | 74db920c | Gautham R Shenoy | #include <sys/uio.h> |
21 | 758e8e38 | Venkateswararao Jujjuri (JV) | #include <sys/vfs.h> |
22 | 0174fe73 | Aneesh Kumar K.V | |
23 | 758e8e38 | Venkateswararao Jujjuri (JV) | #define SM_LOCAL_MODE_BITS 0600 |
24 | 758e8e38 | Venkateswararao Jujjuri (JV) | #define SM_LOCAL_DIR_MODE_BITS 0700 |
25 | 758e8e38 | Venkateswararao Jujjuri (JV) | |
26 | 758e8e38 | Venkateswararao Jujjuri (JV) | typedef struct FsCred |
27 | 758e8e38 | Venkateswararao Jujjuri (JV) | { |
28 | 758e8e38 | Venkateswararao Jujjuri (JV) | uid_t fc_uid; |
29 | 758e8e38 | Venkateswararao Jujjuri (JV) | gid_t fc_gid; |
30 | 758e8e38 | Venkateswararao Jujjuri (JV) | mode_t fc_mode; |
31 | 758e8e38 | Venkateswararao Jujjuri (JV) | dev_t fc_rdev; |
32 | 758e8e38 | Venkateswararao Jujjuri (JV) | } FsCred; |
33 | 74db920c | Gautham R Shenoy | |
34 | fc22118d | Aneesh Kumar K.V | struct xattr_operations;
|
35 | e06a765e | Harsh Prateek Bora | struct FsContext;
|
36 | e06a765e | Harsh Prateek Bora | struct V9fsPath;
|
37 | e06a765e | Harsh Prateek Bora | |
38 | e06a765e | Harsh Prateek Bora | typedef struct extended_ops { |
39 | e06a765e | Harsh Prateek Bora | int (*get_st_gen)(struct FsContext *, struct V9fsPath *, |
40 | e06a765e | Harsh Prateek Bora | mode_t, uint64_t *); |
41 | e06a765e | Harsh Prateek Bora | } extended_ops; |
42 | fc22118d | Aneesh Kumar K.V | |
43 | d3ab98e6 | Aneesh Kumar K.V | /* export flags */
|
44 | c98f1d4a | Aneesh Kumar K.V | #define V9FS_IMMEDIATE_WRITEOUT 0x00000001 |
45 | c98f1d4a | Aneesh Kumar K.V | #define V9FS_PATHNAME_FSCONTEXT 0x00000002 |
46 | b97400ca | Aneesh Kumar K.V | /*
|
47 | b97400ca | Aneesh Kumar K.V | * uid/gid set on fileserver files
|
48 | b97400ca | Aneesh Kumar K.V | */
|
49 | b97400ca | Aneesh Kumar K.V | #define V9FS_SM_PASSTHROUGH 0x00000004 |
50 | b97400ca | Aneesh Kumar K.V | /*
|
51 | b97400ca | Aneesh Kumar K.V | * uid/gid part of xattr
|
52 | b97400ca | Aneesh Kumar K.V | */
|
53 | b97400ca | Aneesh Kumar K.V | #define V9FS_SM_MAPPED 0x00000008 |
54 | b97400ca | Aneesh Kumar K.V | /*
|
55 | b97400ca | Aneesh Kumar K.V | * Server will try to set uid/gid.
|
56 | b97400ca | Aneesh Kumar K.V | * On failure ignore the error.
|
57 | b97400ca | Aneesh Kumar K.V | */
|
58 | b97400ca | Aneesh Kumar K.V | #define V9FS_SM_NONE 0x00000010 |
59 | 2c30dd74 | Aneesh Kumar K.V | /*
|
60 | 2c30dd74 | Aneesh Kumar K.V | * uid/gid part of .virtfs_meatadata namespace
|
61 | 2c30dd74 | Aneesh Kumar K.V | */
|
62 | 2c30dd74 | Aneesh Kumar K.V | #define V9FS_SM_MAPPED_FILE 0x00000020 |
63 | 2c30dd74 | Aneesh Kumar K.V | #define V9FS_RDONLY 0x00000040 |
64 | 2c30dd74 | Aneesh Kumar K.V | #define V9FS_PROXY_SOCK_FD 0x00000080 |
65 | 2c30dd74 | Aneesh Kumar K.V | #define V9FS_PROXY_SOCK_NAME 0x00000100 |
66 | b97400ca | Aneesh Kumar K.V | |
67 | 2c30dd74 | Aneesh Kumar K.V | #define V9FS_SEC_MASK 0x0000003C |
68 | d3ab98e6 | Aneesh Kumar K.V | |
69 | 2c74c2cb | M. Mohan Kumar | |
70 | 99519f0a | Aneesh Kumar K.V | typedef struct FileOperations FileOperations; |
71 | 99519f0a | Aneesh Kumar K.V | /*
|
72 | 99519f0a | Aneesh Kumar K.V | * Structure to store the various fsdev's passed through command line.
|
73 | 99519f0a | Aneesh Kumar K.V | */
|
74 | 99519f0a | Aneesh Kumar K.V | typedef struct FsDriverEntry { |
75 | 99519f0a | Aneesh Kumar K.V | char *fsdev_id;
|
76 | 99519f0a | Aneesh Kumar K.V | char *path;
|
77 | 99519f0a | Aneesh Kumar K.V | int export_flags;
|
78 | 99519f0a | Aneesh Kumar K.V | FileOperations *ops; |
79 | 99519f0a | Aneesh Kumar K.V | } FsDriverEntry; |
80 | 2c74c2cb | M. Mohan Kumar | |
81 | 74db920c | Gautham R Shenoy | typedef struct FsContext |
82 | 74db920c | Gautham R Shenoy | { |
83 | 74db920c | Gautham R Shenoy | uid_t uid; |
84 | b97400ca | Aneesh Kumar K.V | char *fs_root;
|
85 | d3ab98e6 | Aneesh Kumar K.V | int export_flags;
|
86 | fc22118d | Aneesh Kumar K.V | struct xattr_operations **xops;
|
87 | e06a765e | Harsh Prateek Bora | struct extended_ops exops;
|
88 | 532decb7 | Aneesh Kumar K.V | /* fs driver specific data */
|
89 | 532decb7 | Aneesh Kumar K.V | void *private;
|
90 | 74db920c | Gautham R Shenoy | } FsContext; |
91 | 74db920c | Gautham R Shenoy | |
92 | 2289be19 | Aneesh Kumar K.V | typedef struct V9fsPath { |
93 | 2f008a8c | Aneesh Kumar K.V | uint16_t size; |
94 | 2289be19 | Aneesh Kumar K.V | char *data;
|
95 | 2289be19 | Aneesh Kumar K.V | } V9fsPath; |
96 | 2289be19 | Aneesh Kumar K.V | |
97 | cc720ddb | Aneesh Kumar K.V | typedef union V9fsFidOpenState V9fsFidOpenState; |
98 | cc720ddb | Aneesh Kumar K.V | |
99 | 64b85a8f | Blue Swirl | void cred_init(FsCred *);
|
100 | 758e8e38 | Venkateswararao Jujjuri (JV) | |
101 | 99519f0a | Aneesh Kumar K.V | struct FileOperations
|
102 | 74db920c | Gautham R Shenoy | { |
103 | 99519f0a | Aneesh Kumar K.V | int (*parse_opts)(QemuOpts *, struct FsDriverEntry *); |
104 | 0174fe73 | Aneesh Kumar K.V | int (*init)(struct FsContext *); |
105 | 2289be19 | Aneesh Kumar K.V | int (*lstat)(FsContext *, V9fsPath *, struct stat *); |
106 | 2289be19 | Aneesh Kumar K.V | ssize_t (*readlink)(FsContext *, V9fsPath *, char *, size_t);
|
107 | 2289be19 | Aneesh Kumar K.V | int (*chmod)(FsContext *, V9fsPath *, FsCred *);
|
108 | 2289be19 | Aneesh Kumar K.V | int (*chown)(FsContext *, V9fsPath *, FsCred *);
|
109 | 2289be19 | Aneesh Kumar K.V | int (*mknod)(FsContext *, V9fsPath *, const char *, FsCred *); |
110 | 2289be19 | Aneesh Kumar K.V | int (*utimensat)(FsContext *, V9fsPath *, const struct timespec *); |
111 | 5bae1900 | Anthony Liguori | int (*remove)(FsContext *, const char *); |
112 | 2289be19 | Aneesh Kumar K.V | int (*symlink)(FsContext *, const char *, V9fsPath *, |
113 | 2289be19 | Aneesh Kumar K.V | const char *, FsCred *); |
114 | 2289be19 | Aneesh Kumar K.V | int (*link)(FsContext *, V9fsPath *, V9fsPath *, const char *); |
115 | 131dcb25 | Anthony Liguori | int (*setuid)(FsContext *, uid_t);
|
116 | cc720ddb | Aneesh Kumar K.V | int (*close)(FsContext *, V9fsFidOpenState *);
|
117 | cc720ddb | Aneesh Kumar K.V | int (*closedir)(FsContext *, V9fsFidOpenState *);
|
118 | cc720ddb | Aneesh Kumar K.V | int (*opendir)(FsContext *, V9fsPath *, V9fsFidOpenState *);
|
119 | cc720ddb | Aneesh Kumar K.V | int (*open)(FsContext *, V9fsPath *, int, V9fsFidOpenState *); |
120 | cc720ddb | Aneesh Kumar K.V | int (*open2)(FsContext *, V9fsPath *, const char *, |
121 | cc720ddb | Aneesh Kumar K.V | int, FsCred *, V9fsFidOpenState *);
|
122 | cc720ddb | Aneesh Kumar K.V | void (*rewinddir)(FsContext *, V9fsFidOpenState *);
|
123 | cc720ddb | Aneesh Kumar K.V | off_t (*telldir)(FsContext *, V9fsFidOpenState *); |
124 | cc720ddb | Aneesh Kumar K.V | int (*readdir_r)(FsContext *, V9fsFidOpenState *,
|
125 | cc720ddb | Aneesh Kumar K.V | struct dirent *, struct dirent **); |
126 | cc720ddb | Aneesh Kumar K.V | void (*seekdir)(FsContext *, V9fsFidOpenState *, off_t);
|
127 | cc720ddb | Aneesh Kumar K.V | ssize_t (*preadv)(FsContext *, V9fsFidOpenState *, |
128 | cc720ddb | Aneesh Kumar K.V | const struct iovec *, int, off_t); |
129 | cc720ddb | Aneesh Kumar K.V | ssize_t (*pwritev)(FsContext *, V9fsFidOpenState *, |
130 | cc720ddb | Aneesh Kumar K.V | const struct iovec *, int, off_t); |
131 | 2289be19 | Aneesh Kumar K.V | int (*mkdir)(FsContext *, V9fsPath *, const char *, FsCred *); |
132 | 8b888272 | Aneesh Kumar K.V | int (*fstat)(FsContext *, int, V9fsFidOpenState *, struct stat *); |
133 | 8cf89e00 | Anthony Liguori | int (*rename)(FsContext *, const char *, const char *); |
134 | 2289be19 | Aneesh Kumar K.V | int (*truncate)(FsContext *, V9fsPath *, off_t);
|
135 | 8b888272 | Aneesh Kumar K.V | int (*fsync)(FsContext *, int, V9fsFidOpenState *, int); |
136 | 2289be19 | Aneesh Kumar K.V | int (*statfs)(FsContext *s, V9fsPath *path, struct statfs *stbuf); |
137 | 2289be19 | Aneesh Kumar K.V | ssize_t (*lgetxattr)(FsContext *, V9fsPath *, |
138 | fa32ef88 | Aneesh Kumar K.V | const char *, void *, size_t); |
139 | 2289be19 | Aneesh Kumar K.V | ssize_t (*llistxattr)(FsContext *, V9fsPath *, void *, size_t);
|
140 | 2289be19 | Aneesh Kumar K.V | int (*lsetxattr)(FsContext *, V9fsPath *,
|
141 | 10b468bd | Aneesh Kumar K.V | const char *, void *, size_t, int); |
142 | 2289be19 | Aneesh Kumar K.V | int (*lremovexattr)(FsContext *, V9fsPath *, const char *); |
143 | 2289be19 | Aneesh Kumar K.V | int (*name_to_path)(FsContext *, V9fsPath *, const char *, V9fsPath *); |
144 | 2289be19 | Aneesh Kumar K.V | int (*renameat)(FsContext *ctx, V9fsPath *olddir, const char *old_name, |
145 | 2289be19 | Aneesh Kumar K.V | V9fsPath *newdir, const char *new_name); |
146 | 2289be19 | Aneesh Kumar K.V | int (*unlinkat)(FsContext *ctx, V9fsPath *dir, const char *name, int flags); |
147 | 74db920c | Gautham R Shenoy | void *opaque;
|
148 | 99519f0a | Aneesh Kumar K.V | }; |
149 | fc22118d | Aneesh Kumar K.V | |
150 | 74db920c | Gautham R Shenoy | #endif |