]> git.proxmox.com Git - mirror_qemu.git/blob - fsdev/file-op-9p.h
hw/9pfs: Move fid pathname tracking to seperate data type.
[mirror_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 typedef struct V9fsPath {
61 int16_t size;
62 char *data;
63 } V9fsPath;
64
65 void cred_init(FsCred *);
66
67 typedef struct FileOperations
68 {
69 int (*lstat)(FsContext *, V9fsPath *, struct stat *);
70 ssize_t (*readlink)(FsContext *, V9fsPath *, char *, size_t);
71 int (*chmod)(FsContext *, V9fsPath *, FsCred *);
72 int (*chown)(FsContext *, V9fsPath *, FsCred *);
73 int (*mknod)(FsContext *, V9fsPath *, const char *, FsCred *);
74 int (*utimensat)(FsContext *, V9fsPath *, const struct timespec *);
75 int (*remove)(FsContext *, const char *);
76 int (*symlink)(FsContext *, const char *, V9fsPath *,
77 const char *, FsCred *);
78 int (*link)(FsContext *, V9fsPath *, V9fsPath *, const char *);
79 int (*setuid)(FsContext *, uid_t);
80 int (*close)(FsContext *, int);
81 int (*closedir)(FsContext *, DIR *);
82 DIR *(*opendir)(FsContext *, V9fsPath *);
83 int (*open)(FsContext *, V9fsPath *, int);
84 int (*open2)(FsContext *, V9fsPath *, const char *, int, FsCred *);
85 void (*rewinddir)(FsContext *, DIR *);
86 off_t (*telldir)(FsContext *, DIR *);
87 int (*readdir_r)(FsContext *, DIR *, struct dirent *, struct dirent **);
88 void (*seekdir)(FsContext *, DIR *, off_t);
89 ssize_t (*preadv)(FsContext *, int, const struct iovec *, int, off_t);
90 ssize_t (*pwritev)(FsContext *, int, const struct iovec *, int, off_t);
91 int (*mkdir)(FsContext *, V9fsPath *, const char *, FsCred *);
92 int (*fstat)(FsContext *, int, struct stat *);
93 int (*rename)(FsContext *, const char *, const char *);
94 int (*truncate)(FsContext *, V9fsPath *, off_t);
95 int (*fsync)(FsContext *, int, int);
96 int (*statfs)(FsContext *s, V9fsPath *path, struct statfs *stbuf);
97 ssize_t (*lgetxattr)(FsContext *, V9fsPath *,
98 const char *, void *, size_t);
99 ssize_t (*llistxattr)(FsContext *, V9fsPath *, void *, size_t);
100 int (*lsetxattr)(FsContext *, V9fsPath *,
101 const char *, void *, size_t, int);
102 int (*lremovexattr)(FsContext *, V9fsPath *, const char *);
103 int (*name_to_path)(FsContext *, V9fsPath *, const char *, V9fsPath *);
104 int (*renameat)(FsContext *ctx, V9fsPath *olddir, const char *old_name,
105 V9fsPath *newdir, const char *new_name);
106 int (*unlinkat)(FsContext *ctx, V9fsPath *dir, const char *name, int flags);
107 void *opaque;
108 } FileOperations;
109
110 #endif