1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109#ifndef _LINUX_FUSE_H
110#define _LINUX_FUSE_H
111
112#ifdef __KERNEL__
113#include <linux/types.h>
114#else
115#include <stdint.h>
116#endif
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139#define FUSE_KERNEL_VERSION 7
140
141
142#define FUSE_KERNEL_MINOR_VERSION 22
143
144
145#define FUSE_ROOT_ID 1
146
147
148
149
150struct fuse_attr {
151 uint64_t ino;
152 uint64_t size;
153 uint64_t blocks;
154 uint64_t atime;
155 uint64_t mtime;
156 uint64_t ctime;
157 uint32_t atimensec;
158 uint32_t mtimensec;
159 uint32_t ctimensec;
160 uint32_t mode;
161 uint32_t nlink;
162 uint32_t uid;
163 uint32_t gid;
164 uint32_t rdev;
165 uint32_t blksize;
166 uint32_t padding;
167};
168
169struct fuse_kstatfs {
170 uint64_t blocks;
171 uint64_t bfree;
172 uint64_t bavail;
173 uint64_t files;
174 uint64_t ffree;
175 uint32_t bsize;
176 uint32_t namelen;
177 uint32_t frsize;
178 uint32_t padding;
179 uint32_t spare[6];
180};
181
182struct fuse_file_lock {
183 uint64_t start;
184 uint64_t end;
185 uint32_t type;
186 uint32_t pid;
187};
188
189
190
191
192#define FATTR_MODE (1 << 0)
193#define FATTR_UID (1 << 1)
194#define FATTR_GID (1 << 2)
195#define FATTR_SIZE (1 << 3)
196#define FATTR_ATIME (1 << 4)
197#define FATTR_MTIME (1 << 5)
198#define FATTR_FH (1 << 6)
199#define FATTR_ATIME_NOW (1 << 7)
200#define FATTR_MTIME_NOW (1 << 8)
201#define FATTR_LOCKOWNER (1 << 9)
202
203
204
205
206
207
208
209
210#define FOPEN_DIRECT_IO (1 << 0)
211#define FOPEN_KEEP_CACHE (1 << 1)
212#define FOPEN_NONSEEKABLE (1 << 2)
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234#define FUSE_ASYNC_READ (1 << 0)
235#define FUSE_POSIX_LOCKS (1 << 1)
236#define FUSE_FILE_OPS (1 << 2)
237#define FUSE_ATOMIC_O_TRUNC (1 << 3)
238#define FUSE_EXPORT_SUPPORT (1 << 4)
239#define FUSE_BIG_WRITES (1 << 5)
240#define FUSE_DONT_MASK (1 << 6)
241#define FUSE_SPLICE_WRITE (1 << 7)
242#define FUSE_SPLICE_MOVE (1 << 8)
243#define FUSE_SPLICE_READ (1 << 9)
244#define FUSE_FLOCK_LOCKS (1 << 10)
245#define FUSE_HAS_IOCTL_DIR (1 << 11)
246#define FUSE_AUTO_INVAL_DATA (1 << 12)
247#define FUSE_DO_READDIRPLUS (1 << 13)
248#define FUSE_READDIRPLUS_AUTO (1 << 14)
249#define FUSE_ASYNC_DIO (1 << 15)
250
251
252
253
254
255
256#define CUSE_UNRESTRICTED_IOCTL (1 << 0)
257
258
259
260
261#define FUSE_RELEASE_FLUSH (1 << 0)
262#define FUSE_RELEASE_FLOCK_UNLOCK (1 << 1)
263
264
265
266
267#define FUSE_GETATTR_FH (1 << 0)
268
269
270
271
272#define FUSE_LK_FLOCK (1 << 0)
273
274
275
276
277
278
279
280#define FUSE_WRITE_CACHE (1 << 0)
281#define FUSE_WRITE_LOCKOWNER (1 << 1)
282
283
284
285
286#define FUSE_READ_LOCKOWNER (1 << 1)
287
288
289
290
291
292
293
294
295
296
297
298
299#define FUSE_IOCTL_COMPAT (1 << 0)
300#define FUSE_IOCTL_UNRESTRICTED (1 << 1)
301#define FUSE_IOCTL_RETRY (1 << 2)
302#define FUSE_IOCTL_32BIT (1 << 3)
303#define FUSE_IOCTL_DIR (1 << 4)
304
305#define FUSE_IOCTL_MAX_IOV 256
306
307
308
309
310
311
312#define FUSE_POLL_SCHEDULE_NOTIFY (1 << 0)
313
314enum fuse_opcode {
315 FUSE_LOOKUP = 1,
316 FUSE_FORGET = 2,
317 FUSE_GETATTR = 3,
318 FUSE_SETATTR = 4,
319 FUSE_READLINK = 5,
320 FUSE_SYMLINK = 6,
321 FUSE_MKNOD = 8,
322 FUSE_MKDIR = 9,
323 FUSE_UNLINK = 10,
324 FUSE_RMDIR = 11,
325 FUSE_RENAME = 12,
326 FUSE_LINK = 13,
327 FUSE_OPEN = 14,
328 FUSE_READ = 15,
329 FUSE_WRITE = 16,
330 FUSE_STATFS = 17,
331 FUSE_RELEASE = 18,
332 FUSE_FSYNC = 20,
333 FUSE_SETXATTR = 21,
334 FUSE_GETXATTR = 22,
335 FUSE_LISTXATTR = 23,
336 FUSE_REMOVEXATTR = 24,
337 FUSE_FLUSH = 25,
338 FUSE_INIT = 26,
339 FUSE_OPENDIR = 27,
340 FUSE_READDIR = 28,
341 FUSE_RELEASEDIR = 29,
342 FUSE_FSYNCDIR = 30,
343 FUSE_GETLK = 31,
344 FUSE_SETLK = 32,
345 FUSE_SETLKW = 33,
346 FUSE_ACCESS = 34,
347 FUSE_CREATE = 35,
348 FUSE_INTERRUPT = 36,
349 FUSE_BMAP = 37,
350 FUSE_DESTROY = 38,
351 FUSE_IOCTL = 39,
352 FUSE_POLL = 40,
353 FUSE_NOTIFY_REPLY = 41,
354 FUSE_BATCH_FORGET = 42,
355 FUSE_FALLOCATE = 43,
356 FUSE_READDIRPLUS = 44,
357 FUSE_RENAME2 = 45,
358 FUSE_LSEEK = 46,
359
360
361 CUSE_INIT = 4096,
362};
363
364enum fuse_notify_code {
365 FUSE_NOTIFY_POLL = 1,
366 FUSE_NOTIFY_INVAL_INODE = 2,
367 FUSE_NOTIFY_INVAL_ENTRY = 3,
368 FUSE_NOTIFY_STORE = 4,
369 FUSE_NOTIFY_RETRIEVE = 5,
370 FUSE_NOTIFY_DELETE = 6,
371 FUSE_NOTIFY_CODE_MAX,
372};
373
374
375#define FUSE_MIN_READ_BUFFER 8192
376
377#define FUSE_COMPAT_ENTRY_OUT_SIZE 120
378
379struct fuse_entry_out {
380 uint64_t nodeid;
381 uint64_t generation;
382
383 uint64_t entry_valid;
384 uint64_t attr_valid;
385 uint32_t entry_valid_nsec;
386 uint32_t attr_valid_nsec;
387 struct fuse_attr attr;
388};
389
390struct fuse_forget_in {
391 uint64_t nlookup;
392};
393
394struct fuse_forget_one {
395 uint64_t nodeid;
396 uint64_t nlookup;
397};
398
399struct fuse_batch_forget_in {
400 uint32_t count;
401 uint32_t dummy;
402};
403
404struct fuse_getattr_in {
405 uint32_t getattr_flags;
406 uint32_t dummy;
407 uint64_t fh;
408};
409
410#define FUSE_COMPAT_ATTR_OUT_SIZE 96
411
412struct fuse_attr_out {
413 uint64_t attr_valid;
414 uint32_t attr_valid_nsec;
415 uint32_t dummy;
416 struct fuse_attr attr;
417};
418
419#define FUSE_COMPAT_MKNOD_IN_SIZE 8
420
421struct fuse_mknod_in {
422 uint32_t mode;
423 uint32_t rdev;
424 uint32_t umask;
425 uint32_t padding;
426};
427
428struct fuse_mkdir_in {
429 uint32_t mode;
430 uint32_t umask;
431};
432
433struct fuse_rename_in {
434 uint64_t newdir;
435};
436
437struct fuse_rename2_in {
438 uint64_t newdir;
439 uint32_t flags;
440 uint32_t padding;
441};
442
443struct fuse_link_in {
444 uint64_t oldnodeid;
445};
446
447struct fuse_setattr_in {
448 uint32_t valid;
449 uint32_t padding;
450 uint64_t fh;
451 uint64_t size;
452 uint64_t lock_owner;
453 uint64_t atime;
454 uint64_t mtime;
455 uint64_t unused2;
456 uint32_t atimensec;
457 uint32_t mtimensec;
458 uint32_t unused3;
459 uint32_t mode;
460 uint32_t unused4;
461 uint32_t uid;
462 uint32_t gid;
463 uint32_t unused5;
464};
465
466struct fuse_open_in {
467 uint32_t flags;
468 uint32_t unused;
469};
470
471struct fuse_create_in {
472 uint32_t flags;
473 uint32_t mode;
474 uint32_t umask;
475 uint32_t padding;
476};
477
478struct fuse_open_out {
479 uint64_t fh;
480 uint32_t open_flags;
481 uint32_t padding;
482};
483
484struct fuse_release_in {
485 uint64_t fh;
486 uint32_t flags;
487 uint32_t release_flags;
488 uint64_t lock_owner;
489};
490
491struct fuse_flush_in {
492 uint64_t fh;
493 uint32_t unused;
494 uint32_t padding;
495 uint64_t lock_owner;
496};
497
498struct fuse_read_in {
499 uint64_t fh;
500 uint64_t offset;
501 uint32_t size;
502 uint32_t read_flags;
503 uint64_t lock_owner;
504 uint32_t flags;
505 uint32_t padding;
506};
507
508#define FUSE_COMPAT_WRITE_IN_SIZE 24
509
510struct fuse_write_in {
511 uint64_t fh;
512 uint64_t offset;
513 uint32_t size;
514 uint32_t write_flags;
515 uint64_t lock_owner;
516 uint32_t flags;
517 uint32_t padding;
518};
519
520struct fuse_write_out {
521 uint32_t size;
522 uint32_t padding;
523};
524
525#define FUSE_COMPAT_STATFS_SIZE 48
526
527struct fuse_statfs_out {
528 struct fuse_kstatfs st;
529};
530
531struct fuse_fsync_in {
532 uint64_t fh;
533 uint32_t fsync_flags;
534 uint32_t padding;
535};
536
537struct fuse_setxattr_in {
538 uint32_t size;
539 uint32_t flags;
540};
541
542struct fuse_getxattr_in {
543 uint32_t size;
544 uint32_t padding;
545};
546
547struct fuse_getxattr_out {
548 uint32_t size;
549 uint32_t padding;
550};
551
552struct fuse_lk_in {
553 uint64_t fh;
554 uint64_t owner;
555 struct fuse_file_lock lk;
556 uint32_t lk_flags;
557 uint32_t padding;
558};
559
560struct fuse_lk_out {
561 struct fuse_file_lock lk;
562};
563
564struct fuse_access_in {
565 uint32_t mask;
566 uint32_t padding;
567};
568
569struct fuse_init_in {
570 uint32_t major;
571 uint32_t minor;
572 uint32_t max_readahead;
573 uint32_t flags;
574};
575
576struct fuse_init_out {
577 uint32_t major;
578 uint32_t minor;
579 uint32_t max_readahead;
580 uint32_t flags;
581 uint16_t max_background;
582 uint16_t congestion_threshold;
583 uint32_t max_write;
584};
585
586#define CUSE_INIT_INFO_MAX 4096
587
588struct cuse_init_in {
589 uint32_t major;
590 uint32_t minor;
591 uint32_t unused;
592 uint32_t flags;
593};
594
595struct cuse_init_out {
596 uint32_t major;
597 uint32_t minor;
598 uint32_t unused;
599 uint32_t flags;
600 uint32_t max_read;
601 uint32_t max_write;
602 uint32_t dev_major;
603 uint32_t dev_minor;
604 uint32_t spare[10];
605};
606
607struct fuse_interrupt_in {
608 uint64_t unique;
609};
610
611struct fuse_bmap_in {
612 uint64_t block;
613 uint32_t blocksize;
614 uint32_t padding;
615};
616
617struct fuse_bmap_out {
618 uint64_t block;
619};
620
621struct fuse_ioctl_in {
622 uint64_t fh;
623 uint32_t flags;
624 uint32_t cmd;
625 uint64_t arg;
626 uint32_t in_size;
627 uint32_t out_size;
628};
629
630struct fuse_ioctl_iovec {
631 uint64_t base;
632 uint64_t len;
633};
634
635struct fuse_ioctl_out {
636 int32_t result;
637 uint32_t flags;
638 uint32_t in_iovs;
639 uint32_t out_iovs;
640};
641
642struct fuse_poll_in {
643 uint64_t fh;
644 uint64_t kh;
645 uint32_t flags;
646 uint32_t events;
647};
648
649struct fuse_poll_out {
650 uint32_t revents;
651 uint32_t padding;
652};
653
654struct fuse_notify_poll_wakeup_out {
655 uint64_t kh;
656};
657
658struct fuse_fallocate_in {
659 uint64_t fh;
660 uint64_t offset;
661 uint64_t length;
662 uint32_t mode;
663 uint32_t padding;
664};
665
666struct fuse_in_header {
667 uint32_t len;
668 uint32_t opcode;
669 uint64_t unique;
670 uint64_t nodeid;
671 uint32_t uid;
672 uint32_t gid;
673 uint32_t pid;
674 uint32_t padding;
675};
676
677struct fuse_out_header {
678 uint32_t len;
679 int32_t error;
680 uint64_t unique;
681};
682
683struct fuse_dirent {
684 uint64_t ino;
685 uint64_t off;
686 uint32_t namelen;
687 uint32_t type;
688 char name[];
689};
690
691#define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name)
692#define FUSE_DIRENT_ALIGN(x) \
693 (((x) + sizeof(uint64_t) - 1) & ~(sizeof(uint64_t) - 1))
694#define FUSE_DIRENT_SIZE(d) \
695 FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)
696
697struct fuse_direntplus {
698 struct fuse_entry_out entry_out;
699 struct fuse_dirent dirent;
700};
701
702#define FUSE_NAME_OFFSET_DIRENTPLUS \
703 offsetof(struct fuse_direntplus, dirent.name)
704#define FUSE_DIRENTPLUS_SIZE(d) \
705 FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET_DIRENTPLUS + (d)->dirent.namelen)
706
707struct fuse_notify_inval_inode_out {
708 uint64_t ino;
709 int64_t off;
710 int64_t len;
711};
712
713struct fuse_notify_inval_entry_out {
714 uint64_t parent;
715 uint32_t namelen;
716 uint32_t padding;
717};
718
719struct fuse_notify_delete_out {
720 uint64_t parent;
721 uint64_t child;
722 uint32_t namelen;
723 uint32_t padding;
724};
725
726struct fuse_notify_store_out {
727 uint64_t nodeid;
728 uint64_t offset;
729 uint32_t size;
730 uint32_t padding;
731};
732
733struct fuse_notify_retrieve_out {
734 uint64_t notify_unique;
735 uint64_t nodeid;
736 uint64_t offset;
737 uint32_t size;
738 uint32_t padding;
739};
740
741
742struct fuse_notify_retrieve_in {
743 uint64_t dummy1;
744 uint64_t offset;
745 uint32_t size;
746 uint32_t dummy2;
747 uint64_t dummy3;
748 uint64_t dummy4;
749};
750
751struct fuse_lseek_in {
752 uint64_t fh;
753 uint64_t offset;
754 uint32_t whence;
755 uint32_t padding;
756};
757
758struct fuse_lseek_out {
759 uint64_t offset;
760};
761
762#endif
763