xref: /freebsd/sys/fs/fuse/fuse_kernel.h (revision adf376485712c8fffbf3be330d505a969647f479)
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 /**
404  * Fallocate flags.
405  */
406 #define FUSE_FALLOC_FL_KEEP_SIZE	0x1
407 #define FUSE_FALLOC_FL_PUNCH_HOLE	0x2
408 
409 enum fuse_opcode {
410 	FUSE_LOOKUP		= 1,
411 	FUSE_FORGET		= 2,  /* no reply */
412 	FUSE_GETATTR		= 3,
413 	FUSE_SETATTR		= 4,
414 	FUSE_READLINK		= 5,
415 	FUSE_SYMLINK		= 6,
416 	FUSE_MKNOD		= 8,
417 	FUSE_MKDIR		= 9,
418 	FUSE_UNLINK		= 10,
419 	FUSE_RMDIR		= 11,
420 	FUSE_RENAME		= 12,
421 	FUSE_LINK		= 13,
422 	FUSE_OPEN		= 14,
423 	FUSE_READ		= 15,
424 	FUSE_WRITE		= 16,
425 	FUSE_STATFS		= 17,
426 	FUSE_RELEASE		= 18,
427 	FUSE_FSYNC		= 20,
428 	FUSE_SETXATTR		= 21,
429 	FUSE_GETXATTR		= 22,
430 	FUSE_LISTXATTR		= 23,
431 	FUSE_REMOVEXATTR	= 24,
432 	FUSE_FLUSH		= 25,
433 	FUSE_INIT		= 26,
434 	FUSE_OPENDIR		= 27,
435 	FUSE_READDIR		= 28,
436 	FUSE_RELEASEDIR		= 29,
437 	FUSE_FSYNCDIR		= 30,
438 	FUSE_GETLK		= 31,
439 	FUSE_SETLK		= 32,
440 	FUSE_SETLKW		= 33,
441 	FUSE_ACCESS		= 34,
442 	FUSE_CREATE		= 35,
443 	FUSE_INTERRUPT		= 36,
444 	FUSE_BMAP		= 37,
445 	FUSE_DESTROY		= 38,
446 	FUSE_IOCTL		= 39,
447 	FUSE_POLL		= 40,
448 	FUSE_NOTIFY_REPLY	= 41,
449 	FUSE_BATCH_FORGET	= 42,
450 	FUSE_FALLOCATE		= 43,
451 	FUSE_READDIRPLUS	= 44,
452 	FUSE_RENAME2		= 45,
453 	FUSE_LSEEK		= 46,
454 	FUSE_COPY_FILE_RANGE	= 47,
455 
456 #ifdef linux
457 	/* CUSE specific operations */
458 	CUSE_INIT		= 4096,
459 #endif /* linux */
460 };
461 
462 enum fuse_notify_code {
463 	FUSE_NOTIFY_POLL   = 1,
464 	FUSE_NOTIFY_INVAL_INODE = 2,
465 	FUSE_NOTIFY_INVAL_ENTRY = 3,
466 	FUSE_NOTIFY_STORE = 4,
467 	FUSE_NOTIFY_RETRIEVE = 5,
468 	FUSE_NOTIFY_DELETE = 6,
469 	FUSE_NOTIFY_CODE_MAX,
470 };
471 
472 /* The read buffer is required to be at least 8k, but may be much larger */
473 #define FUSE_MIN_READ_BUFFER 8192
474 
475 #define FUSE_COMPAT_ENTRY_OUT_SIZE 120
476 
477 struct fuse_entry_out {
478 	uint64_t	nodeid;		/* Inode ID */
479 	uint64_t	generation;	/* Inode generation: nodeid:gen must
480 					   be unique for the fs's lifetime */
481 	uint64_t	entry_valid;	/* Cache timeout for the name */
482 	uint64_t	attr_valid;	/* Cache timeout for the attributes */
483 	uint32_t	entry_valid_nsec;
484 	uint32_t	attr_valid_nsec;
485 	struct fuse_attr attr;
486 };
487 
488 struct fuse_forget_in {
489 	uint64_t	nlookup;
490 };
491 
492 struct fuse_forget_one {
493 	uint64_t	nodeid;
494 	uint64_t	nlookup;
495 };
496 
497 struct fuse_batch_forget_in {
498 	uint32_t	count;
499 	uint32_t	dummy;
500 };
501 
502 struct fuse_getattr_in {
503 	uint32_t	getattr_flags;
504 	uint32_t	dummy;
505 	uint64_t	fh;
506 };
507 
508 #define FUSE_COMPAT_ATTR_OUT_SIZE 96
509 
510 struct fuse_attr_out {
511 	uint64_t	attr_valid;	/* Cache timeout for the attributes */
512 	uint32_t	attr_valid_nsec;
513 	uint32_t	dummy;
514 	struct fuse_attr attr;
515 };
516 
517 #define FUSE_COMPAT_MKNOD_IN_SIZE 8
518 
519 struct fuse_mknod_in {
520 	uint32_t	mode;
521 	uint32_t	rdev;
522 	uint32_t	umask;
523 	uint32_t	padding;
524 };
525 
526 struct fuse_mkdir_in {
527 	uint32_t	mode;
528 	uint32_t	umask;
529 };
530 
531 struct fuse_rename_in {
532 	uint64_t	newdir;
533 };
534 
535 struct fuse_rename2_in {
536 	uint64_t	newdir;
537 	uint32_t	flags;
538 	uint32_t	padding;
539 };
540 
541 struct fuse_link_in {
542 	uint64_t	oldnodeid;
543 };
544 
545 struct fuse_setattr_in {
546 	uint32_t	valid;
547 	uint32_t	padding;
548 	uint64_t	fh;
549 	uint64_t	size;
550 	uint64_t	lock_owner;
551 	uint64_t	atime;
552 	uint64_t	mtime;
553 	uint64_t	ctime;
554 	uint32_t	atimensec;
555 	uint32_t	mtimensec;
556 	uint32_t	ctimensec;
557 	uint32_t	mode;
558 	uint32_t	unused4;
559 	uint32_t	uid;
560 	uint32_t	gid;
561 	uint32_t	unused5;
562 };
563 
564 struct fuse_open_in {
565 	uint32_t	flags;
566 	uint32_t	unused;
567 };
568 
569 struct fuse_create_in {
570 	uint32_t	flags;
571 	uint32_t	mode;
572 	uint32_t	umask;
573 	uint32_t	padding;
574 };
575 
576 struct fuse_open_out {
577 	uint64_t	fh;
578 	uint32_t	open_flags;
579 	uint32_t	padding;
580 };
581 
582 struct fuse_release_in {
583 	uint64_t	fh;
584 	uint32_t	flags;
585 	uint32_t	release_flags;
586 	uint64_t	lock_owner;
587 };
588 
589 struct fuse_flush_in {
590 	uint64_t	fh;
591 	uint32_t	unused;
592 	uint32_t	padding;
593 	uint64_t	lock_owner;
594 };
595 
596 struct fuse_read_in {
597 	uint64_t	fh;
598 	uint64_t	offset;
599 	uint32_t	size;
600 	uint32_t	read_flags;
601 	uint64_t	lock_owner;
602 	uint32_t	flags;
603 	uint32_t	padding;
604 };
605 
606 #define FUSE_COMPAT_WRITE_IN_SIZE 24
607 
608 struct fuse_write_in {
609 	uint64_t	fh;
610 	uint64_t	offset;
611 	uint32_t	size;
612 	uint32_t	write_flags;
613 	uint64_t	lock_owner;
614 	uint32_t	flags;
615 	uint32_t	padding;
616 };
617 
618 struct fuse_write_out {
619 	uint32_t	size;
620 	uint32_t	padding;
621 };
622 
623 #define FUSE_COMPAT_STATFS_SIZE 48
624 
625 struct fuse_statfs_out {
626 	struct fuse_kstatfs st;
627 };
628 
629 struct fuse_fsync_in {
630 	uint64_t	fh;
631 	uint32_t	fsync_flags;
632 	uint32_t	padding;
633 };
634 
635 struct fuse_setxattr_in {
636 	uint32_t	size;
637 	uint32_t	flags;
638 };
639 
640 struct fuse_listxattr_in {
641 	uint32_t	size;
642 	uint32_t	padding;
643 };
644 
645 struct fuse_listxattr_out {
646 	uint32_t	size;
647 	uint32_t	padding;
648 };
649 
650 struct fuse_getxattr_in {
651 	uint32_t	size;
652 	uint32_t	padding;
653 };
654 
655 struct fuse_getxattr_out {
656 	uint32_t	size;
657 	uint32_t	padding;
658 };
659 
660 struct fuse_lk_in {
661 	uint64_t	fh;
662 	uint64_t	owner;
663 	struct fuse_file_lock lk;
664 	uint32_t	lk_flags;
665 	uint32_t	padding;
666 };
667 
668 struct fuse_lk_out {
669 	struct fuse_file_lock lk;
670 };
671 
672 struct fuse_access_in {
673 	uint32_t	mask;
674 	uint32_t	padding;
675 };
676 
677 struct fuse_init_in {
678 	uint32_t	major;
679 	uint32_t	minor;
680 	uint32_t	max_readahead;
681 	uint32_t	flags;
682 };
683 
684 #define FUSE_COMPAT_INIT_OUT_SIZE 8
685 #define FUSE_COMPAT_22_INIT_OUT_SIZE 24
686 
687 struct fuse_init_out {
688 	uint32_t	major;
689 	uint32_t	minor;
690 	uint32_t	max_readahead;
691 	uint32_t	flags;
692 	uint16_t	max_background;
693 	uint16_t	congestion_threshold;
694 	uint32_t	max_write;
695 	uint32_t	time_gran;
696 	uint16_t	max_pages;
697 	uint16_t	padding;
698 	uint32_t	unused[8];
699 };
700 
701 #ifdef linux
702 #define CUSE_INIT_INFO_MAX 4096
703 
704 struct cuse_init_in {
705 	uint32_t	major;
706 	uint32_t	minor;
707 	uint32_t	unused;
708 	uint32_t	flags;
709 };
710 
711 struct cuse_init_out {
712 	uint32_t	major;
713 	uint32_t	minor;
714 	uint32_t	unused;
715 	uint32_t	flags;
716 	uint32_t	max_read;
717 	uint32_t	max_write;
718 	uint32_t	dev_major;		/* chardev major */
719 	uint32_t	dev_minor;		/* chardev minor */
720 	uint32_t	spare[10];
721 };
722 #endif /* linux */
723 
724 struct fuse_interrupt_in {
725 	uint64_t	unique;
726 };
727 
728 struct fuse_bmap_in {
729 	uint64_t	block;
730 	uint32_t	blocksize;
731 	uint32_t	padding;
732 };
733 
734 struct fuse_bmap_out {
735 	uint64_t	block;
736 };
737 
738 struct fuse_ioctl_in {
739 	uint64_t	fh;
740 	uint32_t	flags;
741 	uint32_t	cmd;
742 	uint64_t	arg;
743 	uint32_t	in_size;
744 	uint32_t	out_size;
745 };
746 
747 struct fuse_ioctl_iovec {
748 	uint64_t	base;
749 	uint64_t	len;
750 };
751 
752 struct fuse_ioctl_out {
753 	int32_t		result;
754 	uint32_t	flags;
755 	uint32_t	in_iovs;
756 	uint32_t	out_iovs;
757 };
758 
759 struct fuse_poll_in {
760 	uint64_t	fh;
761 	uint64_t	kh;
762 	uint32_t	flags;
763 	uint32_t	events;
764 };
765 
766 struct fuse_poll_out {
767 	uint32_t	revents;
768 	uint32_t	padding;
769 };
770 
771 struct fuse_notify_poll_wakeup_out {
772 	uint64_t	kh;
773 };
774 
775 struct fuse_fallocate_in {
776 	uint64_t	fh;
777 	uint64_t	offset;
778 	uint64_t	length;
779 	uint32_t	mode;
780 	uint32_t	padding;
781 };
782 
783 struct fuse_in_header {
784 	uint32_t	len;
785 	uint32_t	opcode;
786 	uint64_t	unique;
787 	uint64_t	nodeid;
788 	uint32_t	uid;
789 	uint32_t	gid;
790 	uint32_t	pid;
791 	uint32_t	padding;
792 };
793 
794 struct fuse_out_header {
795 	uint32_t	len;
796 	int32_t		error;
797 	uint64_t	unique;
798 };
799 
800 struct fuse_dirent {
801 	uint64_t	ino;
802 	uint64_t	off;
803 	uint32_t	namelen;
804 	uint32_t	type;
805 	char name[];
806 };
807 
808 #define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name)
809 #define FUSE_DIRENT_ALIGN(x) \
810 	(((x) + sizeof(uint64_t) - 1) & ~(sizeof(uint64_t) - 1))
811 #define FUSE_DIRENT_SIZE(d) \
812 	FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)
813 
814 struct fuse_direntplus {
815 	struct fuse_entry_out entry_out;
816 	struct fuse_dirent dirent;
817 };
818 
819 #define FUSE_NAME_OFFSET_DIRENTPLUS \
820 	offsetof(struct fuse_direntplus, dirent.name)
821 #define FUSE_DIRENTPLUS_SIZE(d) \
822 	FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET_DIRENTPLUS + (d)->dirent.namelen)
823 
824 struct fuse_notify_inval_inode_out {
825 	uint64_t	ino;
826 	int64_t		off;
827 	int64_t		len;
828 };
829 
830 struct fuse_notify_inval_entry_out {
831 	uint64_t	parent;
832 	uint32_t	namelen;
833 	uint32_t	padding;
834 };
835 
836 struct fuse_notify_delete_out {
837 	uint64_t	parent;
838 	uint64_t	child;
839 	uint32_t	namelen;
840 	uint32_t	padding;
841 };
842 
843 struct fuse_notify_store_out {
844 	uint64_t	nodeid;
845 	uint64_t	offset;
846 	uint32_t	size;
847 	uint32_t	padding;
848 };
849 
850 struct fuse_notify_retrieve_out {
851 	uint64_t	notify_unique;
852 	uint64_t	nodeid;
853 	uint64_t	offset;
854 	uint32_t	size;
855 	uint32_t	padding;
856 };
857 
858 /* Matches the size of fuse_write_in */
859 struct fuse_notify_retrieve_in {
860 	uint64_t	dummy1;
861 	uint64_t	offset;
862 	uint32_t	size;
863 	uint32_t	dummy2;
864 	uint64_t	dummy3;
865 	uint64_t	dummy4;
866 };
867 
868 struct fuse_lseek_in {
869 	uint64_t	fh;
870 	uint64_t	offset;
871 	uint32_t	whence;
872 	uint32_t	padding;
873 };
874 
875 struct fuse_lseek_out {
876 	uint64_t	offset;
877 };
878 
879 struct fuse_copy_file_range_in {
880 	uint64_t	fh_in;
881 	uint64_t	off_in;
882 	uint64_t	nodeid_out;
883 	uint64_t	fh_out;
884 	uint64_t	off_out;
885 	uint64_t	len;
886 	uint64_t	flags;
887 };
888 
889 #endif /* _FUSE_FUSE_KERNEL_H */
890