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