Merge remote branch 'mst/for_anthony' into staging
[qemu.git] / hw / file-op-9p.h
blobd91b7e79963a2ecd05654a28f6e1c67b1cf1233d
1 /*
2 * Virtio 9p
4 * Copyright IBM, Corp. 2010
6 * Authors:
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.
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
25 typedef enum
28 * Server will try to set uid/gid.
29 * On failure ignore the error.
31 SM_NONE = 0,
33 * uid/gid set on fileserver files
35 SM_PASSTHROUGH = 1,
37 * uid/gid part of xattr
39 SM_MAPPED,
40 } SecModel;
42 typedef struct FsCred
44 uid_t fc_uid;
45 gid_t fc_gid;
46 mode_t fc_mode;
47 dev_t fc_rdev;
48 } FsCred;
50 typedef struct FsContext
52 char *fs_root;
53 SecModel fs_sm;
54 uid_t uid;
55 } FsContext;
57 extern void cred_init(FsCred *);
59 typedef struct FileOperations
61 int (*lstat)(FsContext *, const char *, struct stat *);
62 ssize_t (*readlink)(FsContext *, const char *, char *, size_t);
63 int (*chmod)(FsContext *, const char *, FsCred *);
64 int (*chown)(FsContext *, const char *, FsCred *);
65 int (*mknod)(FsContext *, const char *, FsCred *);
66 int (*utimensat)(FsContext *, const char *, const struct timespec *);
67 int (*remove)(FsContext *, const char *);
68 int (*symlink)(FsContext *, const char *, const char *, FsCred *);
69 int (*link)(FsContext *, const char *, const char *);
70 int (*setuid)(FsContext *, uid_t);
71 int (*close)(FsContext *, int);
72 int (*closedir)(FsContext *, DIR *);
73 DIR *(*opendir)(FsContext *, const char *);
74 int (*open)(FsContext *, const char *, int);
75 int (*open2)(FsContext *, const char *, int, FsCred *);
76 void (*rewinddir)(FsContext *, DIR *);
77 off_t (*telldir)(FsContext *, DIR *);
78 struct dirent *(*readdir)(FsContext *, DIR *);
79 void (*seekdir)(FsContext *, DIR *, off_t);
80 ssize_t (*readv)(FsContext *, int, const struct iovec *, int);
81 ssize_t (*writev)(FsContext *, int, const struct iovec *, int);
82 off_t (*lseek)(FsContext *, int, off_t, int);
83 int (*mkdir)(FsContext *, const char *, FsCred *);
84 int (*fstat)(FsContext *, int, struct stat *);
85 int (*rename)(FsContext *, const char *, const char *);
86 int (*truncate)(FsContext *, const char *, off_t);
87 int (*fsync)(FsContext *, int);
88 int (*statfs)(FsContext *s, const char *path, struct statfs *stbuf);
89 ssize_t (*lgetxattr)(FsContext *, const char *,
90 const char *, void *, size_t);
91 ssize_t (*llistxattr)(FsContext *, const char *, void *, size_t);
92 int (*lsetxattr)(FsContext *, const char *,
93 const char *, void *, size_t, int);
94 int (*lremovexattr)(FsContext *, const char *, const char *);
95 void *opaque;
96 } FileOperations;
97 #endif