]>
Commit | Line | Data |
---|---|---|
d8a5ba45 MS |
1 | /* |
2 | FUSE: Filesystem in Userspace | |
1f55ed06 | 3 | Copyright (C) 2001-2008 Miklos Szeredi <miklos@szeredi.hu> |
d8a5ba45 MS |
4 | |
5 | This program can be distributed under the terms of the GNU GPL. | |
6 | See the file COPYING. | |
7 | */ | |
8 | ||
c79e322f MS |
9 | /* |
10 | * This file defines the kernel interface of FUSE | |
11 | * | |
12 | * Protocol changelog: | |
13 | * | |
14 | * 7.9: | |
15 | * - new fuse_getattr_in input argument of GETATTR | |
a9ff4f87 | 16 | * - add lk_flags in fuse_lk_in |
f3332114 | 17 | * - add lock_owner field to fuse_setattr_in, fuse_read_in and fuse_write_in |
0e9663ee | 18 | * - add blksize field to fuse_attr |
a6643094 | 19 | * - add file flags field to fuse_read_in and fuse_write_in |
a7c1b990 TH |
20 | * |
21 | * 7.10 | |
22 | * - add nonseekable open flag | |
1f55ed06 MS |
23 | * |
24 | * 7.11 | |
25 | * - add IOCTL message | |
26 | * - add unsolicited notification support | |
27 | * - add POLL message and NOTIFY_POLL notification | |
e0a43ddc MS |
28 | * |
29 | * 7.12 | |
30 | * - add umask flag to input argument of open, mknod and mkdir | |
3b463ae0 JM |
31 | * - add notification messages for invalidation of inodes and |
32 | * directory entries | |
7a6d3c8b CH |
33 | * |
34 | * 7.13 | |
35 | * - make max number of background requests and congestion threshold | |
36 | * tunables | |
dd3bb14f MS |
37 | * |
38 | * 7.14 | |
39 | * - add splice support to fuse device | |
c79e322f | 40 | */ |
d8a5ba45 | 41 | |
29d434b3 TH |
42 | #ifndef _LINUX_FUSE_H |
43 | #define _LINUX_FUSE_H | |
44 | ||
1f55ed06 | 45 | #include <linux/types.h> |
d8a5ba45 | 46 | |
37d217f0 MS |
47 | /* |
48 | * Version negotiation: | |
49 | * | |
50 | * Both the kernel and userspace send the version they support in the | |
51 | * INIT request and reply respectively. | |
52 | * | |
53 | * If the major versions match then both shall use the smallest | |
54 | * of the two minor versions for communication. | |
55 | * | |
56 | * If the kernel supports a larger major version, then userspace shall | |
57 | * reply with the major version it supports, ignore the rest of the | |
58 | * INIT message and expect a new INIT message from the kernel with a | |
59 | * matching major version. | |
60 | * | |
61 | * If the library supports a larger major version, then it shall fall | |
62 | * back to the major protocol version sent by the kernel for | |
63 | * communication and reply with that major version (and an arbitrary | |
64 | * supported minor version). | |
65 | */ | |
66 | ||
d8a5ba45 | 67 | /** Version number of this interface */ |
9e6268db | 68 | #define FUSE_KERNEL_VERSION 7 |
d8a5ba45 MS |
69 | |
70 | /** Minor version number of this interface */ | |
dd3bb14f | 71 | #define FUSE_KERNEL_MINOR_VERSION 14 |
d8a5ba45 MS |
72 | |
73 | /** The node ID of the root inode */ | |
74 | #define FUSE_ROOT_ID 1 | |
75 | ||
06663267 MS |
76 | /* Make sure all structures are padded to 64bit boundary, so 32bit |
77 | userspace works under 64bit kernels */ | |
78 | ||
d8a5ba45 MS |
79 | struct fuse_attr { |
80 | __u64 ino; | |
81 | __u64 size; | |
82 | __u64 blocks; | |
83 | __u64 atime; | |
84 | __u64 mtime; | |
85 | __u64 ctime; | |
86 | __u32 atimensec; | |
87 | __u32 mtimensec; | |
88 | __u32 ctimensec; | |
89 | __u32 mode; | |
90 | __u32 nlink; | |
91 | __u32 uid; | |
92 | __u32 gid; | |
93 | __u32 rdev; | |
0e9663ee MS |
94 | __u32 blksize; |
95 | __u32 padding; | |
d8a5ba45 MS |
96 | }; |
97 | ||
e5e5558e MS |
98 | struct fuse_kstatfs { |
99 | __u64 blocks; | |
100 | __u64 bfree; | |
101 | __u64 bavail; | |
102 | __u64 files; | |
103 | __u64 ffree; | |
104 | __u32 bsize; | |
105 | __u32 namelen; | |
de5f1202 MS |
106 | __u32 frsize; |
107 | __u32 padding; | |
108 | __u32 spare[6]; | |
e5e5558e MS |
109 | }; |
110 | ||
71421259 MS |
111 | struct fuse_file_lock { |
112 | __u64 start; | |
113 | __u64 end; | |
114 | __u32 type; | |
115 | __u32 pid; /* tgid */ | |
116 | }; | |
117 | ||
9cd68455 MS |
118 | /** |
119 | * Bitmasks for fuse_setattr_in.valid | |
120 | */ | |
9e6268db MS |
121 | #define FATTR_MODE (1 << 0) |
122 | #define FATTR_UID (1 << 1) | |
123 | #define FATTR_GID (1 << 2) | |
124 | #define FATTR_SIZE (1 << 3) | |
125 | #define FATTR_ATIME (1 << 4) | |
126 | #define FATTR_MTIME (1 << 5) | |
befc649c | 127 | #define FATTR_FH (1 << 6) |
17637cba MS |
128 | #define FATTR_ATIME_NOW (1 << 7) |
129 | #define FATTR_MTIME_NOW (1 << 8) | |
f3332114 | 130 | #define FATTR_LOCKOWNER (1 << 9) |
9e6268db | 131 | |
45323fb7 MS |
132 | /** |
133 | * Flags returned by the OPEN request | |
134 | * | |
135 | * FOPEN_DIRECT_IO: bypass page cache for this open file | |
136 | * FOPEN_KEEP_CACHE: don't invalidate the data cache on open | |
a7c1b990 | 137 | * FOPEN_NONSEEKABLE: the file is not seekable |
45323fb7 MS |
138 | */ |
139 | #define FOPEN_DIRECT_IO (1 << 0) | |
140 | #define FOPEN_KEEP_CACHE (1 << 1) | |
a7c1b990 | 141 | #define FOPEN_NONSEEKABLE (1 << 2) |
45323fb7 | 142 | |
9cd68455 MS |
143 | /** |
144 | * INIT request/reply flags | |
33670fa2 MS |
145 | * |
146 | * FUSE_EXPORT_SUPPORT: filesystem handles lookups of "." and ".." | |
e0a43ddc | 147 | * FUSE_DONT_MASK: don't apply umask to file mode on create operations |
9cd68455 MS |
148 | */ |
149 | #define FUSE_ASYNC_READ (1 << 0) | |
71421259 | 150 | #define FUSE_POSIX_LOCKS (1 << 1) |
c79e322f | 151 | #define FUSE_FILE_OPS (1 << 2) |
6ff958ed | 152 | #define FUSE_ATOMIC_O_TRUNC (1 << 3) |
33670fa2 | 153 | #define FUSE_EXPORT_SUPPORT (1 << 4) |
78bb6cb9 | 154 | #define FUSE_BIG_WRITES (1 << 5) |
e0a43ddc | 155 | #define FUSE_DONT_MASK (1 << 6) |
9cd68455 | 156 | |
151060ac TH |
157 | /** |
158 | * CUSE INIT request/reply flags | |
159 | * | |
160 | * CUSE_UNRESTRICTED_IOCTL: use unrestricted ioctl | |
161 | */ | |
162 | #define CUSE_UNRESTRICTED_IOCTL (1 << 0) | |
163 | ||
e9168c18 MS |
164 | /** |
165 | * Release flags | |
166 | */ | |
167 | #define FUSE_RELEASE_FLUSH (1 << 0) | |
168 | ||
c79e322f MS |
169 | /** |
170 | * Getattr flags | |
171 | */ | |
172 | #define FUSE_GETATTR_FH (1 << 0) | |
173 | ||
a9ff4f87 MS |
174 | /** |
175 | * Lock flags | |
176 | */ | |
177 | #define FUSE_LK_FLOCK (1 << 0) | |
178 | ||
b25e82e5 MS |
179 | /** |
180 | * WRITE flags | |
181 | * | |
182 | * FUSE_WRITE_CACHE: delayed write from page cache, file handle is guessed | |
f3332114 | 183 | * FUSE_WRITE_LOCKOWNER: lock_owner field is valid |
b25e82e5 MS |
184 | */ |
185 | #define FUSE_WRITE_CACHE (1 << 0) | |
f3332114 MS |
186 | #define FUSE_WRITE_LOCKOWNER (1 << 1) |
187 | ||
188 | /** | |
189 | * Read flags | |
190 | */ | |
191 | #define FUSE_READ_LOCKOWNER (1 << 1) | |
b25e82e5 | 192 | |
59efec7b TH |
193 | /** |
194 | * Ioctl flags | |
195 | * | |
196 | * FUSE_IOCTL_COMPAT: 32bit compat ioctl on 64bit machine | |
197 | * FUSE_IOCTL_UNRESTRICTED: not restricted to well-formed ioctls, retry allowed | |
198 | * FUSE_IOCTL_RETRY: retry with new iovecs | |
199 | * | |
200 | * FUSE_IOCTL_MAX_IOV: maximum of in_iovecs + out_iovecs | |
201 | */ | |
202 | #define FUSE_IOCTL_COMPAT (1 << 0) | |
203 | #define FUSE_IOCTL_UNRESTRICTED (1 << 1) | |
204 | #define FUSE_IOCTL_RETRY (1 << 2) | |
205 | ||
206 | #define FUSE_IOCTL_MAX_IOV 256 | |
207 | ||
95668a69 TH |
208 | /** |
209 | * Poll flags | |
210 | * | |
211 | * FUSE_POLL_SCHEDULE_NOTIFY: request poll notify | |
212 | */ | |
213 | #define FUSE_POLL_SCHEDULE_NOTIFY (1 << 0) | |
214 | ||
334f485d | 215 | enum fuse_opcode { |
e5e5558e MS |
216 | FUSE_LOOKUP = 1, |
217 | FUSE_FORGET = 2, /* no reply */ | |
218 | FUSE_GETATTR = 3, | |
9e6268db | 219 | FUSE_SETATTR = 4, |
e5e5558e | 220 | FUSE_READLINK = 5, |
9e6268db | 221 | FUSE_SYMLINK = 6, |
9e6268db MS |
222 | FUSE_MKNOD = 8, |
223 | FUSE_MKDIR = 9, | |
224 | FUSE_UNLINK = 10, | |
225 | FUSE_RMDIR = 11, | |
226 | FUSE_RENAME = 12, | |
227 | FUSE_LINK = 13, | |
b6aeaded MS |
228 | FUSE_OPEN = 14, |
229 | FUSE_READ = 15, | |
230 | FUSE_WRITE = 16, | |
e5e5558e | 231 | FUSE_STATFS = 17, |
b6aeaded MS |
232 | FUSE_RELEASE = 18, |
233 | FUSE_FSYNC = 20, | |
92a8780e MS |
234 | FUSE_SETXATTR = 21, |
235 | FUSE_GETXATTR = 22, | |
236 | FUSE_LISTXATTR = 23, | |
237 | FUSE_REMOVEXATTR = 24, | |
b6aeaded | 238 | FUSE_FLUSH = 25, |
04730fef MS |
239 | FUSE_INIT = 26, |
240 | FUSE_OPENDIR = 27, | |
241 | FUSE_READDIR = 28, | |
82547981 | 242 | FUSE_RELEASEDIR = 29, |
31d40d74 | 243 | FUSE_FSYNCDIR = 30, |
71421259 MS |
244 | FUSE_GETLK = 31, |
245 | FUSE_SETLK = 32, | |
246 | FUSE_SETLKW = 33, | |
fd72faac | 247 | FUSE_ACCESS = 34, |
a4d27e75 MS |
248 | FUSE_CREATE = 35, |
249 | FUSE_INTERRUPT = 36, | |
b2d2272f | 250 | FUSE_BMAP = 37, |
0ec7ca41 | 251 | FUSE_DESTROY = 38, |
59efec7b | 252 | FUSE_IOCTL = 39, |
95668a69 | 253 | FUSE_POLL = 40, |
151060ac TH |
254 | |
255 | /* CUSE specific operations */ | |
256 | CUSE_INIT = 4096, | |
334f485d MS |
257 | }; |
258 | ||
8599396b | 259 | enum fuse_notify_code { |
95668a69 | 260 | FUSE_NOTIFY_POLL = 1, |
3b463ae0 JM |
261 | FUSE_NOTIFY_INVAL_INODE = 2, |
262 | FUSE_NOTIFY_INVAL_ENTRY = 3, | |
8599396b TH |
263 | FUSE_NOTIFY_CODE_MAX, |
264 | }; | |
265 | ||
1d3d752b MS |
266 | /* The read buffer is required to be at least 8k, but may be much larger */ |
267 | #define FUSE_MIN_READ_BUFFER 8192 | |
e5e5558e | 268 | |
0e9663ee MS |
269 | #define FUSE_COMPAT_ENTRY_OUT_SIZE 120 |
270 | ||
e5e5558e MS |
271 | struct fuse_entry_out { |
272 | __u64 nodeid; /* Inode ID */ | |
273 | __u64 generation; /* Inode generation: nodeid:gen must | |
274 | be unique for the fs's lifetime */ | |
275 | __u64 entry_valid; /* Cache timeout for the name */ | |
276 | __u64 attr_valid; /* Cache timeout for the attributes */ | |
277 | __u32 entry_valid_nsec; | |
278 | __u32 attr_valid_nsec; | |
279 | struct fuse_attr attr; | |
280 | }; | |
281 | ||
282 | struct fuse_forget_in { | |
9e6268db | 283 | __u64 nlookup; |
e5e5558e MS |
284 | }; |
285 | ||
c79e322f MS |
286 | struct fuse_getattr_in { |
287 | __u32 getattr_flags; | |
288 | __u32 dummy; | |
289 | __u64 fh; | |
290 | }; | |
291 | ||
0e9663ee MS |
292 | #define FUSE_COMPAT_ATTR_OUT_SIZE 96 |
293 | ||
e5e5558e MS |
294 | struct fuse_attr_out { |
295 | __u64 attr_valid; /* Cache timeout for the attributes */ | |
296 | __u32 attr_valid_nsec; | |
297 | __u32 dummy; | |
298 | struct fuse_attr attr; | |
299 | }; | |
300 | ||
e0a43ddc MS |
301 | #define FUSE_COMPAT_MKNOD_IN_SIZE 8 |
302 | ||
9e6268db MS |
303 | struct fuse_mknod_in { |
304 | __u32 mode; | |
305 | __u32 rdev; | |
e0a43ddc MS |
306 | __u32 umask; |
307 | __u32 padding; | |
9e6268db MS |
308 | }; |
309 | ||
310 | struct fuse_mkdir_in { | |
311 | __u32 mode; | |
e0a43ddc | 312 | __u32 umask; |
9e6268db MS |
313 | }; |
314 | ||
315 | struct fuse_rename_in { | |
316 | __u64 newdir; | |
317 | }; | |
318 | ||
319 | struct fuse_link_in { | |
320 | __u64 oldnodeid; | |
321 | }; | |
322 | ||
323 | struct fuse_setattr_in { | |
324 | __u32 valid; | |
06663267 | 325 | __u32 padding; |
befc649c MS |
326 | __u64 fh; |
327 | __u64 size; | |
f3332114 | 328 | __u64 lock_owner; |
befc649c MS |
329 | __u64 atime; |
330 | __u64 mtime; | |
331 | __u64 unused2; | |
332 | __u32 atimensec; | |
333 | __u32 mtimensec; | |
334 | __u32 unused3; | |
335 | __u32 mode; | |
336 | __u32 unused4; | |
337 | __u32 uid; | |
338 | __u32 gid; | |
339 | __u32 unused5; | |
9e6268db MS |
340 | }; |
341 | ||
b6aeaded | 342 | struct fuse_open_in { |
e0a43ddc MS |
343 | __u32 flags; |
344 | __u32 unused; | |
345 | }; | |
346 | ||
347 | struct fuse_create_in { | |
b6aeaded | 348 | __u32 flags; |
fd72faac | 349 | __u32 mode; |
e0a43ddc MS |
350 | __u32 umask; |
351 | __u32 padding; | |
b6aeaded MS |
352 | }; |
353 | ||
354 | struct fuse_open_out { | |
355 | __u64 fh; | |
356 | __u32 open_flags; | |
06663267 | 357 | __u32 padding; |
b6aeaded MS |
358 | }; |
359 | ||
360 | struct fuse_release_in { | |
361 | __u64 fh; | |
362 | __u32 flags; | |
e9168c18 MS |
363 | __u32 release_flags; |
364 | __u64 lock_owner; | |
b6aeaded MS |
365 | }; |
366 | ||
367 | struct fuse_flush_in { | |
368 | __u64 fh; | |
e9168c18 | 369 | __u32 unused; |
06663267 | 370 | __u32 padding; |
71421259 | 371 | __u64 lock_owner; |
b6aeaded MS |
372 | }; |
373 | ||
374 | struct fuse_read_in { | |
375 | __u64 fh; | |
376 | __u64 offset; | |
377 | __u32 size; | |
f3332114 MS |
378 | __u32 read_flags; |
379 | __u64 lock_owner; | |
a6643094 MS |
380 | __u32 flags; |
381 | __u32 padding; | |
b6aeaded MS |
382 | }; |
383 | ||
f3332114 MS |
384 | #define FUSE_COMPAT_WRITE_IN_SIZE 24 |
385 | ||
b6aeaded MS |
386 | struct fuse_write_in { |
387 | __u64 fh; | |
388 | __u64 offset; | |
389 | __u32 size; | |
390 | __u32 write_flags; | |
f3332114 | 391 | __u64 lock_owner; |
a6643094 MS |
392 | __u32 flags; |
393 | __u32 padding; | |
b6aeaded MS |
394 | }; |
395 | ||
396 | struct fuse_write_out { | |
397 | __u32 size; | |
06663267 | 398 | __u32 padding; |
b6aeaded MS |
399 | }; |
400 | ||
de5f1202 MS |
401 | #define FUSE_COMPAT_STATFS_SIZE 48 |
402 | ||
e5e5558e MS |
403 | struct fuse_statfs_out { |
404 | struct fuse_kstatfs st; | |
405 | }; | |
406 | ||
b6aeaded MS |
407 | struct fuse_fsync_in { |
408 | __u64 fh; | |
409 | __u32 fsync_flags; | |
06663267 | 410 | __u32 padding; |
b6aeaded MS |
411 | }; |
412 | ||
92a8780e MS |
413 | struct fuse_setxattr_in { |
414 | __u32 size; | |
415 | __u32 flags; | |
416 | }; | |
417 | ||
418 | struct fuse_getxattr_in { | |
419 | __u32 size; | |
06663267 | 420 | __u32 padding; |
92a8780e MS |
421 | }; |
422 | ||
423 | struct fuse_getxattr_out { | |
424 | __u32 size; | |
06663267 | 425 | __u32 padding; |
92a8780e MS |
426 | }; |
427 | ||
71421259 MS |
428 | struct fuse_lk_in { |
429 | __u64 fh; | |
430 | __u64 owner; | |
431 | struct fuse_file_lock lk; | |
a9ff4f87 MS |
432 | __u32 lk_flags; |
433 | __u32 padding; | |
71421259 MS |
434 | }; |
435 | ||
436 | struct fuse_lk_out { | |
437 | struct fuse_file_lock lk; | |
438 | }; | |
439 | ||
31d40d74 MS |
440 | struct fuse_access_in { |
441 | __u32 mask; | |
442 | __u32 padding; | |
443 | }; | |
444 | ||
3ec870d5 | 445 | struct fuse_init_in { |
334f485d MS |
446 | __u32 major; |
447 | __u32 minor; | |
9cd68455 MS |
448 | __u32 max_readahead; |
449 | __u32 flags; | |
334f485d MS |
450 | }; |
451 | ||
3ec870d5 MS |
452 | struct fuse_init_out { |
453 | __u32 major; | |
454 | __u32 minor; | |
9cd68455 MS |
455 | __u32 max_readahead; |
456 | __u32 flags; | |
7a6d3c8b CH |
457 | __u16 max_background; |
458 | __u16 congestion_threshold; | |
3ec870d5 MS |
459 | __u32 max_write; |
460 | }; | |
461 | ||
151060ac TH |
462 | #define CUSE_INIT_INFO_MAX 4096 |
463 | ||
464 | struct cuse_init_in { | |
465 | __u32 major; | |
466 | __u32 minor; | |
467 | __u32 unused; | |
468 | __u32 flags; | |
469 | }; | |
470 | ||
471 | struct cuse_init_out { | |
472 | __u32 major; | |
473 | __u32 minor; | |
474 | __u32 unused; | |
475 | __u32 flags; | |
476 | __u32 max_read; | |
477 | __u32 max_write; | |
478 | __u32 dev_major; /* chardev major */ | |
479 | __u32 dev_minor; /* chardev minor */ | |
480 | __u32 spare[10]; | |
481 | }; | |
482 | ||
a4d27e75 MS |
483 | struct fuse_interrupt_in { |
484 | __u64 unique; | |
485 | }; | |
486 | ||
b2d2272f MS |
487 | struct fuse_bmap_in { |
488 | __u64 block; | |
489 | __u32 blocksize; | |
490 | __u32 padding; | |
491 | }; | |
492 | ||
493 | struct fuse_bmap_out { | |
494 | __u64 block; | |
495 | }; | |
496 | ||
59efec7b TH |
497 | struct fuse_ioctl_in { |
498 | __u64 fh; | |
499 | __u32 flags; | |
500 | __u32 cmd; | |
501 | __u64 arg; | |
502 | __u32 in_size; | |
503 | __u32 out_size; | |
504 | }; | |
505 | ||
506 | struct fuse_ioctl_out { | |
507 | __s32 result; | |
508 | __u32 flags; | |
509 | __u32 in_iovs; | |
510 | __u32 out_iovs; | |
511 | }; | |
512 | ||
95668a69 TH |
513 | struct fuse_poll_in { |
514 | __u64 fh; | |
515 | __u64 kh; | |
516 | __u32 flags; | |
517 | __u32 padding; | |
518 | }; | |
519 | ||
520 | struct fuse_poll_out { | |
521 | __u32 revents; | |
522 | __u32 padding; | |
523 | }; | |
524 | ||
525 | struct fuse_notify_poll_wakeup_out { | |
526 | __u64 kh; | |
527 | }; | |
528 | ||
334f485d MS |
529 | struct fuse_in_header { |
530 | __u32 len; | |
531 | __u32 opcode; | |
532 | __u64 unique; | |
533 | __u64 nodeid; | |
534 | __u32 uid; | |
535 | __u32 gid; | |
536 | __u32 pid; | |
06663267 | 537 | __u32 padding; |
334f485d MS |
538 | }; |
539 | ||
540 | struct fuse_out_header { | |
541 | __u32 len; | |
542 | __s32 error; | |
543 | __u64 unique; | |
544 | }; | |
545 | ||
e5e5558e MS |
546 | struct fuse_dirent { |
547 | __u64 ino; | |
548 | __u64 off; | |
549 | __u32 namelen; | |
550 | __u32 type; | |
551 | char name[0]; | |
552 | }; | |
553 | ||
21f3da95 | 554 | #define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name) |
e5e5558e MS |
555 | #define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(__u64) - 1) & ~(sizeof(__u64) - 1)) |
556 | #define FUSE_DIRENT_SIZE(d) \ | |
557 | FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen) | |
29d434b3 | 558 | |
3b463ae0 JM |
559 | struct fuse_notify_inval_inode_out { |
560 | __u64 ino; | |
561 | __s64 off; | |
562 | __s64 len; | |
563 | }; | |
564 | ||
565 | struct fuse_notify_inval_entry_out { | |
566 | __u64 parent; | |
567 | __u32 namelen; | |
568 | __u32 padding; | |
569 | }; | |
570 | ||
29d434b3 | 571 | #endif /* _LINUX_FUSE_H */ |