root / lab4 / .minix-src / include / fuse.h @ 14
History | View | Annotate | Download (6.12 KB)
1 | 13 | up20180614 | /* $NetBSD: fuse.h,v 1.21 2008/08/01 15:54:09 dillo Exp $ */
|
---|---|---|---|
2 | |||
3 | /*
|
||
4 | * Copyright ? 2007 Alistair Crooks. All rights reserved.
|
||
5 | *
|
||
6 | * Redistribution and use in source and binary forms, with or without
|
||
7 | * modification, are permitted provided that the following conditions
|
||
8 | * are met:
|
||
9 | * 1. Redistributions of source code must retain the above copyright
|
||
10 | * notice, this list of conditions and the following disclaimer.
|
||
11 | * 2. Redistributions in binary form must reproduce the above copyright
|
||
12 | * notice, this list of conditions and the following disclaimer in the
|
||
13 | * documentation and/or other materials provided with the distribution.
|
||
14 | * 3. The name of the author may not be used to endorse or promote
|
||
15 | * products derived from this software without specific prior written
|
||
16 | * permission.
|
||
17 | *
|
||
18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||
19 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||
22 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||
24 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||
25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||
26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||
27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||
29 | */
|
||
30 | #ifndef FUSE_H_
|
||
31 | #define FUSE_H_ 20070123 |
||
32 | |||
33 | /* set the default version to use for the fuse interface */
|
||
34 | /* this value determines the API to be used */
|
||
35 | #ifndef FUSE_USE_VERSION
|
||
36 | #define FUSE_USE_VERSION 26 |
||
37 | #endif
|
||
38 | |||
39 | #include <sys/types.h> |
||
40 | |||
41 | #include <puffs.h> |
||
42 | #include <utime.h> |
||
43 | |||
44 | #ifdef __cplusplus
|
||
45 | extern "C" { |
||
46 | #endif
|
||
47 | |||
48 | struct fuse;
|
||
49 | struct fuse_args; /* XXXsupportme */ |
||
50 | |||
51 | struct fuse_file_info {
|
||
52 | int32_t flags; |
||
53 | uint32_t fh_old; |
||
54 | int32_t writepage; |
||
55 | uint32_t direct_io:1;
|
||
56 | uint32_t keep_cache:1;
|
||
57 | uint32_t flush:1;
|
||
58 | uint32_t padding:29;
|
||
59 | uint64_t fh; |
||
60 | uint64_t lock_owner; |
||
61 | }; |
||
62 | |||
63 | struct fuse_conn_info {
|
||
64 | uint32_t proto_major; |
||
65 | uint32_t proto_minor; |
||
66 | uint32_t async_read; |
||
67 | uint32_t max_write; |
||
68 | uint32_t max_readahead; |
||
69 | uint32_t reserved[27];
|
||
70 | }; |
||
71 | |||
72 | /* equivalent'ish of puffs_cc */
|
||
73 | struct fuse_context {
|
||
74 | struct fuse *fuse;
|
||
75 | uid_t uid; |
||
76 | gid_t gid; |
||
77 | pid_t pid; |
||
78 | void *private_data;
|
||
79 | }; |
||
80 | |||
81 | /**
|
||
82 | * Argument list
|
||
83 | */
|
||
84 | struct fuse_args {
|
||
85 | int argc;
|
||
86 | char **argv;
|
||
87 | int allocated;
|
||
88 | }; |
||
89 | |||
90 | /**
|
||
91 | * Initializer for 'struct fuse_args'
|
||
92 | */
|
||
93 | #define FUSE_ARGS_INIT(argc, argv) { argc, argv, 0 } |
||
94 | |||
95 | typedef struct puffs_fuse_dirh *fuse_dirh_t; |
||
96 | |||
97 | typedef int (*fuse_fill_dir_t)(void *, const char *, const struct stat *, off_t); |
||
98 | typedef int (*fuse_dirfil_t)(fuse_dirh_t, const char *, int, ino_t); |
||
99 | |||
100 | #define FUSE_VERSION 26 |
||
101 | #define FUSE_MAJOR_VERSION 2 |
||
102 | #define FUSE_MINOR_VERSION 6 |
||
103 | |||
104 | /*
|
||
105 | * These operations shadow those in puffs_usermount, and are used
|
||
106 | * as a table of callbacks to make when file system requests come
|
||
107 | * in.
|
||
108 | *
|
||
109 | * NOTE: keep same order as fuse
|
||
110 | */
|
||
111 | struct fuse_operations {
|
||
112 | int (*getattr)(const char *, struct stat *); |
||
113 | int (*readlink)(const char *, char *, size_t); |
||
114 | int (*getdir)(const char *, fuse_dirh_t, fuse_dirfil_t); |
||
115 | int (*mknod)(const char *, mode_t, dev_t); |
||
116 | int (*mkdir)(const char *, mode_t); |
||
117 | int (*unlink)(const char *); |
||
118 | int (*rmdir)(const char *); |
||
119 | int (*symlink)(const char *, const char *); |
||
120 | int (*rename)(const char *, const char *); |
||
121 | int (*link)(const char *, const char *); |
||
122 | int (*chmod)(const char *, mode_t); |
||
123 | int (*chown)(const char *, uid_t, gid_t); |
||
124 | int (*truncate)(const char *, off_t); |
||
125 | int (*utime)(const char *, struct utimbuf *); |
||
126 | int (*open)(const char *, struct fuse_file_info *); |
||
127 | int (*read)(const char *, char *, size_t, off_t, struct fuse_file_info *); |
||
128 | int (*write)(const char *, const char *, size_t, off_t, struct fuse_file_info *); |
||
129 | int (*statfs)(const char *, struct statvfs *); |
||
130 | int (*flush)(const char *, struct fuse_file_info *); |
||
131 | int (*release)(const char *, struct fuse_file_info *); |
||
132 | int (*fsync)(const char *, int, struct fuse_file_info *); |
||
133 | int (*setxattr)(const char *, const char *, const char *, size_t, int); |
||
134 | int (*getxattr)(const char *, const char *, char *, size_t); |
||
135 | int (*listxattr)(const char *, char *, size_t); |
||
136 | int (*removexattr)(const char *, const char *); |
||
137 | int (*opendir)(const char *, struct fuse_file_info *); |
||
138 | int (*readdir)(const char *, void *, fuse_fill_dir_t, off_t, struct fuse_file_info *); |
||
139 | int (*releasedir)(const char *, struct fuse_file_info *); |
||
140 | int (*fsyncdir)(const char *, int, struct fuse_file_info *); |
||
141 | void *(*init)(struct fuse_conn_info *); |
||
142 | void (*destroy)(void *); |
||
143 | int (*access)(const char *, int); |
||
144 | int (*create)(const char *, mode_t, struct fuse_file_info *); |
||
145 | int (*ftruncate)(const char *, off_t, struct fuse_file_info *); |
||
146 | int (*fgetattr)(const char *, struct stat *, struct fuse_file_info *); |
||
147 | int (*lock)(const char *, struct fuse_file_info *, int, struct flock *); |
||
148 | int (*utimens)(const char *, const struct timespec *); |
||
149 | int (*bmap)(const char *, size_t , uint64_t *); |
||
150 | }; |
||
151 | |||
152 | |||
153 | struct fuse_chan *fuse_mount(const char *, struct fuse_args *); |
||
154 | struct fuse *fuse_new(struct fuse_chan *, struct fuse_args *, |
||
155 | const struct fuse_operations *, size_t, void *); |
||
156 | |||
157 | int fuse_main_real(int, char **, const struct fuse_operations *, size_t, void *); |
||
158 | int fuse_loop(struct fuse *); |
||
159 | struct fuse_context *fuse_get_context(void); |
||
160 | void fuse_exit(struct fuse *); |
||
161 | void fuse_destroy(struct fuse *); |
||
162 | |||
163 | void fuse_unmount(const char *, struct fuse_chan *); |
||
164 | |||
165 | struct fuse *fuse_setup(int, char **, const struct fuse_operations *, |
||
166 | size_t, char **, int *, int *); |
||
167 | void fuse_teardown(struct fuse *, char *); |
||
168 | |||
169 | #if FUSE_USE_VERSION == 22 |
||
170 | #define fuse_unmount fuse_unmount_compat22
|
||
171 | #endif
|
||
172 | |||
173 | void fuse_unmount_compat22(const char *); |
||
174 | |||
175 | #if FUSE_USE_VERSION >= 26 |
||
176 | #define fuse_main(argc, argv, op, arg) \
|
||
177 | fuse_main_real(argc, argv, op, sizeof(*(op)), arg)
|
||
178 | #define fuse_setup fuse_setup26
|
||
179 | #else
|
||
180 | #define fuse_main(argc, argv, op) \
|
||
181 | fuse_main_real(argc, argv, op, sizeof(*(op)), NULL) |
||
182 | #endif
|
||
183 | |||
184 | struct fuse *fuse_setup26(int, char **, const struct fuse_operations *, |
||
185 | size_t, char **, int *, void *); |
||
186 | |||
187 | #ifdef __cplusplus
|
||
188 | } |
||
189 | #endif
|
||
190 | |||
191 | #include <fuse_opt.h> |
||
192 | |||
193 | #endif |