Blob


1 /* This file defines the kernel interface of FUSE */
3 /*
4 This -- and only this -- header file may also be distributed under
5 the terms of the BSD Licence as follows:
7 Copyright (C) 2001-2006 Miklos Szeredi. All rights reserved.
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions
11 are met:
12 1. Redistributions of source code must retain the above copyright
13 notice, this list of conditions and the following disclaimer.
14 2. Redistributions in binary form must reproduce the above copyright
15 notice, this list of conditions and the following disclaimer in the
16 documentation and/or other materials provided with the distribution.
18 THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
22 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 SUCH DAMAGE.
29 */
31 /* RSC changed these lines */
32 #include <inttypes.h>
33 #define __u64 uint64_t
34 #define __u32 uint32_t
35 #define __s32 int32_t
37 /** Version number of this interface */
38 #define FUSE_KERNEL_VERSION 7
40 /** Minor version number of this interface */
41 #define FUSE_KERNEL_MINOR_VERSION 5
43 /** The node ID of the root inode */
44 #define FUSE_ROOT_ID 1
46 /** The major number of the fuse character device */
47 #define FUSE_MAJOR 10
49 /** The minor number of the fuse character device */
50 #define FUSE_MINOR 229
52 /* Make sure all structures are padded to 64bit boundary, so 32bit
53 userspace works under 64bit kernels */
55 struct fuse_attr {
56 __u64 ino;
57 __u64 size;
58 __u64 blocks;
59 __u64 atime;
60 __u64 mtime;
61 __u64 ctime;
62 __u32 atimensec;
63 __u32 mtimensec;
64 __u32 ctimensec;
65 __u32 mode;
66 __u32 nlink;
67 __u32 uid;
68 __u32 gid;
69 __u32 rdev;
70 };
72 struct fuse_kstatfs {
73 __u64 blocks;
74 __u64 bfree;
75 __u64 bavail;
76 __u64 files;
77 __u64 ffree;
78 __u32 bsize;
79 __u32 namelen;
80 __u32 frsize;
81 __u32 padding;
82 __u32 spare[6];
83 };
85 #define FATTR_MODE (1 << 0)
86 #define FATTR_UID (1 << 1)
87 #define FATTR_GID (1 << 2)
88 #define FATTR_SIZE (1 << 3)
89 #define FATTR_ATIME (1 << 4)
90 #define FATTR_MTIME (1 << 5)
91 #define FATTR_FH (1 << 6)
93 /**
94 * Flags returned by the OPEN request
95 *
96 * FOPEN_DIRECT_IO: bypass page cache for this open file
97 * FOPEN_KEEP_CACHE: don't invalidate the data cache on open
98 */
99 #define FOPEN_DIRECT_IO (1 << 0)
100 #define FOPEN_KEEP_CACHE (1 << 1)
102 enum fuse_opcode {
103 FUSE_LOOKUP = 1,
104 FUSE_FORGET = 2, /* no reply */
105 FUSE_GETATTR = 3,
106 FUSE_SETATTR = 4,
107 FUSE_READLINK = 5,
108 FUSE_SYMLINK = 6,
109 FUSE_MKNOD = 8,
110 FUSE_MKDIR = 9,
111 FUSE_UNLINK = 10,
112 FUSE_RMDIR = 11,
113 FUSE_RENAME = 12,
114 FUSE_LINK = 13,
115 FUSE_OPEN = 14,
116 FUSE_READ = 15,
117 FUSE_WRITE = 16,
118 FUSE_STATFS = 17,
119 FUSE_RELEASE = 18,
120 FUSE_FSYNC = 20,
121 FUSE_SETXATTR = 21,
122 FUSE_GETXATTR = 22,
123 FUSE_LISTXATTR = 23,
124 FUSE_REMOVEXATTR = 24,
125 FUSE_FLUSH = 25,
126 FUSE_INIT = 26,
127 FUSE_OPENDIR = 27,
128 FUSE_READDIR = 28,
129 FUSE_RELEASEDIR = 29,
130 FUSE_FSYNCDIR = 30,
131 FUSE_ACCESS = 34,
132 FUSE_CREATE = 35
133 };
135 /* The read buffer is required to be at least 8k, but may be much larger */
136 #define FUSE_MIN_READ_BUFFER 8192
138 struct fuse_entry_out {
139 __u64 nodeid; /* Inode ID */
140 __u64 generation; /* Inode generation: nodeid:gen must
141 be unique for the fs's lifetime */
142 __u64 entry_valid; /* Cache timeout for the name */
143 __u64 attr_valid; /* Cache timeout for the attributes */
144 __u32 entry_valid_nsec;
145 __u32 attr_valid_nsec;
146 struct fuse_attr attr;
147 };
149 struct fuse_forget_in {
150 __u64 nlookup;
151 };
153 struct fuse_attr_out {
154 __u64 attr_valid; /* Cache timeout for the attributes */
155 __u32 attr_valid_nsec;
156 __u32 dummy;
157 struct fuse_attr attr;
158 };
160 struct fuse_mknod_in {
161 __u32 mode;
162 __u32 rdev;
163 };
165 struct fuse_mkdir_in {
166 __u32 mode;
167 __u32 padding;
168 };
170 struct fuse_rename_in {
171 __u64 newdir;
172 };
174 struct fuse_link_in {
175 __u64 oldnodeid;
176 };
178 struct fuse_setattr_in {
179 __u32 valid;
180 __u32 padding;
181 __u64 fh;
182 __u64 size;
183 __u64 unused1;
184 __u64 atime;
185 __u64 mtime;
186 __u64 unused2;
187 __u32 atimensec;
188 __u32 mtimensec;
189 __u32 unused3;
190 __u32 mode;
191 __u32 unused4;
192 __u32 uid;
193 __u32 gid;
194 __u32 unused5;
195 };
197 struct fuse_open_in {
198 __u32 flags;
199 __u32 mode;
200 };
202 struct fuse_open_out {
203 __u64 fh;
204 __u32 open_flags;
205 __u32 padding;
206 };
208 struct fuse_release_in {
209 __u64 fh;
210 __u32 flags;
211 __u32 padding;
212 };
214 struct fuse_flush_in {
215 __u64 fh;
216 __u32 flush_flags;
217 __u32 padding;
218 };
220 struct fuse_read_in {
221 __u64 fh;
222 __u64 offset;
223 __u32 size;
224 __u32 padding;
225 };
227 struct fuse_write_in {
228 __u64 fh;
229 __u64 offset;
230 __u32 size;
231 __u32 write_flags;
232 };
234 struct fuse_write_out {
235 __u32 size;
236 __u32 padding;
237 };
239 #define FUSE_COMPAT_STATFS_SIZE 48
241 struct fuse_statfs_out {
242 struct fuse_kstatfs st;
243 };
245 struct fuse_fsync_in {
246 __u64 fh;
247 __u32 fsync_flags;
248 __u32 padding;
249 };
251 struct fuse_setxattr_in {
252 __u32 size;
253 __u32 flags;
254 };
256 struct fuse_getxattr_in {
257 __u32 size;
258 __u32 padding;
259 };
261 struct fuse_getxattr_out {
262 __u32 size;
263 __u32 padding;
264 };
266 struct fuse_access_in {
267 __u32 mask;
268 __u32 padding;
269 };
271 struct fuse_init_in {
272 __u32 major;
273 __u32 minor;
274 };
276 struct fuse_init_out {
277 __u32 major;
278 __u32 minor;
279 __u32 unused[3];
280 __u32 max_write;
281 };
283 struct fuse_in_header {
284 __u32 len;
285 __u32 opcode;
286 __u64 unique;
287 __u64 nodeid;
288 __u32 uid;
289 __u32 gid;
290 __u32 pid;
291 __u32 padding;
292 };
294 struct fuse_out_header {
295 __u32 len;
296 __s32 error;
297 __u64 unique;
298 };
300 /* RSC changed name[0] to name[1] for old C compilers */
301 struct fuse_dirent {
302 __u64 ino;
303 __u64 off;
304 __u32 namelen;
305 __u32 type;
306 char name[1];
307 };
309 #define FUSE_NAME_OFFSET ((unsigned) ((struct fuse_dirent *) 0)->name)
310 #define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(__u64) - 1) & ~(sizeof(__u64) - 1))
311 #define FUSE_DIRENT_SIZE(d) \
312 FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)