Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
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
39#ifndef _LINUX_FUSE_H
40#define _LINUX_FUSE_H
41
42#include <linux/types.h>
43
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
64/** Version number of this interface */
65#define FUSE_KERNEL_VERSION 7
66
67/** Minor version number of this interface */
68#define FUSE_KERNEL_MINOR_VERSION 13
69
70/** The node ID of the root inode */
71#define FUSE_ROOT_ID 1
72
73/* Make sure all structures are padded to 64bit boundary, so 32bit
74 userspace works under 64bit kernels */
75
76struct 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;
91 __u32 blksize;
92 __u32 padding;
93};
94
95struct fuse_kstatfs {
96 __u64 blocks;
97 __u64 bfree;
98 __u64 bavail;
99 __u64 files;
100 __u64 ffree;
101 __u32 bsize;
102 __u32 namelen;
103 __u32 frsize;
104 __u32 padding;
105 __u32 spare[6];
106};
107
108struct fuse_file_lock {
109 __u64 start;
110 __u64 end;
111 __u32 type;
112 __u32 pid; /* tgid */
113};
114
115/**
116 * Bitmasks for fuse_setattr_in.valid
117 */
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)
124#define FATTR_FH (1 << 6)
125#define FATTR_ATIME_NOW (1 << 7)
126#define FATTR_MTIME_NOW (1 << 8)
127#define FATTR_LOCKOWNER (1 << 9)
128
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
134 * FOPEN_NONSEEKABLE: the file is not seekable
135 */
136#define FOPEN_DIRECT_IO (1 << 0)
137#define FOPEN_KEEP_CACHE (1 << 1)
138#define FOPEN_NONSEEKABLE (1 << 2)
139
140/**
141 * INIT request/reply flags
142 *
143 * FUSE_EXPORT_SUPPORT: filesystem handles lookups of "." and ".."
144 * FUSE_DONT_MASK: don't apply umask to file mode on create operations
145 */
146#define FUSE_ASYNC_READ (1 << 0)
147#define FUSE_POSIX_LOCKS (1 << 1)
148#define FUSE_FILE_OPS (1 << 2)
149#define FUSE_ATOMIC_O_TRUNC (1 << 3)
150#define FUSE_EXPORT_SUPPORT (1 << 4)
151#define FUSE_BIG_WRITES (1 << 5)
152#define FUSE_DONT_MASK (1 << 6)
153
154/**
155 * CUSE INIT request/reply flags
156 *
157 * CUSE_UNRESTRICTED_IOCTL: use unrestricted ioctl
158 */
159#define CUSE_UNRESTRICTED_IOCTL (1 << 0)
160
161/**
162 * Release flags
163 */
164#define FUSE_RELEASE_FLUSH (1 << 0)
165
166/**
167 * Getattr flags
168 */
169#define FUSE_GETATTR_FH (1 << 0)
170
171/**
172 * Lock flags
173 */
174#define FUSE_LK_FLOCK (1 << 0)
175
176/**
177 * WRITE flags
178 *
179 * FUSE_WRITE_CACHE: delayed write from page cache, file handle is guessed
180 * FUSE_WRITE_LOCKOWNER: lock_owner field is valid
181 */
182#define FUSE_WRITE_CACHE (1 << 0)
183#define FUSE_WRITE_LOCKOWNER (1 << 1)
184
185/**
186 * Read flags
187 */
188#define FUSE_READ_LOCKOWNER (1 << 1)
189
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
205/**
206 * Poll flags
207 *
208 * FUSE_POLL_SCHEDULE_NOTIFY: request poll notify
209 */
210#define FUSE_POLL_SCHEDULE_NOTIFY (1 << 0)
211
212enum fuse_opcode {
213 FUSE_LOOKUP = 1,
214 FUSE_FORGET = 2, /* no reply */
215 FUSE_GETATTR = 3,
216 FUSE_SETATTR = 4,
217 FUSE_READLINK = 5,
218 FUSE_SYMLINK = 6,
219 FUSE_MKNOD = 8,
220 FUSE_MKDIR = 9,
221 FUSE_UNLINK = 10,
222 FUSE_RMDIR = 11,
223 FUSE_RENAME = 12,
224 FUSE_LINK = 13,
225 FUSE_OPEN = 14,
226 FUSE_READ = 15,
227 FUSE_WRITE = 16,
228 FUSE_STATFS = 17,
229 FUSE_RELEASE = 18,
230 FUSE_FSYNC = 20,
231 FUSE_SETXATTR = 21,
232 FUSE_GETXATTR = 22,
233 FUSE_LISTXATTR = 23,
234 FUSE_REMOVEXATTR = 24,
235 FUSE_FLUSH = 25,
236 FUSE_INIT = 26,
237 FUSE_OPENDIR = 27,
238 FUSE_READDIR = 28,
239 FUSE_RELEASEDIR = 29,
240 FUSE_FSYNCDIR = 30,
241 FUSE_GETLK = 31,
242 FUSE_SETLK = 32,
243 FUSE_SETLKW = 33,
244 FUSE_ACCESS = 34,
245 FUSE_CREATE = 35,
246 FUSE_INTERRUPT = 36,
247 FUSE_BMAP = 37,
248 FUSE_DESTROY = 38,
249 FUSE_IOCTL = 39,
250 FUSE_POLL = 40,
251
252 /* CUSE specific operations */
253 CUSE_INIT = 4096,
254};
255
256enum fuse_notify_code {
257 FUSE_NOTIFY_POLL = 1,
258 FUSE_NOTIFY_INVAL_INODE = 2,
259 FUSE_NOTIFY_INVAL_ENTRY = 3,
260 FUSE_NOTIFY_CODE_MAX,
261};
262
263/* The read buffer is required to be at least 8k, but may be much larger */
264#define FUSE_MIN_READ_BUFFER 8192
265
266#define FUSE_COMPAT_ENTRY_OUT_SIZE 120
267
268struct 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
279struct fuse_forget_in {
280 __u64 nlookup;
281};
282
283struct fuse_getattr_in {
284 __u32 getattr_flags;
285 __u32 dummy;
286 __u64 fh;
287};
288
289#define FUSE_COMPAT_ATTR_OUT_SIZE 96
290
291struct 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
298#define FUSE_COMPAT_MKNOD_IN_SIZE 8
299
300struct fuse_mknod_in {
301 __u32 mode;
302 __u32 rdev;
303 __u32 umask;
304 __u32 padding;
305};
306
307struct fuse_mkdir_in {
308 __u32 mode;
309 __u32 umask;
310};
311
312struct fuse_rename_in {
313 __u64 newdir;
314};
315
316struct fuse_link_in {
317 __u64 oldnodeid;
318};
319
320struct fuse_setattr_in {
321 __u32 valid;
322 __u32 padding;
323 __u64 fh;
324 __u64 size;
325 __u64 lock_owner;
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;
337};
338
339struct fuse_open_in {
340 __u32 flags;
341 __u32 unused;
342};
343
344struct fuse_create_in {
345 __u32 flags;
346 __u32 mode;
347 __u32 umask;
348 __u32 padding;
349};
350
351struct fuse_open_out {
352 __u64 fh;
353 __u32 open_flags;
354 __u32 padding;
355};
356
357struct fuse_release_in {
358 __u64 fh;
359 __u32 flags;
360 __u32 release_flags;
361 __u64 lock_owner;
362};
363
364struct fuse_flush_in {
365 __u64 fh;
366 __u32 unused;
367 __u32 padding;
368 __u64 lock_owner;
369};
370
371struct fuse_read_in {
372 __u64 fh;
373 __u64 offset;
374 __u32 size;
375 __u32 read_flags;
376 __u64 lock_owner;
377 __u32 flags;
378 __u32 padding;
379};
380
381#define FUSE_COMPAT_WRITE_IN_SIZE 24
382
383struct fuse_write_in {
384 __u64 fh;
385 __u64 offset;
386 __u32 size;
387 __u32 write_flags;
388 __u64 lock_owner;
389 __u32 flags;
390 __u32 padding;
391};
392
393struct fuse_write_out {
394 __u32 size;
395 __u32 padding;
396};
397
398#define FUSE_COMPAT_STATFS_SIZE 48
399
400struct fuse_statfs_out {
401 struct fuse_kstatfs st;
402};
403
404struct fuse_fsync_in {
405 __u64 fh;
406 __u32 fsync_flags;
407 __u32 padding;
408};
409
410struct fuse_setxattr_in {
411 __u32 size;
412 __u32 flags;
413};
414
415struct fuse_getxattr_in {
416 __u32 size;
417 __u32 padding;
418};
419
420struct fuse_getxattr_out {
421 __u32 size;
422 __u32 padding;
423};
424
425struct fuse_lk_in {
426 __u64 fh;
427 __u64 owner;
428 struct fuse_file_lock lk;
429 __u32 lk_flags;
430 __u32 padding;
431};
432
433struct fuse_lk_out {
434 struct fuse_file_lock lk;
435};
436
437struct fuse_access_in {
438 __u32 mask;
439 __u32 padding;
440};
441
442struct fuse_init_in {
443 __u32 major;
444 __u32 minor;
445 __u32 max_readahead;
446 __u32 flags;
447};
448
449struct fuse_init_out {
450 __u32 major;
451 __u32 minor;
452 __u32 max_readahead;
453 __u32 flags;
454 __u16 max_background;
455 __u16 congestion_threshold;
456 __u32 max_write;
457};
458
459#define CUSE_INIT_INFO_MAX 4096
460
461struct cuse_init_in {
462 __u32 major;
463 __u32 minor;
464 __u32 unused;
465 __u32 flags;
466};
467
468struct 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
480struct fuse_interrupt_in {
481 __u64 unique;
482};
483
484struct fuse_bmap_in {
485 __u64 block;
486 __u32 blocksize;
487 __u32 padding;
488};
489
490struct fuse_bmap_out {
491 __u64 block;
492};
493
494struct 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
503struct fuse_ioctl_out {
504 __s32 result;
505 __u32 flags;
506 __u32 in_iovs;
507 __u32 out_iovs;
508};
509
510struct fuse_poll_in {
511 __u64 fh;
512 __u64 kh;
513 __u32 flags;
514 __u32 padding;
515};
516
517struct fuse_poll_out {
518 __u32 revents;
519 __u32 padding;
520};
521
522struct fuse_notify_poll_wakeup_out {
523 __u64 kh;
524};
525
526struct fuse_in_header {
527 __u32 len;
528 __u32 opcode;
529 __u64 unique;
530 __u64 nodeid;
531 __u32 uid;
532 __u32 gid;
533 __u32 pid;
534 __u32 padding;
535};
536
537struct fuse_out_header {
538 __u32 len;
539 __s32 error;
540 __u64 unique;
541};
542
543struct fuse_dirent {
544 __u64 ino;
545 __u64 off;
546 __u32 namelen;
547 __u32 type;
548 char name[0];
549};
550
551#define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name)
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)
555
556struct fuse_notify_inval_inode_out {
557 __u64 ino;
558 __s64 off;
559 __s64 len;
560};
561
562struct fuse_notify_inval_entry_out {
563 __u64 parent;
564 __u32 namelen;
565 __u32 padding;
566};
567
568#endif /* _LINUX_FUSE_H */