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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186#ifndef _LINUX_FUSE_H
187#define _LINUX_FUSE_H
188
189#include <stdint.h>
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212#define FUSE_KERNEL_VERSION 7
213
214
215#define FUSE_KERNEL_MINOR_VERSION 33
216
217
218#define FUSE_ROOT_ID 1
219
220
221
222
223struct fuse_attr {
224 uint64_t ino;
225 uint64_t size;
226 uint64_t blocks;
227 uint64_t atime;
228 uint64_t mtime;
229 uint64_t ctime;
230 uint32_t atimensec;
231 uint32_t mtimensec;
232 uint32_t ctimensec;
233 uint32_t mode;
234 uint32_t nlink;
235 uint32_t uid;
236 uint32_t gid;
237 uint32_t rdev;
238 uint32_t blksize;
239 uint32_t flags;
240};
241
242struct fuse_kstatfs {
243 uint64_t blocks;
244 uint64_t bfree;
245 uint64_t bavail;
246 uint64_t files;
247 uint64_t ffree;
248 uint32_t bsize;
249 uint32_t namelen;
250 uint32_t frsize;
251 uint32_t padding;
252 uint32_t spare[6];
253};
254
255struct fuse_file_lock {
256 uint64_t start;
257 uint64_t end;
258 uint32_t type;
259 uint32_t pid;
260};
261
262
263
264
265#define FATTR_MODE (1 << 0)
266#define FATTR_UID (1 << 1)
267#define FATTR_GID (1 << 2)
268#define FATTR_SIZE (1 << 3)
269#define FATTR_ATIME (1 << 4)
270#define FATTR_MTIME (1 << 5)
271#define FATTR_FH (1 << 6)
272#define FATTR_ATIME_NOW (1 << 7)
273#define FATTR_MTIME_NOW (1 << 8)
274#define FATTR_LOCKOWNER (1 << 9)
275#define FATTR_CTIME (1 << 10)
276#define FATTR_KILL_SUIDGID (1 << 11)
277
278
279
280
281
282
283
284
285
286
287#define FOPEN_DIRECT_IO (1 << 0)
288#define FOPEN_KEEP_CACHE (1 << 1)
289#define FOPEN_NONSEEKABLE (1 << 2)
290#define FOPEN_CACHE_DIR (1 << 3)
291#define FOPEN_STREAM (1 << 4)
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333#define FUSE_ASYNC_READ (1 << 0)
334#define FUSE_POSIX_LOCKS (1 << 1)
335#define FUSE_FILE_OPS (1 << 2)
336#define FUSE_ATOMIC_O_TRUNC (1 << 3)
337#define FUSE_EXPORT_SUPPORT (1 << 4)
338#define FUSE_BIG_WRITES (1 << 5)
339#define FUSE_DONT_MASK (1 << 6)
340#define FUSE_SPLICE_WRITE (1 << 7)
341#define FUSE_SPLICE_MOVE (1 << 8)
342#define FUSE_SPLICE_READ (1 << 9)
343#define FUSE_FLOCK_LOCKS (1 << 10)
344#define FUSE_HAS_IOCTL_DIR (1 << 11)
345#define FUSE_AUTO_INVAL_DATA (1 << 12)
346#define FUSE_DO_READDIRPLUS (1 << 13)
347#define FUSE_READDIRPLUS_AUTO (1 << 14)
348#define FUSE_ASYNC_DIO (1 << 15)
349#define FUSE_WRITEBACK_CACHE (1 << 16)
350#define FUSE_NO_OPEN_SUPPORT (1 << 17)
351#define FUSE_PARALLEL_DIROPS (1 << 18)
352#define FUSE_HANDLE_KILLPRIV (1 << 19)
353#define FUSE_POSIX_ACL (1 << 20)
354#define FUSE_ABORT_ERROR (1 << 21)
355#define FUSE_MAX_PAGES (1 << 22)
356#define FUSE_CACHE_SYMLINKS (1 << 23)
357#define FUSE_NO_OPENDIR_SUPPORT (1 << 24)
358#define FUSE_EXPLICIT_INVAL_DATA (1 << 25)
359#define FUSE_MAP_ALIGNMENT (1 << 26)
360#define FUSE_SUBMOUNTS (1 << 27)
361#define FUSE_HANDLE_KILLPRIV_V2 (1 << 28)
362#define FUSE_SETXATTR_EXT (1 << 29)
363
364
365
366
367
368
369#define CUSE_UNRESTRICTED_IOCTL (1 << 0)
370
371
372
373
374#define FUSE_RELEASE_FLUSH (1 << 0)
375#define FUSE_RELEASE_FLOCK_UNLOCK (1 << 1)
376
377
378
379
380#define FUSE_GETATTR_FH (1 << 0)
381
382
383
384
385#define FUSE_LK_FLOCK (1 << 0)
386
387
388
389
390
391
392
393
394#define FUSE_WRITE_CACHE (1 << 0)
395#define FUSE_WRITE_LOCKOWNER (1 << 1)
396#define FUSE_WRITE_KILL_SUIDGID (1 << 2)
397
398
399#define FUSE_WRITE_KILL_PRIV FUSE_WRITE_KILL_SUIDGID
400
401
402
403
404#define FUSE_READ_LOCKOWNER (1 << 1)
405
406
407
408
409
410
411
412
413
414
415
416
417
418#define FUSE_IOCTL_COMPAT (1 << 0)
419#define FUSE_IOCTL_UNRESTRICTED (1 << 1)
420#define FUSE_IOCTL_RETRY (1 << 2)
421#define FUSE_IOCTL_32BIT (1 << 3)
422#define FUSE_IOCTL_DIR (1 << 4)
423#define FUSE_IOCTL_COMPAT_X32 (1 << 5)
424
425#define FUSE_IOCTL_MAX_IOV 256
426
427
428
429
430
431
432#define FUSE_POLL_SCHEDULE_NOTIFY (1 << 0)
433
434
435
436
437
438
439#define FUSE_FSYNC_FDATASYNC (1 << 0)
440
441
442
443
444
445
446#define FUSE_ATTR_SUBMOUNT (1 << 0)
447
448
449
450
451
452#define FUSE_OPEN_KILL_SUIDGID (1 << 0)
453
454
455
456
457
458#define FUSE_SETXATTR_ACL_KILL_SGID (1 << 0)
459
460enum fuse_opcode {
461 FUSE_LOOKUP = 1,
462 FUSE_FORGET = 2,
463 FUSE_GETATTR = 3,
464 FUSE_SETATTR = 4,
465 FUSE_READLINK = 5,
466 FUSE_SYMLINK = 6,
467 FUSE_MKNOD = 8,
468 FUSE_MKDIR = 9,
469 FUSE_UNLINK = 10,
470 FUSE_RMDIR = 11,
471 FUSE_RENAME = 12,
472 FUSE_LINK = 13,
473 FUSE_OPEN = 14,
474 FUSE_READ = 15,
475 FUSE_WRITE = 16,
476 FUSE_STATFS = 17,
477 FUSE_RELEASE = 18,
478 FUSE_FSYNC = 20,
479 FUSE_SETXATTR = 21,
480 FUSE_GETXATTR = 22,
481 FUSE_LISTXATTR = 23,
482 FUSE_REMOVEXATTR = 24,
483 FUSE_FLUSH = 25,
484 FUSE_INIT = 26,
485 FUSE_OPENDIR = 27,
486 FUSE_READDIR = 28,
487 FUSE_RELEASEDIR = 29,
488 FUSE_FSYNCDIR = 30,
489 FUSE_GETLK = 31,
490 FUSE_SETLK = 32,
491 FUSE_SETLKW = 33,
492 FUSE_ACCESS = 34,
493 FUSE_CREATE = 35,
494 FUSE_INTERRUPT = 36,
495 FUSE_BMAP = 37,
496 FUSE_DESTROY = 38,
497 FUSE_IOCTL = 39,
498 FUSE_POLL = 40,
499 FUSE_NOTIFY_REPLY = 41,
500 FUSE_BATCH_FORGET = 42,
501 FUSE_FALLOCATE = 43,
502 FUSE_READDIRPLUS = 44,
503 FUSE_RENAME2 = 45,
504 FUSE_LSEEK = 46,
505 FUSE_COPY_FILE_RANGE = 47,
506 FUSE_SETUPMAPPING = 48,
507 FUSE_REMOVEMAPPING = 49,
508
509
510 CUSE_INIT = 4096,
511
512
513 CUSE_INIT_BSWAP_RESERVED = 1048576,
514 FUSE_INIT_BSWAP_RESERVED = 436207616,
515};
516
517enum fuse_notify_code {
518 FUSE_NOTIFY_POLL = 1,
519 FUSE_NOTIFY_INVAL_INODE = 2,
520 FUSE_NOTIFY_INVAL_ENTRY = 3,
521 FUSE_NOTIFY_STORE = 4,
522 FUSE_NOTIFY_RETRIEVE = 5,
523 FUSE_NOTIFY_DELETE = 6,
524 FUSE_NOTIFY_CODE_MAX,
525};
526
527
528#define FUSE_MIN_READ_BUFFER 8192
529
530#define FUSE_COMPAT_ENTRY_OUT_SIZE 120
531
532struct fuse_entry_out {
533 uint64_t nodeid;
534 uint64_t generation;
535
536 uint64_t entry_valid;
537 uint64_t attr_valid;
538 uint32_t entry_valid_nsec;
539 uint32_t attr_valid_nsec;
540 struct fuse_attr attr;
541};
542
543struct fuse_forget_in {
544 uint64_t nlookup;
545};
546
547struct fuse_forget_one {
548 uint64_t nodeid;
549 uint64_t nlookup;
550};
551
552struct fuse_batch_forget_in {
553 uint32_t count;
554 uint32_t dummy;
555};
556
557struct fuse_getattr_in {
558 uint32_t getattr_flags;
559 uint32_t dummy;
560 uint64_t fh;
561};
562
563#define FUSE_COMPAT_ATTR_OUT_SIZE 96
564
565struct fuse_attr_out {
566 uint64_t attr_valid;
567 uint32_t attr_valid_nsec;
568 uint32_t dummy;
569 struct fuse_attr attr;
570};
571
572#define FUSE_COMPAT_MKNOD_IN_SIZE 8
573
574struct fuse_mknod_in {
575 uint32_t mode;
576 uint32_t rdev;
577 uint32_t umask;
578 uint32_t padding;
579};
580
581struct fuse_mkdir_in {
582 uint32_t mode;
583 uint32_t umask;
584};
585
586struct fuse_rename_in {
587 uint64_t newdir;
588};
589
590struct fuse_rename2_in {
591 uint64_t newdir;
592 uint32_t flags;
593 uint32_t padding;
594};
595
596struct fuse_link_in {
597 uint64_t oldnodeid;
598};
599
600struct fuse_setattr_in {
601 uint32_t valid;
602 uint32_t padding;
603 uint64_t fh;
604 uint64_t size;
605 uint64_t lock_owner;
606 uint64_t atime;
607 uint64_t mtime;
608 uint64_t ctime;
609 uint32_t atimensec;
610 uint32_t mtimensec;
611 uint32_t ctimensec;
612 uint32_t mode;
613 uint32_t unused4;
614 uint32_t uid;
615 uint32_t gid;
616 uint32_t unused5;
617};
618
619struct fuse_open_in {
620 uint32_t flags;
621 uint32_t open_flags;
622};
623
624struct fuse_create_in {
625 uint32_t flags;
626 uint32_t mode;
627 uint32_t umask;
628 uint32_t open_flags;
629};
630
631struct fuse_open_out {
632 uint64_t fh;
633 uint32_t open_flags;
634 uint32_t padding;
635};
636
637struct fuse_release_in {
638 uint64_t fh;
639 uint32_t flags;
640 uint32_t release_flags;
641 uint64_t lock_owner;
642};
643
644struct fuse_flush_in {
645 uint64_t fh;
646 uint32_t unused;
647 uint32_t padding;
648 uint64_t lock_owner;
649};
650
651struct fuse_read_in {
652 uint64_t fh;
653 uint64_t offset;
654 uint32_t size;
655 uint32_t read_flags;
656 uint64_t lock_owner;
657 uint32_t flags;
658 uint32_t padding;
659};
660
661#define FUSE_COMPAT_WRITE_IN_SIZE 24
662
663struct fuse_write_in {
664 uint64_t fh;
665 uint64_t offset;
666 uint32_t size;
667 uint32_t write_flags;
668 uint64_t lock_owner;
669 uint32_t flags;
670 uint32_t padding;
671};
672
673struct fuse_write_out {
674 uint32_t size;
675 uint32_t padding;
676};
677
678#define FUSE_COMPAT_STATFS_SIZE 48
679
680struct fuse_statfs_out {
681 struct fuse_kstatfs st;
682};
683
684struct fuse_fsync_in {
685 uint64_t fh;
686 uint32_t fsync_flags;
687 uint32_t padding;
688};
689
690#define FUSE_COMPAT_SETXATTR_IN_SIZE 8
691
692struct fuse_setxattr_in {
693 uint32_t size;
694 uint32_t flags;
695 uint32_t setxattr_flags;
696 uint32_t padding;
697};
698
699struct fuse_getxattr_in {
700 uint32_t size;
701 uint32_t padding;
702};
703
704struct fuse_getxattr_out {
705 uint32_t size;
706 uint32_t padding;
707};
708
709struct fuse_lk_in {
710 uint64_t fh;
711 uint64_t owner;
712 struct fuse_file_lock lk;
713 uint32_t lk_flags;
714 uint32_t padding;
715};
716
717struct fuse_lk_out {
718 struct fuse_file_lock lk;
719};
720
721struct fuse_access_in {
722 uint32_t mask;
723 uint32_t padding;
724};
725
726struct fuse_init_in {
727 uint32_t major;
728 uint32_t minor;
729 uint32_t max_readahead;
730 uint32_t flags;
731};
732
733#define FUSE_COMPAT_INIT_OUT_SIZE 8
734#define FUSE_COMPAT_22_INIT_OUT_SIZE 24
735
736struct fuse_init_out {
737 uint32_t major;
738 uint32_t minor;
739 uint32_t max_readahead;
740 uint32_t flags;
741 uint16_t max_background;
742 uint16_t congestion_threshold;
743 uint32_t max_write;
744 uint32_t time_gran;
745 uint16_t max_pages;
746 uint16_t map_alignment;
747 uint32_t unused[8];
748};
749
750#define CUSE_INIT_INFO_MAX 4096
751
752struct cuse_init_in {
753 uint32_t major;
754 uint32_t minor;
755 uint32_t unused;
756 uint32_t flags;
757};
758
759struct cuse_init_out {
760 uint32_t major;
761 uint32_t minor;
762 uint32_t unused;
763 uint32_t flags;
764 uint32_t max_read;
765 uint32_t max_write;
766 uint32_t dev_major;
767 uint32_t dev_minor;
768 uint32_t spare[10];
769};
770
771struct fuse_interrupt_in {
772 uint64_t unique;
773};
774
775struct fuse_bmap_in {
776 uint64_t block;
777 uint32_t blocksize;
778 uint32_t padding;
779};
780
781struct fuse_bmap_out {
782 uint64_t block;
783};
784
785struct fuse_ioctl_in {
786 uint64_t fh;
787 uint32_t flags;
788 uint32_t cmd;
789 uint64_t arg;
790 uint32_t in_size;
791 uint32_t out_size;
792};
793
794struct fuse_ioctl_iovec {
795 uint64_t base;
796 uint64_t len;
797};
798
799struct fuse_ioctl_out {
800 int32_t result;
801 uint32_t flags;
802 uint32_t in_iovs;
803 uint32_t out_iovs;
804};
805
806struct fuse_poll_in {
807 uint64_t fh;
808 uint64_t kh;
809 uint32_t flags;
810 uint32_t events;
811};
812
813struct fuse_poll_out {
814 uint32_t revents;
815 uint32_t padding;
816};
817
818struct fuse_notify_poll_wakeup_out {
819 uint64_t kh;
820};
821
822struct fuse_fallocate_in {
823 uint64_t fh;
824 uint64_t offset;
825 uint64_t length;
826 uint32_t mode;
827 uint32_t padding;
828};
829
830struct fuse_in_header {
831 uint32_t len;
832 uint32_t opcode;
833 uint64_t unique;
834 uint64_t nodeid;
835 uint32_t uid;
836 uint32_t gid;
837 uint32_t pid;
838 uint32_t padding;
839};
840
841struct fuse_out_header {
842 uint32_t len;
843 int32_t error;
844 uint64_t unique;
845};
846
847struct fuse_dirent {
848 uint64_t ino;
849 uint64_t off;
850 uint32_t namelen;
851 uint32_t type;
852 char name[];
853};
854
855#define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name)
856#define FUSE_DIRENT_ALIGN(x) \
857 (((x) + sizeof(uint64_t) - 1) & ~(sizeof(uint64_t) - 1))
858#define FUSE_DIRENT_SIZE(d) \
859 FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)
860
861struct fuse_direntplus {
862 struct fuse_entry_out entry_out;
863 struct fuse_dirent dirent;
864};
865
866#define FUSE_NAME_OFFSET_DIRENTPLUS \
867 offsetof(struct fuse_direntplus, dirent.name)
868#define FUSE_DIRENTPLUS_SIZE(d) \
869 FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET_DIRENTPLUS + (d)->dirent.namelen)
870
871struct fuse_notify_inval_inode_out {
872 uint64_t ino;
873 int64_t off;
874 int64_t len;
875};
876
877struct fuse_notify_inval_entry_out {
878 uint64_t parent;
879 uint32_t namelen;
880 uint32_t padding;
881};
882
883struct fuse_notify_delete_out {
884 uint64_t parent;
885 uint64_t child;
886 uint32_t namelen;
887 uint32_t padding;
888};
889
890struct fuse_notify_store_out {
891 uint64_t nodeid;
892 uint64_t offset;
893 uint32_t size;
894 uint32_t padding;
895};
896
897struct fuse_notify_retrieve_out {
898 uint64_t notify_unique;
899 uint64_t nodeid;
900 uint64_t offset;
901 uint32_t size;
902 uint32_t padding;
903};
904
905
906struct fuse_notify_retrieve_in {
907 uint64_t dummy1;
908 uint64_t offset;
909 uint32_t size;
910 uint32_t dummy2;
911 uint64_t dummy3;
912 uint64_t dummy4;
913};
914
915
916#define FUSE_DEV_IOC_MAGIC 229
917#define FUSE_DEV_IOC_CLONE _IOR(FUSE_DEV_IOC_MAGIC, 0, uint32_t)
918
919struct fuse_lseek_in {
920 uint64_t fh;
921 uint64_t offset;
922 uint32_t whence;
923 uint32_t padding;
924};
925
926struct fuse_lseek_out {
927 uint64_t offset;
928};
929
930struct fuse_copy_file_range_in {
931 uint64_t fh_in;
932 uint64_t off_in;
933 uint64_t nodeid_out;
934 uint64_t fh_out;
935 uint64_t off_out;
936 uint64_t len;
937 uint64_t flags;
938};
939
940#define FUSE_SETUPMAPPING_FLAG_WRITE (1ull << 0)
941#define FUSE_SETUPMAPPING_FLAG_READ (1ull << 1)
942struct fuse_setupmapping_in {
943
944 uint64_t fh;
945
946 uint64_t foffset;
947
948 uint64_t len;
949
950 uint64_t flags;
951
952 uint64_t moffset;
953};
954
955struct fuse_removemapping_in {
956
957 uint32_t count;
958};
959
960struct fuse_removemapping_one {
961
962 uint64_t moffset;
963
964 uint64_t len;
965};
966
967#define FUSE_REMOVEMAPPING_MAX_ENTRY \
968 (PAGE_SIZE / sizeof(struct fuse_removemapping_one))
969
970#endif
971