]> git.proxmox.com Git - qemu.git/blob - fsdev/file-op-9p.h
hw/9pfs: Add init callback to fs driver
[qemu.git] / fsdev / file-op-9p.h
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
15 #include <sys/types.h>
16 #include <dirent.h>
17 #include <sys/time.h>
18 #include <utime.h>
19 #include <sys/stat.h>
20 #include <sys/uio.h>
21 #include <sys/vfs.h>
22
23 #define SM_LOCAL_MODE_BITS 0600
24 #define SM_LOCAL_DIR_MODE_BITS 0700
25
26 typedef enum
27 {
28 /*
29 * Server will try to set uid/gid.
30 * On failure ignore the error.
31 */
32 SM_NONE = 0,
33 /*
34 * uid/gid set on fileserver files
35 */
36 SM_PASSTHROUGH = 1,
37 /*
38 * uid/gid part of xattr
39 */
40 SM_MAPPED,
41 } SecModel;
42
43 typedef struct FsCred
44 {
45 uid_t fc_uid;
46 gid_t fc_gid;
47 mode_t fc_mode;
48 dev_t fc_rdev;
49 } FsCred;
50
51 struct xattr_operations;
52
53 typedef struct FsContext
54 {
55 char *fs_root;
56 SecModel fs_sm;
57 uid_t uid;
58 struct xattr_operations **xops;
59 } FsContext;
60
61 typedef struct V9fsPath {
62 int16_t size;
63 char *data;
64 } V9fsPath;
65
66 void cred_init(FsCred *);
67
68 typedef struct FileOperations
69 {
70 int (*init)(struct FsContext *);
71 int (*lstat)(FsContext *, V9fsPath *, struct stat *);
72 ssize_t (*readlink)(FsContext *, V9fsPath *, char *, size_t);
73 int (*chmod)(FsContext *, V9fsPath *, FsCred *);
74 int (*chown)(FsContext *, V9fsPath *, FsCred *);
75 int (*mknod)(FsContext *, V9fsPath *, const char *, FsCred *);
76 int (*utimensat)(FsContext *, V9fsPath *, const struct timespec *);
77 int (*remove)(FsContext *, const char *);
78 int (*symlink)(FsContext *, const char *, V9fsPath *,
79 const char *, FsCred *);
80 int (*link)(FsContext *, V9fsPath *, V9fsPath *, const char *);
81 int (*setuid)(FsContext *, uid_t);
82 int (*close)(FsContext *, int);
83 int (*closedir)(FsContext *, DIR *);
84 DIR *(*opendir)(FsContext *, V9fsPath *);
85 int (*open)(FsContext *, V9fsPath *, int);
86 int (*open2)(FsContext *, V9fsPath *, const char *, int, FsCred *);
87 void (*rewinddir)(FsContext *, DIR *);
88 off_t (*telldir)(FsContext *, DIR *);
89 int (*readdir_r)(FsContext *, DIR *, struct dirent *, struct dirent **);
90 void (*seekdir)(FsContext *, DIR *, off_t);
91 ssize_t (*preadv)(FsContext *, int, const struct iovec *, int, off_t);
92 ssize_t (*pwritev)(FsContext *, int, const struct iovec *, int, off_t);
93 int (*mkdir)(FsContext *, V9fsPath *, const char *, FsCred *);
94 int (*fstat)(FsContext *, int, struct stat *);
95 int (*rename)(FsContext *, const char *, const char *);
96 int (*truncate)(FsContext *, V9fsPath *, off_t);
97 int (*fsync)(FsContext *, int, int);
98 int (*statfs)(FsContext *s, V9fsPath *path, struct statfs *stbuf);
99 ssize_t (*lgetxattr)(FsContext *, V9fsPath *,
100 const char *, void *, size_t);
101 ssize_t (*llistxattr)(FsContext *, V9fsPath *, void *, size_t);
102 int (*lsetxattr)(FsContext *, V9fsPath *,
103 const char *, void *, size_t, int);
104 int (*lremovexattr)(FsContext *, V9fsPath *, const char *);
105 int (*name_to_path)(FsContext *, V9fsPath *, const char *, V9fsPath *);
106 int (*renameat)(FsContext *ctx, V9fsPath *olddir, const char *old_name,
107 V9fsPath *newdir, const char *new_name);
108 int (*unlinkat)(FsContext *ctx, V9fsPath *dir, const char *name, int flags);
109 void *opaque;
110 } FileOperations;
111
112 #endif