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