]>
Commit | Line | Data |
---|---|---|
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 | |
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> | |
758e8e38 | 21 | #include <sys/vfs.h> |
0174fe73 | 22 | |
758e8e38 VJ |
23 | #define SM_LOCAL_MODE_BITS 0600 |
24 | #define SM_LOCAL_DIR_MODE_BITS 0700 | |
25 | ||
26 | typedef enum | |
27 | { | |
12848bfc AK |
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, | |
758e8e38 VJ |
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; | |
74db920c | 50 | |
fc22118d | 51 | struct xattr_operations; |
e06a765e HPB |
52 | struct FsContext; |
53 | struct V9fsPath; | |
54 | ||
55 | typedef struct extended_ops { | |
56 | int (*get_st_gen)(struct FsContext *, struct V9fsPath *, | |
57 | mode_t, uint64_t *); | |
58 | } extended_ops; | |
fc22118d | 59 | |
d3ab98e6 | 60 | /* export flags */ |
c98f1d4a AK |
61 | #define V9FS_IMMEDIATE_WRITEOUT 0x00000001 |
62 | #define V9FS_PATHNAME_FSCONTEXT 0x00000002 | |
d3ab98e6 | 63 | |
74db920c GS |
64 | typedef struct FsContext |
65 | { | |
66 | char *fs_root; | |
758e8e38 | 67 | SecModel fs_sm; |
74db920c | 68 | uid_t uid; |
d3ab98e6 | 69 | int export_flags; |
fc22118d | 70 | struct xattr_operations **xops; |
e06a765e | 71 | struct extended_ops exops; |
532decb7 AK |
72 | /* fs driver specific data */ |
73 | void *private; | |
74db920c GS |
74 | } FsContext; |
75 | ||
2289be19 AK |
76 | typedef struct V9fsPath { |
77 | int16_t size; | |
78 | char *data; | |
79 | } V9fsPath; | |
80 | ||
64b85a8f | 81 | void cred_init(FsCred *); |
758e8e38 | 82 | |
74db920c GS |
83 | typedef struct FileOperations |
84 | { | |
0174fe73 | 85 | int (*init)(struct FsContext *); |
2289be19 AK |
86 | int (*lstat)(FsContext *, V9fsPath *, struct stat *); |
87 | ssize_t (*readlink)(FsContext *, V9fsPath *, char *, size_t); | |
88 | int (*chmod)(FsContext *, V9fsPath *, FsCred *); | |
89 | int (*chown)(FsContext *, V9fsPath *, FsCred *); | |
90 | int (*mknod)(FsContext *, V9fsPath *, const char *, FsCred *); | |
91 | int (*utimensat)(FsContext *, V9fsPath *, const struct timespec *); | |
5bae1900 | 92 | int (*remove)(FsContext *, const char *); |
2289be19 AK |
93 | int (*symlink)(FsContext *, const char *, V9fsPath *, |
94 | const char *, FsCred *); | |
95 | int (*link)(FsContext *, V9fsPath *, V9fsPath *, const char *); | |
131dcb25 AL |
96 | int (*setuid)(FsContext *, uid_t); |
97 | int (*close)(FsContext *, int); | |
98 | int (*closedir)(FsContext *, DIR *); | |
2289be19 AK |
99 | DIR *(*opendir)(FsContext *, V9fsPath *); |
100 | int (*open)(FsContext *, V9fsPath *, int); | |
101 | int (*open2)(FsContext *, V9fsPath *, const char *, int, FsCred *); | |
a9231555 AL |
102 | void (*rewinddir)(FsContext *, DIR *); |
103 | off_t (*telldir)(FsContext *, DIR *); | |
5f524c1e | 104 | int (*readdir_r)(FsContext *, DIR *, struct dirent *, struct dirent **); |
a9231555 | 105 | void (*seekdir)(FsContext *, DIR *, off_t); |
56d15a53 SG |
106 | ssize_t (*preadv)(FsContext *, int, const struct iovec *, int, off_t); |
107 | ssize_t (*pwritev)(FsContext *, int, const struct iovec *, int, off_t); | |
2289be19 | 108 | int (*mkdir)(FsContext *, V9fsPath *, const char *, FsCred *); |
c494dd6f | 109 | int (*fstat)(FsContext *, int, struct stat *); |
8cf89e00 | 110 | int (*rename)(FsContext *, const char *, const char *); |
2289be19 | 111 | int (*truncate)(FsContext *, V9fsPath *, off_t); |
49594973 | 112 | int (*fsync)(FsContext *, int, int); |
2289be19 AK |
113 | int (*statfs)(FsContext *s, V9fsPath *path, struct statfs *stbuf); |
114 | ssize_t (*lgetxattr)(FsContext *, V9fsPath *, | |
fa32ef88 | 115 | const char *, void *, size_t); |
2289be19 AK |
116 | ssize_t (*llistxattr)(FsContext *, V9fsPath *, void *, size_t); |
117 | int (*lsetxattr)(FsContext *, V9fsPath *, | |
10b468bd | 118 | const char *, void *, size_t, int); |
2289be19 AK |
119 | int (*lremovexattr)(FsContext *, V9fsPath *, const char *); |
120 | int (*name_to_path)(FsContext *, V9fsPath *, const char *, V9fsPath *); | |
121 | int (*renameat)(FsContext *ctx, V9fsPath *olddir, const char *old_name, | |
122 | V9fsPath *newdir, const char *new_name); | |
123 | int (*unlinkat)(FsContext *ctx, V9fsPath *dir, const char *name, int flags); | |
74db920c GS |
124 | void *opaque; |
125 | } FileOperations; | |
fc22118d | 126 | |
74db920c | 127 | #endif |