xref: /spdk/include/linux/fuse_kernel.h (revision 8afdeef3becfe9409cc9e7372bd0bc10e8b7d46d)
1 /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) */
2 /*
3     This file defines the kernel interface of FUSE
4     Copyright (C) 2001-2008  Miklos Szeredi <miklos@szeredi.hu>
5 
6     This program can be distributed under the terms of the GNU GPL.
7     See the file COPYING.
8 
9     This -- and only this -- header file may also be distributed under
10     the terms of the BSD Licence as follows:
11 
12     Copyright (C) 2001-2007 Miklos Szeredi. All rights reserved.
13 
14     Redistribution and use in source and binary forms, with or without
15     modification, are permitted provided that the following conditions
16     are met:
17     1. Redistributions of source code must retain the above copyright
18        notice, this list of conditions and the following disclaimer.
19     2. Redistributions in binary form must reproduce the above copyright
20        notice, this list of conditions and the following disclaimer in the
21        documentation and/or other materials provided with the distribution.
22 
23     THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
24     ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25     IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26     ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
27     FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28     DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29     OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30     HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32     OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33     SUCH DAMAGE.
34 */
35 
36 /*
37  * This file defines the kernel interface of FUSE
38  *
39  * Protocol changelog:
40  *
41  * 7.9:
42  *  - new fuse_getattr_in input argument of GETATTR
43  *  - add lk_flags in fuse_lk_in
44  *  - add lock_owner field to fuse_setattr_in, fuse_read_in and fuse_write_in
45  *  - add blksize field to fuse_attr
46  *  - add file flags field to fuse_read_in and fuse_write_in
47  *
48  * 7.10
49  *  - add nonseekable open flag
50  *
51  * 7.11
52  *  - add IOCTL message
53  *  - add unsolicited notification support
54  *  - add POLL message and NOTIFY_POLL notification
55  *
56  * 7.12
57  *  - add umask flag to input argument of open, mknod and mkdir
58  *  - add notification messages for invalidation of inodes and
59  *    directory entries
60  *
61  * 7.13
62  *  - make max number of background requests and congestion threshold
63  *    tunables
64  *
65  * 7.14
66  *  - add splice support to fuse device
67  *
68  * 7.15
69  *  - add store notify
70  *  - add retrieve notify
71  *
72  * 7.16
73  *  - add BATCH_FORGET request
74  *  - FUSE_IOCTL_UNRESTRICTED shall now return with array of 'struct
75  *    fuse_ioctl_iovec' instead of ambiguous 'struct iovec'
76  *  - add FUSE_IOCTL_32BIT flag
77  *
78  * 7.17
79  *  - add FUSE_FLOCK_LOCKS and FUSE_RELEASE_FLOCK_UNLOCK
80  *
81  * 7.18
82  *  - add FUSE_IOCTL_DIR flag
83  *  - add FUSE_NOTIFY_DELETE
84  *
85  * 7.19
86  *  - add FUSE_FALLOCATE
87  *
88  * 7.20
89  *  - add FUSE_AUTO_INVAL_DATA
90  *
91  * 7.21
92  *  - add FUSE_READDIRPLUS
93  *  - send the requested events in POLL request
94  *
95  * 7.22
96  *  - add FUSE_ASYNC_DIO
97  *
98  * 7.23
99  *  - add FUSE_WRITEBACK_CACHE
100  *  - add time_gran to fuse_init_out
101  *  - add reserved space to fuse_init_out
102  *  - add FATTR_CTIME
103  *  - add ctime and ctimensec to fuse_setattr_in
104  *  - add FUSE_RENAME2 request
105  *  - add FUSE_NO_OPEN_SUPPORT flag
106  *
107  *  7.24
108  *  - add FUSE_LSEEK for SEEK_HOLE and SEEK_DATA support
109  *
110  *  7.25
111  *  - add FUSE_PARALLEL_DIROPS
112  *
113  *  7.26
114  *  - add FUSE_HANDLE_KILLPRIV
115  *  - add FUSE_POSIX_ACL
116  *
117  *  7.27
118  *  - add FUSE_ABORT_ERROR
119  *
120  *  7.28
121  *  - add FUSE_COPY_FILE_RANGE
122  */
123 
124 #ifndef _LINUX_FUSE_H
125 #define _LINUX_FUSE_H
126 
127 #ifdef __KERNEL__
128 #include <linux/types.h>
129 #else
130 #include <stdint.h>
131 #endif
132 
133 /*
134  * Version negotiation:
135  *
136  * Both the kernel and userspace send the version they support in the
137  * INIT request and reply respectively.
138  *
139  * If the major versions match then both shall use the smallest
140  * of the two minor versions for communication.
141  *
142  * If the kernel supports a larger major version, then userspace shall
143  * reply with the major version it supports, ignore the rest of the
144  * INIT message and expect a new INIT message from the kernel with a
145  * matching major version.
146  *
147  * If the library supports a larger major version, then it shall fall
148  * back to the major protocol version sent by the kernel for
149  * communication and reply with that major version (and an arbitrary
150  * supported minor version).
151  */
152 
153 /** Version number of this interface */
154 #define FUSE_KERNEL_VERSION 7
155 
156 /** Minor version number of this interface */
157 #define FUSE_KERNEL_MINOR_VERSION 27
158 
159 /** The node ID of the root inode */
160 #define FUSE_ROOT_ID 1
161 
162 /* Make sure all structures are padded to 64bit boundary, so 32bit
163    userspace works under 64bit kernels */
164 
165 struct fuse_attr {
166 	uint64_t	ino;
167 	uint64_t	size;
168 	uint64_t	blocks;
169 	uint64_t	atime;
170 	uint64_t	mtime;
171 	uint64_t	ctime;
172 	uint32_t	atimensec;
173 	uint32_t	mtimensec;
174 	uint32_t	ctimensec;
175 	uint32_t	mode;
176 	uint32_t	nlink;
177 	uint32_t	uid;
178 	uint32_t	gid;
179 	uint32_t	rdev;
180 	uint32_t	blksize;
181 	uint32_t	padding;
182 };
183 
184 struct fuse_kstatfs {
185 	uint64_t	blocks;
186 	uint64_t	bfree;
187 	uint64_t	bavail;
188 	uint64_t	files;
189 	uint64_t	ffree;
190 	uint32_t	bsize;
191 	uint32_t	namelen;
192 	uint32_t	frsize;
193 	uint32_t	padding;
194 	uint32_t	spare[6];
195 };
196 
197 struct fuse_file_lock {
198 	uint64_t	start;
199 	uint64_t	end;
200 	uint32_t	type;
201 	uint32_t	pid; /* tgid */
202 };
203 
204 /**
205  * Bitmasks for fuse_setattr_in.valid
206  */
207 #define FATTR_MODE	(1 << 0)
208 #define FATTR_UID	(1 << 1)
209 #define FATTR_GID	(1 << 2)
210 #define FATTR_SIZE	(1 << 3)
211 #define FATTR_ATIME	(1 << 4)
212 #define FATTR_MTIME	(1 << 5)
213 #define FATTR_FH	(1 << 6)
214 #define FATTR_ATIME_NOW	(1 << 7)
215 #define FATTR_MTIME_NOW	(1 << 8)
216 #define FATTR_LOCKOWNER	(1 << 9)
217 #define FATTR_CTIME	(1 << 10)
218 
219 /**
220  * Flags returned by the OPEN request
221  *
222  * FOPEN_DIRECT_IO: bypass page cache for this open file
223  * FOPEN_KEEP_CACHE: don't invalidate the data cache on open
224  * FOPEN_NONSEEKABLE: the file is not seekable
225  */
226 #define FOPEN_DIRECT_IO		(1 << 0)
227 #define FOPEN_KEEP_CACHE	(1 << 1)
228 #define FOPEN_NONSEEKABLE	(1 << 2)
229 
230 /**
231  * INIT request/reply flags
232  *
233  * FUSE_ASYNC_READ: asynchronous read requests
234  * FUSE_POSIX_LOCKS: remote locking for POSIX file locks
235  * FUSE_FILE_OPS: kernel sends file handle for fstat, etc... (not yet supported)
236  * FUSE_ATOMIC_O_TRUNC: handles the O_TRUNC open flag in the filesystem
237  * FUSE_EXPORT_SUPPORT: filesystem handles lookups of "." and ".."
238  * FUSE_BIG_WRITES: filesystem can handle write size larger than 4kB
239  * FUSE_DONT_MASK: don't apply umask to file mode on create operations
240  * FUSE_SPLICE_WRITE: kernel supports splice write on the device
241  * FUSE_SPLICE_MOVE: kernel supports splice move on the device
242  * FUSE_SPLICE_READ: kernel supports splice read on the device
243  * FUSE_FLOCK_LOCKS: remote locking for BSD style file locks
244  * FUSE_HAS_IOCTL_DIR: kernel supports ioctl on directories
245  * FUSE_AUTO_INVAL_DATA: automatically invalidate cached pages
246  * FUSE_DO_READDIRPLUS: do READDIRPLUS (READDIR+LOOKUP in one)
247  * FUSE_READDIRPLUS_AUTO: adaptive readdirplus
248  * FUSE_ASYNC_DIO: asynchronous direct I/O submission
249  * FUSE_WRITEBACK_CACHE: use writeback cache for buffered writes
250  * FUSE_NO_OPEN_SUPPORT: kernel supports zero-message opens
251  * FUSE_PARALLEL_DIROPS: allow parallel lookups and readdir
252  * FUSE_HANDLE_KILLPRIV: fs handles killing suid/sgid/cap on write/chown/trunc
253  * FUSE_POSIX_ACL: filesystem supports posix acls
254  * FUSE_ABORT_ERROR: reading the device after abort returns ECONNABORTED
255  */
256 #define FUSE_ASYNC_READ		(1 << 0)
257 #define FUSE_POSIX_LOCKS	(1 << 1)
258 #define FUSE_FILE_OPS		(1 << 2)
259 #define FUSE_ATOMIC_O_TRUNC	(1 << 3)
260 #define FUSE_EXPORT_SUPPORT	(1 << 4)
261 #define FUSE_BIG_WRITES		(1 << 5)
262 #define FUSE_DONT_MASK		(1 << 6)
263 #define FUSE_SPLICE_WRITE	(1 << 7)
264 #define FUSE_SPLICE_MOVE	(1 << 8)
265 #define FUSE_SPLICE_READ	(1 << 9)
266 #define FUSE_FLOCK_LOCKS	(1 << 10)
267 #define FUSE_HAS_IOCTL_DIR	(1 << 11)
268 #define FUSE_AUTO_INVAL_DATA	(1 << 12)
269 #define FUSE_DO_READDIRPLUS	(1 << 13)
270 #define FUSE_READDIRPLUS_AUTO	(1 << 14)
271 #define FUSE_ASYNC_DIO		(1 << 15)
272 #define FUSE_WRITEBACK_CACHE	(1 << 16)
273 #define FUSE_NO_OPEN_SUPPORT	(1 << 17)
274 #define FUSE_PARALLEL_DIROPS    (1 << 18)
275 #define FUSE_HANDLE_KILLPRIV	(1 << 19)
276 #define FUSE_POSIX_ACL		(1 << 20)
277 #define FUSE_ABORT_ERROR	(1 << 21)
278 
279 /**
280  * CUSE INIT request/reply flags
281  *
282  * CUSE_UNRESTRICTED_IOCTL:  use unrestricted ioctl
283  */
284 #define CUSE_UNRESTRICTED_IOCTL	(1 << 0)
285 
286 /**
287  * Release flags
288  */
289 #define FUSE_RELEASE_FLUSH	(1 << 0)
290 #define FUSE_RELEASE_FLOCK_UNLOCK	(1 << 1)
291 
292 /**
293  * Getattr flags
294  */
295 #define FUSE_GETATTR_FH		(1 << 0)
296 
297 /**
298  * Lock flags
299  */
300 #define FUSE_LK_FLOCK		(1 << 0)
301 
302 /**
303  * WRITE flags
304  *
305  * FUSE_WRITE_CACHE: delayed write from page cache, file handle is guessed
306  * FUSE_WRITE_LOCKOWNER: lock_owner field is valid
307  */
308 #define FUSE_WRITE_CACHE	(1 << 0)
309 #define FUSE_WRITE_LOCKOWNER	(1 << 1)
310 
311 /**
312  * Read flags
313  */
314 #define FUSE_READ_LOCKOWNER	(1 << 1)
315 
316 /**
317  * Ioctl flags
318  *
319  * FUSE_IOCTL_COMPAT: 32bit compat ioctl on 64bit machine
320  * FUSE_IOCTL_UNRESTRICTED: not restricted to well-formed ioctls, retry allowed
321  * FUSE_IOCTL_RETRY: retry with new iovecs
322  * FUSE_IOCTL_32BIT: 32bit ioctl
323  * FUSE_IOCTL_DIR: is a directory
324  *
325  * FUSE_IOCTL_MAX_IOV: maximum of in_iovecs + out_iovecs
326  */
327 #define FUSE_IOCTL_COMPAT	(1 << 0)
328 #define FUSE_IOCTL_UNRESTRICTED	(1 << 1)
329 #define FUSE_IOCTL_RETRY	(1 << 2)
330 #define FUSE_IOCTL_32BIT	(1 << 3)
331 #define FUSE_IOCTL_DIR		(1 << 4)
332 
333 #define FUSE_IOCTL_MAX_IOV	256
334 
335 /**
336  * Poll flags
337  *
338  * FUSE_POLL_SCHEDULE_NOTIFY: request poll notify
339  */
340 #define FUSE_POLL_SCHEDULE_NOTIFY (1 << 0)
341 
342 enum fuse_opcode {
343 	FUSE_LOOKUP		= 1,
344 	FUSE_FORGET		= 2,  /* no reply */
345 	FUSE_GETATTR		= 3,
346 	FUSE_SETATTR		= 4,
347 	FUSE_READLINK		= 5,
348 	FUSE_SYMLINK		= 6,
349 	FUSE_MKNOD		= 8,
350 	FUSE_MKDIR		= 9,
351 	FUSE_UNLINK		= 10,
352 	FUSE_RMDIR		= 11,
353 	FUSE_RENAME		= 12,
354 	FUSE_LINK		= 13,
355 	FUSE_OPEN		= 14,
356 	FUSE_READ		= 15,
357 	FUSE_WRITE		= 16,
358 	FUSE_STATFS		= 17,
359 	FUSE_RELEASE		= 18,
360 	FUSE_FSYNC		= 20,
361 	FUSE_SETXATTR		= 21,
362 	FUSE_GETXATTR		= 22,
363 	FUSE_LISTXATTR		= 23,
364 	FUSE_REMOVEXATTR	= 24,
365 	FUSE_FLUSH		= 25,
366 	FUSE_INIT		= 26,
367 	FUSE_OPENDIR		= 27,
368 	FUSE_READDIR		= 28,
369 	FUSE_RELEASEDIR		= 29,
370 	FUSE_FSYNCDIR		= 30,
371 	FUSE_GETLK		= 31,
372 	FUSE_SETLK		= 32,
373 	FUSE_SETLKW		= 33,
374 	FUSE_ACCESS		= 34,
375 	FUSE_CREATE		= 35,
376 	FUSE_INTERRUPT		= 36,
377 	FUSE_BMAP		= 37,
378 	FUSE_DESTROY		= 38,
379 	FUSE_IOCTL		= 39,
380 	FUSE_POLL		= 40,
381 	FUSE_NOTIFY_REPLY	= 41,
382 	FUSE_BATCH_FORGET	= 42,
383 	FUSE_FALLOCATE		= 43,
384 	FUSE_READDIRPLUS	= 44,
385 	FUSE_RENAME2		= 45,
386 	FUSE_LSEEK		= 46,
387 	FUSE_COPY_FILE_RANGE	= 47,
388 	FUSE_SETUPMAPPING       = 48,
389 	FUSE_REMOVEMAPPING      = 49,
390 	FUSE_SYNCFS             = 50,
391 
392 	/* CUSE specific operations */
393 	CUSE_INIT		= 4096,
394 };
395 
396 enum fuse_notify_code {
397 	FUSE_NOTIFY_POLL   = 1,
398 	FUSE_NOTIFY_INVAL_INODE = 2,
399 	FUSE_NOTIFY_INVAL_ENTRY = 3,
400 	FUSE_NOTIFY_STORE = 4,
401 	FUSE_NOTIFY_RETRIEVE = 5,
402 	FUSE_NOTIFY_DELETE = 6,
403 	FUSE_NOTIFY_CODE_MAX,
404 };
405 
406 /* The read buffer is required to be at least 8k, but may be much larger */
407 #define FUSE_MIN_READ_BUFFER 8192
408 
409 #define FUSE_COMPAT_ENTRY_OUT_SIZE 120
410 
411 struct fuse_entry_out {
412 	uint64_t	nodeid;		/* Inode ID */
413 	uint64_t	generation;	/* Inode generation: nodeid:gen must
414 					   be unique for the fs's lifetime */
415 	uint64_t	entry_valid;	/* Cache timeout for the name */
416 	uint64_t	attr_valid;	/* Cache timeout for the attributes */
417 	uint32_t	entry_valid_nsec;
418 	uint32_t	attr_valid_nsec;
419 	struct fuse_attr attr;
420 };
421 
422 struct fuse_forget_in {
423 	uint64_t	nlookup;
424 };
425 
426 struct fuse_forget_one {
427 	uint64_t	nodeid;
428 	uint64_t	nlookup;
429 };
430 
431 struct fuse_batch_forget_in {
432 	uint32_t	count;
433 	uint32_t	dummy;
434 };
435 
436 struct fuse_getattr_in {
437 	uint32_t	getattr_flags;
438 	uint32_t	dummy;
439 	uint64_t	fh;
440 };
441 
442 #define FUSE_COMPAT_ATTR_OUT_SIZE 96
443 
444 struct fuse_attr_out {
445 	uint64_t	attr_valid;	/* Cache timeout for the attributes */
446 	uint32_t	attr_valid_nsec;
447 	uint32_t	dummy;
448 	struct fuse_attr attr;
449 };
450 
451 #define FUSE_COMPAT_MKNOD_IN_SIZE 8
452 
453 struct fuse_mknod_in {
454 	uint32_t	mode;
455 	uint32_t	rdev;
456 	uint32_t	umask;
457 	uint32_t	padding;
458 };
459 
460 struct fuse_mkdir_in {
461 	uint32_t	mode;
462 	uint32_t	umask;
463 };
464 
465 struct fuse_rename_in {
466 	uint64_t	newdir;
467 };
468 
469 struct fuse_rename2_in {
470 	uint64_t	newdir;
471 	uint32_t	flags;
472 	uint32_t	padding;
473 };
474 
475 struct fuse_link_in {
476 	uint64_t	oldnodeid;
477 };
478 
479 struct fuse_setattr_in {
480 	uint32_t	valid;
481 	uint32_t	padding;
482 	uint64_t	fh;
483 	uint64_t	size;
484 	uint64_t	lock_owner;
485 	uint64_t	atime;
486 	uint64_t	mtime;
487 	uint64_t	ctime;
488 	uint32_t	atimensec;
489 	uint32_t	mtimensec;
490 	uint32_t	ctimensec;
491 	uint32_t	mode;
492 	uint32_t	unused4;
493 	uint32_t	uid;
494 	uint32_t	gid;
495 	uint32_t	unused5;
496 };
497 
498 struct fuse_open_in {
499 	uint32_t	flags;
500 	uint32_t	unused;
501 };
502 
503 struct fuse_create_in {
504 	uint32_t	flags;
505 	uint32_t	mode;
506 	uint32_t	umask;
507 	uint32_t	padding;
508 };
509 
510 struct fuse_open_out {
511 	uint64_t	fh;
512 	uint32_t	open_flags;
513 	uint32_t	padding;
514 };
515 
516 struct fuse_release_in {
517 	uint64_t	fh;
518 	uint32_t	flags;
519 	uint32_t	release_flags;
520 	uint64_t	lock_owner;
521 };
522 
523 struct fuse_flush_in {
524 	uint64_t	fh;
525 	uint32_t	unused;
526 	uint32_t	padding;
527 	uint64_t	lock_owner;
528 };
529 
530 struct fuse_read_in {
531 	uint64_t	fh;
532 	uint64_t	offset;
533 	uint32_t	size;
534 	uint32_t	read_flags;
535 	uint64_t	lock_owner;
536 	uint32_t	flags;
537 	uint32_t	padding;
538 };
539 
540 #define FUSE_COMPAT_WRITE_IN_SIZE 24
541 
542 struct fuse_write_in {
543 	uint64_t	fh;
544 	uint64_t	offset;
545 	uint32_t	size;
546 	uint32_t	write_flags;
547 	uint64_t	lock_owner;
548 	uint32_t	flags;
549 	uint32_t	padding;
550 };
551 
552 struct fuse_write_out {
553 	uint32_t	size;
554 	uint32_t	padding;
555 };
556 
557 #define FUSE_COMPAT_STATFS_SIZE 48
558 
559 struct fuse_statfs_out {
560 	struct fuse_kstatfs st;
561 };
562 
563 struct fuse_fsync_in {
564 	uint64_t	fh;
565 	uint32_t	fsync_flags;
566 	uint32_t	padding;
567 };
568 
569 struct fuse_setxattr_in {
570 	uint32_t	size;
571 	uint32_t	flags;
572 };
573 
574 struct fuse_getxattr_in {
575 	uint32_t	size;
576 	uint32_t	padding;
577 };
578 
579 struct fuse_getxattr_out {
580 	uint32_t	size;
581 	uint32_t	padding;
582 };
583 
584 struct fuse_lk_in {
585 	uint64_t	fh;
586 	uint64_t	owner;
587 	struct fuse_file_lock lk;
588 	uint32_t	lk_flags;
589 	uint32_t	padding;
590 };
591 
592 struct fuse_lk_out {
593 	struct fuse_file_lock lk;
594 };
595 
596 struct fuse_access_in {
597 	uint32_t	mask;
598 	uint32_t	padding;
599 };
600 
601 struct fuse_init_in {
602 	uint32_t	major;
603 	uint32_t	minor;
604 	uint32_t	max_readahead;
605 	uint32_t	flags;
606 };
607 
608 #define FUSE_COMPAT_INIT_OUT_SIZE 8
609 #define FUSE_COMPAT_22_INIT_OUT_SIZE 24
610 
611 struct fuse_init_out {
612 	uint32_t	major;
613 	uint32_t	minor;
614 	uint32_t	max_readahead;
615 	uint32_t	flags;
616 	uint16_t	max_background;
617 	uint16_t	congestion_threshold;
618 	uint32_t	max_write;
619 	uint32_t	time_gran;
620 	uint32_t	unused[9];
621 };
622 
623 #define CUSE_INIT_INFO_MAX 4096
624 
625 struct cuse_init_in {
626 	uint32_t	major;
627 	uint32_t	minor;
628 	uint32_t	unused;
629 	uint32_t	flags;
630 };
631 
632 struct cuse_init_out {
633 	uint32_t	major;
634 	uint32_t	minor;
635 	uint32_t	unused;
636 	uint32_t	flags;
637 	uint32_t	max_read;
638 	uint32_t	max_write;
639 	uint32_t	dev_major;		/* chardev major */
640 	uint32_t	dev_minor;		/* chardev minor */
641 	uint32_t	spare[10];
642 };
643 
644 struct fuse_interrupt_in {
645 	uint64_t	unique;
646 };
647 
648 struct fuse_bmap_in {
649 	uint64_t	block;
650 	uint32_t	blocksize;
651 	uint32_t	padding;
652 };
653 
654 struct fuse_bmap_out {
655 	uint64_t	block;
656 };
657 
658 struct fuse_ioctl_in {
659 	uint64_t	fh;
660 	uint32_t	flags;
661 	uint32_t	cmd;
662 	uint64_t	arg;
663 	uint32_t	in_size;
664 	uint32_t	out_size;
665 };
666 
667 struct fuse_ioctl_iovec {
668 	uint64_t	base;
669 	uint64_t	len;
670 };
671 
672 struct fuse_ioctl_out {
673 	int32_t		result;
674 	uint32_t	flags;
675 	uint32_t	in_iovs;
676 	uint32_t	out_iovs;
677 };
678 
679 struct fuse_poll_in {
680 	uint64_t	fh;
681 	uint64_t	kh;
682 	uint32_t	flags;
683 	uint32_t	events;
684 };
685 
686 struct fuse_poll_out {
687 	uint32_t	revents;
688 	uint32_t	padding;
689 };
690 
691 struct fuse_notify_poll_wakeup_out {
692 	uint64_t	kh;
693 };
694 
695 struct fuse_fallocate_in {
696 	uint64_t	fh;
697 	uint64_t	offset;
698 	uint64_t	length;
699 	uint32_t	mode;
700 	uint32_t	padding;
701 };
702 
703 struct fuse_in_header {
704 	uint32_t	len;
705 	uint32_t	opcode;
706 	uint64_t	unique;
707 	uint64_t	nodeid;
708 	uint32_t	uid;
709 	uint32_t	gid;
710 	uint32_t	pid;
711 	uint32_t	padding;
712 };
713 
714 struct fuse_out_header {
715 	uint32_t	len;
716 	int32_t		error;
717 	uint64_t	unique;
718 };
719 
720 struct fuse_dirent {
721 	uint64_t	ino;
722 	uint64_t	off;
723 	uint32_t	namelen;
724 	uint32_t	type;
725 	char name[];
726 };
727 
728 #define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name)
729 #define FUSE_DIRENT_ALIGN(x) \
730 	(((x) + sizeof(uint64_t) - 1) & ~(sizeof(uint64_t) - 1))
731 #define FUSE_DIRENT_SIZE(d) \
732 	FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)
733 
734 struct fuse_direntplus {
735 	struct fuse_entry_out entry_out;
736 	struct fuse_dirent dirent;
737 };
738 
739 #define FUSE_NAME_OFFSET_DIRENTPLUS \
740 	offsetof(struct fuse_direntplus, dirent.name)
741 #define FUSE_DIRENTPLUS_SIZE(d) \
742 	FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET_DIRENTPLUS + (d)->dirent.namelen)
743 
744 struct fuse_notify_inval_inode_out {
745 	uint64_t	ino;
746 	int64_t		off;
747 	int64_t		len;
748 };
749 
750 struct fuse_notify_inval_entry_out {
751 	uint64_t	parent;
752 	uint32_t	namelen;
753 	uint32_t	padding;
754 };
755 
756 struct fuse_notify_delete_out {
757 	uint64_t	parent;
758 	uint64_t	child;
759 	uint32_t	namelen;
760 	uint32_t	padding;
761 };
762 
763 struct fuse_notify_store_out {
764 	uint64_t	nodeid;
765 	uint64_t	offset;
766 	uint32_t	size;
767 	uint32_t	padding;
768 };
769 
770 struct fuse_notify_retrieve_out {
771 	uint64_t	notify_unique;
772 	uint64_t	nodeid;
773 	uint64_t	offset;
774 	uint32_t	size;
775 	uint32_t	padding;
776 };
777 
778 /* Matches the size of fuse_write_in */
779 struct fuse_notify_retrieve_in {
780 	uint64_t	dummy1;
781 	uint64_t	offset;
782 	uint32_t	size;
783 	uint32_t	dummy2;
784 	uint64_t	dummy3;
785 	uint64_t	dummy4;
786 };
787 
788 /* Device ioctls: */
789 #define FUSE_DEV_IOC_CLONE	_IOR(229, 0, uint32_t)
790 
791 struct fuse_lseek_in {
792 	uint64_t	fh;
793 	uint64_t	offset;
794 	uint32_t	whence;
795 	uint32_t	padding;
796 };
797 
798 struct fuse_lseek_out {
799 	uint64_t	offset;
800 };
801 
802 struct fuse_copy_file_range_in {
803 	uint64_t	fh_in;
804 	uint64_t	off_in;
805 	uint64_t	nodeid_out;
806 	uint64_t	fh_out;
807 	uint64_t	off_out;
808 	uint64_t	len;
809 	uint64_t	flags;
810 };
811 
812 #define FUSE_SETUPMAPPING_ENTRIES 8
813 #define FUSE_SETUPMAPPING_FLAG_WRITE (1ull << 0)
814 struct fuse_setupmapping_in {
815         /* An already open handle */
816 	uint64_t	fh;
817         /* Offset into the file to start the mapping */
818         uint64_t        foffset;
819         /* Length of mapping required */
820         uint64_t        len;
821         /* Flags, FUSE_SETUPMAPPING_FLAG_* */
822         uint64_t        flags;
823         /* memory offset in to dax window */
824         uint64_t        moffset;
825 };
826 
827 struct fuse_setupmapping_out {
828         /* Offsets into the cache of mappings */
829         uint64_t        coffset[FUSE_SETUPMAPPING_ENTRIES];
830         /* Lengths of each mapping */
831         uint64_t        len[FUSE_SETUPMAPPING_ENTRIES];
832 };
833 
834 struct fuse_removemapping_in {
835         /* An already open handle */
836 	uint64_t	fh;
837         /* Offset into the dax to start the unmapping */
838         uint64_t        moffset;
839         /* Length of mapping required */
840         uint64_t        len;
841 };
842 
843 #endif /* _LINUX_FUSE_H */
844