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