4 * Copyright IBM, Corp. 2010
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.
20 #include "qemu-fsdev-throttle.h"
22 #define SM_LOCAL_MODE_BITS 0600
23 #define SM_LOCAL_DIR_MODE_BITS 0700
25 typedef struct FsCred
{
32 typedef struct FsContext FsContext
;
33 typedef struct V9fsPath V9fsPath
;
35 typedef struct ExtendedOps
{
36 int (*get_st_gen
)(FsContext
*, V9fsPath
*, mode_t
, uint64_t *);
40 #define V9FS_IMMEDIATE_WRITEOUT 0x00000001
41 #define V9FS_PATHNAME_FSCONTEXT 0x00000002
43 * uid/gid set on fileserver files
45 #define V9FS_SM_PASSTHROUGH 0x00000004
47 * uid/gid part of xattr
49 #define V9FS_SM_MAPPED 0x00000008
51 * Server will try to set uid/gid.
52 * On failure ignore the error.
54 #define V9FS_SM_NONE 0x00000010
56 * uid/gid part of .virtfs_meatadata namespace
58 #define V9FS_SM_MAPPED_FILE 0x00000020
59 #define V9FS_RDONLY 0x00000040
60 #define V9FS_PROXY_SOCK_FD 0x00000080
61 #define V9FS_PROXY_SOCK_NAME 0x00000100
63 * multidevs option (either one of the two applies exclusively)
65 #define V9FS_REMAP_INODES 0x00000200
66 #define V9FS_FORBID_MULTIDEVS 0x00000400
68 * Disables certain performance warnings from being logged on host side.
70 #define V9FS_NO_PERF_WARN 0x00000800
72 #define V9FS_SEC_MASK 0x0000003C
75 typedef struct FileOperations FileOperations
;
76 typedef struct XattrOperations XattrOperations
;
79 * Structure to store the various fsdev's passed through command line.
81 typedef struct FsDriverEntry
{
95 XattrOperations
**xops
;
98 /* fs driver specific data */
109 typedef union V9fsFidOpenState V9fsFidOpenState
;
111 void cred_init(FsCred
*);
113 struct FileOperations
115 int (*parse_opts
)(QemuOpts
*, FsDriverEntry
*, Error
**errp
);
116 int (*init
)(FsContext
*, Error
**errp
);
117 void (*cleanup
)(FsContext
*);
118 int (*lstat
)(FsContext
*, V9fsPath
*, struct stat
*);
119 ssize_t (*readlink
)(FsContext
*, V9fsPath
*, char *, size_t);
120 int (*chmod
)(FsContext
*, V9fsPath
*, FsCred
*);
121 int (*chown
)(FsContext
*, V9fsPath
*, FsCred
*);
122 int (*mknod
)(FsContext
*, V9fsPath
*, const char *, FsCred
*);
123 int (*utimensat
)(FsContext
*, V9fsPath
*, const struct timespec
*);
124 int (*remove
)(FsContext
*, const char *);
125 int (*symlink
)(FsContext
*, const char *, V9fsPath
*,
126 const char *, FsCred
*);
127 int (*link
)(FsContext
*, V9fsPath
*, V9fsPath
*, const char *);
128 int (*setuid
)(FsContext
*, uid_t
);
129 int (*close
)(FsContext
*, V9fsFidOpenState
*);
130 int (*closedir
)(FsContext
*, V9fsFidOpenState
*);
131 int (*opendir
)(FsContext
*, V9fsPath
*, V9fsFidOpenState
*);
132 int (*open
)(FsContext
*, V9fsPath
*, int, V9fsFidOpenState
*);
133 int (*open2
)(FsContext
*, V9fsPath
*, const char *,
134 int, FsCred
*, V9fsFidOpenState
*);
135 void (*rewinddir
)(FsContext
*, V9fsFidOpenState
*);
136 off_t (*telldir
)(FsContext
*, V9fsFidOpenState
*);
137 struct dirent
* (*readdir
)(FsContext
*, V9fsFidOpenState
*);
138 void (*seekdir
)(FsContext
*, V9fsFidOpenState
*, off_t
);
139 ssize_t (*preadv
)(FsContext
*, V9fsFidOpenState
*,
140 const struct iovec
*, int, off_t
);
141 ssize_t (*pwritev
)(FsContext
*, V9fsFidOpenState
*,
142 const struct iovec
*, int, off_t
);
143 int (*mkdir
)(FsContext
*, V9fsPath
*, const char *, FsCred
*);
144 int (*fstat
)(FsContext
*, int, V9fsFidOpenState
*, struct stat
*);
145 int (*rename
)(FsContext
*, const char *, const char *);
146 int (*truncate
)(FsContext
*, V9fsPath
*, off_t
);
147 int (*fsync
)(FsContext
*, int, V9fsFidOpenState
*, int);
148 int (*statfs
)(FsContext
*s
, V9fsPath
*path
, struct statfs
*stbuf
);
149 ssize_t (*lgetxattr
)(FsContext
*, V9fsPath
*,
150 const char *, void *, size_t);
151 ssize_t (*llistxattr
)(FsContext
*, V9fsPath
*, void *, size_t);
152 int (*lsetxattr
)(FsContext
*, V9fsPath
*,
153 const char *, void *, size_t, int);
154 int (*lremovexattr
)(FsContext
*, V9fsPath
*, const char *);
155 int (*name_to_path
)(FsContext
*, V9fsPath
*, const char *, V9fsPath
*);
156 int (*renameat
)(FsContext
*ctx
, V9fsPath
*olddir
, const char *old_name
,
157 V9fsPath
*newdir
, const char *new_name
);
158 int (*unlinkat
)(FsContext
*ctx
, V9fsPath
*dir
, const char *name
, int flags
);