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