ipv6/udp: Use the correct variable to determine non-blocking condition
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / linux / fuse.h
blobd464de53db4399c598ec3793f75290856b049255
1 /*
2 FUSE: Filesystem in Userspace
3 Copyright (C) 2001-2008 Miklos Szeredi <miklos@szeredi.hu>
5 This program can be distributed under the terms of the GNU GPL.
6 See the file COPYING.
7 */
9 /*
10 * This file defines the kernel interface of FUSE
12 * Protocol changelog:
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
21 * 7.10
22 * - add nonseekable open flag
24 * 7.11
25 * - add IOCTL message
26 * - add unsolicited notification support
27 * - add POLL message and NOTIFY_POLL notification
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
34 * 7.13
35 * - make max number of background requests and congestion threshold
36 * tunables
38 * 7.14
39 * - add splice support to fuse device
41 * 7.15
42 * - add store notify
43 * - add retrieve notify
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
52 #ifndef _LINUX_FUSE_H
53 #define _LINUX_FUSE_H
55 #include <linux/types.h>
58 * Version negotiation:
60 * Both the kernel and userspace send the version they support in the
61 * INIT request and reply respectively.
63 * If the major versions match then both shall use the smallest
64 * of the two minor versions for communication.
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.
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).
77 /** Version number of this interface */
78 #define FUSE_KERNEL_VERSION 7
80 /** Minor version number of this interface */
81 #define FUSE_KERNEL_MINOR_VERSION 16
83 /** The node ID of the root inode */
84 #define FUSE_ROOT_ID 1
86 /* Make sure all structures are padded to 64bit boundary, so 32bit
87 userspace works under 64bit kernels */
89 struct 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;
104 __u32 blksize;
105 __u32 padding;
108 struct fuse_kstatfs {
109 __u64 blocks;
110 __u64 bfree;
111 __u64 bavail;
112 __u64 files;
113 __u64 ffree;
114 __u32 bsize;
115 __u32 namelen;
116 __u32 frsize;
117 __u32 padding;
118 __u32 spare[6];
121 struct fuse_file_lock {
122 __u64 start;
123 __u64 end;
124 __u32 type;
125 __u32 pid; /* tgid */
129 * Bitmasks for fuse_setattr_in.valid
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)
137 #define FATTR_FH (1 << 6)
138 #define FATTR_ATIME_NOW (1 << 7)
139 #define FATTR_MTIME_NOW (1 << 8)
140 #define FATTR_LOCKOWNER (1 << 9)
143 * Flags returned by the OPEN request
145 * FOPEN_DIRECT_IO: bypass page cache for this open file
146 * FOPEN_KEEP_CACHE: don't invalidate the data cache on open
147 * FOPEN_NONSEEKABLE: the file is not seekable
149 #define FOPEN_DIRECT_IO (1 << 0)
150 #define FOPEN_KEEP_CACHE (1 << 1)
151 #define FOPEN_NONSEEKABLE (1 << 2)
154 * INIT request/reply flags
156 * FUSE_EXPORT_SUPPORT: filesystem handles lookups of "." and ".."
157 * FUSE_DONT_MASK: don't apply umask to file mode on create operations
159 #define FUSE_ASYNC_READ (1 << 0)
160 #define FUSE_POSIX_LOCKS (1 << 1)
161 #define FUSE_FILE_OPS (1 << 2)
162 #define FUSE_ATOMIC_O_TRUNC (1 << 3)
163 #define FUSE_EXPORT_SUPPORT (1 << 4)
164 #define FUSE_BIG_WRITES (1 << 5)
165 #define FUSE_DONT_MASK (1 << 6)
168 * CUSE INIT request/reply flags
170 * CUSE_UNRESTRICTED_IOCTL: use unrestricted ioctl
172 #define CUSE_UNRESTRICTED_IOCTL (1 << 0)
175 * Release flags
177 #define FUSE_RELEASE_FLUSH (1 << 0)
180 * Getattr flags
182 #define FUSE_GETATTR_FH (1 << 0)
185 * Lock flags
187 #define FUSE_LK_FLOCK (1 << 0)
190 * WRITE flags
192 * FUSE_WRITE_CACHE: delayed write from page cache, file handle is guessed
193 * FUSE_WRITE_LOCKOWNER: lock_owner field is valid
195 #define FUSE_WRITE_CACHE (1 << 0)
196 #define FUSE_WRITE_LOCKOWNER (1 << 1)
199 * Read flags
201 #define FUSE_READ_LOCKOWNER (1 << 1)
204 * Ioctl flags
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
209 * FUSE_IOCTL_32BIT: 32bit ioctl
211 * FUSE_IOCTL_MAX_IOV: maximum of in_iovecs + out_iovecs
213 #define FUSE_IOCTL_COMPAT (1 << 0)
214 #define FUSE_IOCTL_UNRESTRICTED (1 << 1)
215 #define FUSE_IOCTL_RETRY (1 << 2)
216 #define FUSE_IOCTL_32BIT (1 << 3)
218 #define FUSE_IOCTL_MAX_IOV 256
221 * Poll flags
223 * FUSE_POLL_SCHEDULE_NOTIFY: request poll notify
225 #define FUSE_POLL_SCHEDULE_NOTIFY (1 << 0)
227 enum fuse_opcode {
228 FUSE_LOOKUP = 1,
229 FUSE_FORGET = 2, /* no reply */
230 FUSE_GETATTR = 3,
231 FUSE_SETATTR = 4,
232 FUSE_READLINK = 5,
233 FUSE_SYMLINK = 6,
234 FUSE_MKNOD = 8,
235 FUSE_MKDIR = 9,
236 FUSE_UNLINK = 10,
237 FUSE_RMDIR = 11,
238 FUSE_RENAME = 12,
239 FUSE_LINK = 13,
240 FUSE_OPEN = 14,
241 FUSE_READ = 15,
242 FUSE_WRITE = 16,
243 FUSE_STATFS = 17,
244 FUSE_RELEASE = 18,
245 FUSE_FSYNC = 20,
246 FUSE_SETXATTR = 21,
247 FUSE_GETXATTR = 22,
248 FUSE_LISTXATTR = 23,
249 FUSE_REMOVEXATTR = 24,
250 FUSE_FLUSH = 25,
251 FUSE_INIT = 26,
252 FUSE_OPENDIR = 27,
253 FUSE_READDIR = 28,
254 FUSE_RELEASEDIR = 29,
255 FUSE_FSYNCDIR = 30,
256 FUSE_GETLK = 31,
257 FUSE_SETLK = 32,
258 FUSE_SETLKW = 33,
259 FUSE_ACCESS = 34,
260 FUSE_CREATE = 35,
261 FUSE_INTERRUPT = 36,
262 FUSE_BMAP = 37,
263 FUSE_DESTROY = 38,
264 FUSE_IOCTL = 39,
265 FUSE_POLL = 40,
266 FUSE_NOTIFY_REPLY = 41,
267 FUSE_BATCH_FORGET = 42,
269 /* CUSE specific operations */
270 CUSE_INIT = 4096,
273 enum fuse_notify_code {
274 FUSE_NOTIFY_POLL = 1,
275 FUSE_NOTIFY_INVAL_INODE = 2,
276 FUSE_NOTIFY_INVAL_ENTRY = 3,
277 FUSE_NOTIFY_STORE = 4,
278 FUSE_NOTIFY_RETRIEVE = 5,
279 FUSE_NOTIFY_CODE_MAX,
282 /* The read buffer is required to be at least 8k, but may be much larger */
283 #define FUSE_MIN_READ_BUFFER 8192
285 #define FUSE_COMPAT_ENTRY_OUT_SIZE 120
287 struct 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;
298 struct fuse_forget_in {
299 __u64 nlookup;
302 struct fuse_forget_one {
303 __u64 nodeid;
304 __u64 nlookup;
307 struct fuse_batch_forget_in {
308 __u32 count;
309 __u32 dummy;
312 struct fuse_getattr_in {
313 __u32 getattr_flags;
314 __u32 dummy;
315 __u64 fh;
318 #define FUSE_COMPAT_ATTR_OUT_SIZE 96
320 struct 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;
327 #define FUSE_COMPAT_MKNOD_IN_SIZE 8
329 struct fuse_mknod_in {
330 __u32 mode;
331 __u32 rdev;
332 __u32 umask;
333 __u32 padding;
336 struct fuse_mkdir_in {
337 __u32 mode;
338 __u32 umask;
341 struct fuse_rename_in {
342 __u64 newdir;
345 struct fuse_link_in {
346 __u64 oldnodeid;
349 struct fuse_setattr_in {
350 __u32 valid;
351 __u32 padding;
352 __u64 fh;
353 __u64 size;
354 __u64 lock_owner;
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;
368 struct fuse_open_in {
369 __u32 flags;
370 __u32 unused;
373 struct fuse_create_in {
374 __u32 flags;
375 __u32 mode;
376 __u32 umask;
377 __u32 padding;
380 struct fuse_open_out {
381 __u64 fh;
382 __u32 open_flags;
383 __u32 padding;
386 struct fuse_release_in {
387 __u64 fh;
388 __u32 flags;
389 __u32 release_flags;
390 __u64 lock_owner;
393 struct fuse_flush_in {
394 __u64 fh;
395 __u32 unused;
396 __u32 padding;
397 __u64 lock_owner;
400 struct fuse_read_in {
401 __u64 fh;
402 __u64 offset;
403 __u32 size;
404 __u32 read_flags;
405 __u64 lock_owner;
406 __u32 flags;
407 __u32 padding;
410 #define FUSE_COMPAT_WRITE_IN_SIZE 24
412 struct fuse_write_in {
413 __u64 fh;
414 __u64 offset;
415 __u32 size;
416 __u32 write_flags;
417 __u64 lock_owner;
418 __u32 flags;
419 __u32 padding;
422 struct fuse_write_out {
423 __u32 size;
424 __u32 padding;
427 #define FUSE_COMPAT_STATFS_SIZE 48
429 struct fuse_statfs_out {
430 struct fuse_kstatfs st;
433 struct fuse_fsync_in {
434 __u64 fh;
435 __u32 fsync_flags;
436 __u32 padding;
439 struct fuse_setxattr_in {
440 __u32 size;
441 __u32 flags;
444 struct fuse_getxattr_in {
445 __u32 size;
446 __u32 padding;
449 struct fuse_getxattr_out {
450 __u32 size;
451 __u32 padding;
454 struct fuse_lk_in {
455 __u64 fh;
456 __u64 owner;
457 struct fuse_file_lock lk;
458 __u32 lk_flags;
459 __u32 padding;
462 struct fuse_lk_out {
463 struct fuse_file_lock lk;
466 struct fuse_access_in {
467 __u32 mask;
468 __u32 padding;
471 struct fuse_init_in {
472 __u32 major;
473 __u32 minor;
474 __u32 max_readahead;
475 __u32 flags;
478 struct fuse_init_out {
479 __u32 major;
480 __u32 minor;
481 __u32 max_readahead;
482 __u32 flags;
483 __u16 max_background;
484 __u16 congestion_threshold;
485 __u32 max_write;
488 #define CUSE_INIT_INFO_MAX 4096
490 struct cuse_init_in {
491 __u32 major;
492 __u32 minor;
493 __u32 unused;
494 __u32 flags;
497 struct 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];
509 struct fuse_interrupt_in {
510 __u64 unique;
513 struct fuse_bmap_in {
514 __u64 block;
515 __u32 blocksize;
516 __u32 padding;
519 struct fuse_bmap_out {
520 __u64 block;
523 struct fuse_ioctl_in {
524 __u64 fh;
525 __u32 flags;
526 __u32 cmd;
527 __u64 arg;
528 __u32 in_size;
529 __u32 out_size;
532 struct fuse_ioctl_iovec {
533 __u64 base;
534 __u64 len;
537 struct fuse_ioctl_out {
538 __s32 result;
539 __u32 flags;
540 __u32 in_iovs;
541 __u32 out_iovs;
544 struct fuse_poll_in {
545 __u64 fh;
546 __u64 kh;
547 __u32 flags;
548 __u32 padding;
551 struct fuse_poll_out {
552 __u32 revents;
553 __u32 padding;
556 struct fuse_notify_poll_wakeup_out {
557 __u64 kh;
560 struct fuse_in_header {
561 __u32 len;
562 __u32 opcode;
563 __u64 unique;
564 __u64 nodeid;
565 __u32 uid;
566 __u32 gid;
567 __u32 pid;
568 __u32 padding;
571 struct fuse_out_header {
572 __u32 len;
573 __s32 error;
574 __u64 unique;
577 struct fuse_dirent {
578 __u64 ino;
579 __u64 off;
580 __u32 namelen;
581 __u32 type;
582 char name[0];
585 #define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name)
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)
590 struct fuse_notify_inval_inode_out {
591 __u64 ino;
592 __s64 off;
593 __s64 len;
596 struct fuse_notify_inval_entry_out {
597 __u64 parent;
598 __u32 namelen;
599 __u32 padding;
602 struct fuse_notify_store_out {
603 __u64 nodeid;
604 __u64 offset;
605 __u32 size;
606 __u32 padding;
609 struct fuse_notify_retrieve_out {
610 __u64 notify_unique;
611 __u64 nodeid;
612 __u64 offset;
613 __u32 size;
614 __u32 padding;
617 /* Matches the size of fuse_write_in */
618 struct fuse_notify_retrieve_in {
619 __u64 dummy1;
620 __u64 offset;
621 __u32 size;
622 __u32 dummy2;
623 __u64 dummy3;
624 __u64 dummy4;
627 #endif /* _LINUX_FUSE_H */