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