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