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