qapi: export the marshallers
[qemu/kevin.git] / fsdev / file-op-9p.h
blob6db9feac8f1c8a00f162c386629882bd179f00c5
1 /*
2 * 9p
4 * Copyright IBM, Corp. 2010
6 * Authors:
7 * Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
14 #ifndef FILE_OP_9P_H
15 #define FILE_OP_9P_H
17 #include <dirent.h>
18 #include <utime.h>
19 #include <sys/vfs.h>
21 #define SM_LOCAL_MODE_BITS 0600
22 #define SM_LOCAL_DIR_MODE_BITS 0700
24 typedef struct FsCred
26 uid_t fc_uid;
27 gid_t fc_gid;
28 mode_t fc_mode;
29 dev_t fc_rdev;
30 } FsCred;
32 struct xattr_operations;
33 struct FsContext;
34 struct V9fsPath;
36 typedef struct extended_ops {
37 int (*get_st_gen)(struct FsContext *, struct V9fsPath *,
38 mode_t, uint64_t *);
39 } extended_ops;
41 /* export flags */
42 #define V9FS_IMMEDIATE_WRITEOUT 0x00000001
43 #define V9FS_PATHNAME_FSCONTEXT 0x00000002
45 * uid/gid set on fileserver files
47 #define V9FS_SM_PASSTHROUGH 0x00000004
49 * uid/gid part of xattr
51 #define V9FS_SM_MAPPED 0x00000008
53 * Server will try to set uid/gid.
54 * On failure ignore the error.
56 #define V9FS_SM_NONE 0x00000010
58 * uid/gid part of .virtfs_meatadata namespace
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
65 #define V9FS_SEC_MASK 0x0000003C
68 typedef struct FileOperations FileOperations;
70 * Structure to store the various fsdev's passed through command line.
72 typedef struct FsDriverEntry {
73 char *fsdev_id;
74 char *path;
75 int export_flags;
76 FileOperations *ops;
77 } FsDriverEntry;
79 typedef struct FsContext
81 uid_t uid;
82 char *fs_root;
83 int export_flags;
84 struct xattr_operations **xops;
85 struct extended_ops exops;
86 /* fs driver specific data */
87 void *private;
88 } FsContext;
90 typedef struct V9fsPath {
91 uint16_t size;
92 char *data;
93 } V9fsPath;
95 typedef union V9fsFidOpenState V9fsFidOpenState;
97 void cred_init(FsCred *);
99 struct FileOperations
101 int (*parse_opts)(QemuOpts *, struct FsDriverEntry *);
102 int (*init)(struct FsContext *);
103 int (*lstat)(FsContext *, V9fsPath *, struct stat *);
104 ssize_t (*readlink)(FsContext *, V9fsPath *, char *, size_t);
105 int (*chmod)(FsContext *, V9fsPath *, FsCred *);
106 int (*chown)(FsContext *, V9fsPath *, FsCred *);
107 int (*mknod)(FsContext *, V9fsPath *, const char *, FsCred *);
108 int (*utimensat)(FsContext *, V9fsPath *, const struct timespec *);
109 int (*remove)(FsContext *, const char *);
110 int (*symlink)(FsContext *, const char *, V9fsPath *,
111 const char *, FsCred *);
112 int (*link)(FsContext *, V9fsPath *, V9fsPath *, const char *);
113 int (*setuid)(FsContext *, uid_t);
114 int (*close)(FsContext *, V9fsFidOpenState *);
115 int (*closedir)(FsContext *, V9fsFidOpenState *);
116 int (*opendir)(FsContext *, V9fsPath *, V9fsFidOpenState *);
117 int (*open)(FsContext *, V9fsPath *, int, V9fsFidOpenState *);
118 int (*open2)(FsContext *, V9fsPath *, const char *,
119 int, FsCred *, V9fsFidOpenState *);
120 void (*rewinddir)(FsContext *, V9fsFidOpenState *);
121 off_t (*telldir)(FsContext *, V9fsFidOpenState *);
122 struct dirent * (*readdir)(FsContext *, V9fsFidOpenState *);
123 void (*seekdir)(FsContext *, V9fsFidOpenState *, off_t);
124 ssize_t (*preadv)(FsContext *, V9fsFidOpenState *,
125 const struct iovec *, int, off_t);
126 ssize_t (*pwritev)(FsContext *, V9fsFidOpenState *,
127 const struct iovec *, int, off_t);
128 int (*mkdir)(FsContext *, V9fsPath *, const char *, FsCred *);
129 int (*fstat)(FsContext *, int, V9fsFidOpenState *, struct stat *);
130 int (*rename)(FsContext *, const char *, const char *);
131 int (*truncate)(FsContext *, V9fsPath *, off_t);
132 int (*fsync)(FsContext *, int, V9fsFidOpenState *, int);
133 int (*statfs)(FsContext *s, V9fsPath *path, struct statfs *stbuf);
134 ssize_t (*lgetxattr)(FsContext *, V9fsPath *,
135 const char *, void *, size_t);
136 ssize_t (*llistxattr)(FsContext *, V9fsPath *, void *, size_t);
137 int (*lsetxattr)(FsContext *, V9fsPath *,
138 const char *, void *, size_t, int);
139 int (*lremovexattr)(FsContext *, V9fsPath *, const char *);
140 int (*name_to_path)(FsContext *, V9fsPath *, const char *, V9fsPath *);
141 int (*renameat)(FsContext *ctx, V9fsPath *olddir, const char *old_name,
142 V9fsPath *newdir, const char *new_name);
143 int (*unlinkat)(FsContext *ctx, V9fsPath *dir, const char *name, int flags);
144 void *opaque;
147 #endif