]> git.proxmox.com Git - qemu.git/blob - fsdev/file-op-9p.h
virtio-serial: Clean up virtser_bus_dev_print() output
[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 #define SM_LOCAL_MODE_BITS 0600
23 #define SM_LOCAL_DIR_MODE_BITS 0700
24
25 typedef enum
26 {
27 /*
28 * Server will try to set uid/gid.
29 * On failure ignore the error.
30 */
31 SM_NONE = 0,
32 /*
33 * uid/gid set on fileserver files
34 */
35 SM_PASSTHROUGH = 1,
36 /*
37 * uid/gid part of xattr
38 */
39 SM_MAPPED,
40 } SecModel;
41
42 typedef struct FsCred
43 {
44 uid_t fc_uid;
45 gid_t fc_gid;
46 mode_t fc_mode;
47 dev_t fc_rdev;
48 } FsCred;
49
50 struct xattr_operations;
51
52 typedef struct FsContext
53 {
54 char *fs_root;
55 SecModel fs_sm;
56 uid_t uid;
57 struct xattr_operations **xops;
58 } FsContext;
59
60 void cred_init(FsCred *);
61
62 typedef struct FileOperations
63 {
64 int (*lstat)(FsContext *, const char *, struct stat *);
65 ssize_t (*readlink)(FsContext *, const char *, char *, size_t);
66 int (*chmod)(FsContext *, const char *, FsCred *);
67 int (*chown)(FsContext *, const char *, FsCred *);
68 int (*mknod)(FsContext *, const char *, FsCred *);
69 int (*utimensat)(FsContext *, const char *, const struct timespec *);
70 int (*remove)(FsContext *, const char *);
71 int (*symlink)(FsContext *, const char *, const char *, FsCred *);
72 int (*link)(FsContext *, const char *, const char *);
73 int (*setuid)(FsContext *, uid_t);
74 int (*close)(FsContext *, int);
75 int (*closedir)(FsContext *, DIR *);
76 DIR *(*opendir)(FsContext *, const char *);
77 int (*open)(FsContext *, const char *, int);
78 int (*open2)(FsContext *, const char *, int, FsCred *);
79 void (*rewinddir)(FsContext *, DIR *);
80 off_t (*telldir)(FsContext *, DIR *);
81 struct dirent *(*readdir)(FsContext *, DIR *);
82 void (*seekdir)(FsContext *, DIR *, off_t);
83 ssize_t (*preadv)(FsContext *, int, const struct iovec *, int, off_t);
84 ssize_t (*pwritev)(FsContext *, int, const struct iovec *, int, off_t);
85 int (*mkdir)(FsContext *, const char *, FsCred *);
86 int (*fstat)(FsContext *, int, struct stat *);
87 int (*rename)(FsContext *, const char *, const char *);
88 int (*truncate)(FsContext *, const char *, off_t);
89 int (*fsync)(FsContext *, int, int);
90 int (*statfs)(FsContext *s, const char *path, struct statfs *stbuf);
91 ssize_t (*lgetxattr)(FsContext *, const char *,
92 const char *, void *, size_t);
93 ssize_t (*llistxattr)(FsContext *, const char *, void *, size_t);
94 int (*lsetxattr)(FsContext *, const char *,
95 const char *, void *, size_t, int);
96 int (*lremovexattr)(FsContext *, const char *, const char *);
97 void *opaque;
98 } FileOperations;
99
100 #endif