xref: /freebsd/sys/fs/fuse/fuse_kernel.h (revision 48d92db0804b0e70e0d8dca5e1c8a99eaf70cc3c)
192bbfe1fSAlan Somers /*-
292bbfe1fSAlan Somers  * SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause)
392bbfe1fSAlan Somers  *
45fe58019SAttilio Rao  * This file defines the kernel interface of FUSE
59c62bc70SAlan Somers  * Copyright (C) 2001-2008  Miklos Szeredi <miklos@szeredi.hu>
65fe58019SAttilio Rao  *
75fe58019SAttilio Rao  * This program can be distributed under the terms of the GNU GPL.
85fe58019SAttilio Rao  * See the file COPYING.
95fe58019SAttilio Rao  *
105fe58019SAttilio Rao  * This -- and only this -- header file may also be distributed under
115fe58019SAttilio Rao  * the terms of the BSD Licence as follows:
125fe58019SAttilio Rao  *
135fe58019SAttilio Rao  * Copyright (C) 2001-2007 Miklos Szeredi. All rights reserved.
145fe58019SAttilio Rao  *
155fe58019SAttilio Rao  * Redistribution and use in source and binary forms, with or without
165fe58019SAttilio Rao  * modification, are permitted provided that the following conditions
175fe58019SAttilio Rao  * are met:
185fe58019SAttilio Rao  * 1. Redistributions of source code must retain the above copyright
195fe58019SAttilio Rao  *    notice, this list of conditions and the following disclaimer.
205fe58019SAttilio Rao  * 2. Redistributions in binary form must reproduce the above copyright
215fe58019SAttilio Rao  *    notice, this list of conditions and the following disclaimer in the
225fe58019SAttilio Rao  *    documentation and/or other materials provided with the distribution.
235fe58019SAttilio Rao  *
245fe58019SAttilio Rao  * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
255fe58019SAttilio Rao  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
265fe58019SAttilio Rao  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
275fe58019SAttilio Rao  * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
285fe58019SAttilio Rao  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
295fe58019SAttilio Rao  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
305fe58019SAttilio Rao  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
315fe58019SAttilio Rao  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
325fe58019SAttilio Rao  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
335fe58019SAttilio Rao  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
345fe58019SAttilio Rao  * SUCH DAMAGE.
355fe58019SAttilio Rao  */
365fe58019SAttilio Rao 
3716bd2d47SAlan Somers /*
3816bd2d47SAlan Somers  * This file defines the kernel interface of FUSE
3916bd2d47SAlan Somers  *
4016bd2d47SAlan Somers  * Protocol changelog:
4116bd2d47SAlan Somers  *
42a3a1ce37SAlan Somers  * 7.1:
43a3a1ce37SAlan Somers  *  - add the following messages:
44a3a1ce37SAlan Somers  *      FUSE_SETATTR, FUSE_SYMLINK, FUSE_MKNOD, FUSE_MKDIR, FUSE_UNLINK,
45a3a1ce37SAlan Somers  *      FUSE_RMDIR, FUSE_RENAME, FUSE_LINK, FUSE_OPEN, FUSE_READ, FUSE_WRITE,
46a3a1ce37SAlan Somers  *      FUSE_RELEASE, FUSE_FSYNC, FUSE_FLUSH, FUSE_SETXATTR, FUSE_GETXATTR,
47a3a1ce37SAlan Somers  *      FUSE_LISTXATTR, FUSE_REMOVEXATTR, FUSE_OPENDIR, FUSE_READDIR,
48a3a1ce37SAlan Somers  *      FUSE_RELEASEDIR
49a3a1ce37SAlan Somers  *  - add padding to messages to accommodate 32-bit servers on 64-bit kernels
50a3a1ce37SAlan Somers  *
51a3a1ce37SAlan Somers  * 7.2:
52a3a1ce37SAlan Somers  *  - add FOPEN_DIRECT_IO and FOPEN_KEEP_CACHE flags
53a3a1ce37SAlan Somers  *  - add FUSE_FSYNCDIR message
54a3a1ce37SAlan Somers  *
55a3a1ce37SAlan Somers  * 7.3:
56a3a1ce37SAlan Somers  *  - add FUSE_ACCESS message
57a3a1ce37SAlan Somers  *  - add FUSE_CREATE message
58a3a1ce37SAlan Somers  *  - add filehandle to fuse_setattr_in
59a3a1ce37SAlan Somers  *
60a3a1ce37SAlan Somers  * 7.4:
61a3a1ce37SAlan Somers  *  - add frsize to fuse_kstatfs
62a3a1ce37SAlan Somers  *  - clean up request size limit checking
63a3a1ce37SAlan Somers  *
64a3a1ce37SAlan Somers  * 7.5:
65a3a1ce37SAlan Somers  *  - add flags and max_write to fuse_init_out
66a3a1ce37SAlan Somers  *
67a3a1ce37SAlan Somers  * 7.6:
68a3a1ce37SAlan Somers  *  - add max_readahead to fuse_init_in and fuse_init_out
69a3a1ce37SAlan Somers  *
70a3a1ce37SAlan Somers  * 7.7:
71a3a1ce37SAlan Somers  *  - add FUSE_INTERRUPT message
72a3a1ce37SAlan Somers  *  - add POSIX file lock support
73a3a1ce37SAlan Somers  *
74a3a1ce37SAlan Somers  * 7.8:
75a3a1ce37SAlan Somers  *  - add lock_owner and flags fields to fuse_release_in
76a3a1ce37SAlan Somers  *  - add FUSE_BMAP message
77a3a1ce37SAlan Somers  *  - add FUSE_DESTROY message
78a3a1ce37SAlan Somers  *
7916bd2d47SAlan Somers  * 7.9:
8016bd2d47SAlan Somers  *  - new fuse_getattr_in input argument of GETATTR
8116bd2d47SAlan Somers  *  - add lk_flags in fuse_lk_in
8216bd2d47SAlan Somers  *  - add lock_owner field to fuse_setattr_in, fuse_read_in and fuse_write_in
8316bd2d47SAlan Somers  *  - add blksize field to fuse_attr
8416bd2d47SAlan Somers  *  - add file flags field to fuse_read_in and fuse_write_in
85a3a1ce37SAlan Somers  *  - Add ATIME_NOW and MTIME_NOW flags to fuse_setattr_in
863f105d16SAlan Somers  *
873f105d16SAlan Somers  * 7.10
883f105d16SAlan Somers  *  - add nonseekable open flag
899c62bc70SAlan Somers  *
909c62bc70SAlan Somers  * 7.11
919c62bc70SAlan Somers  *  - add IOCTL message
929c62bc70SAlan Somers  *  - add unsolicited notification support
93a3a1ce37SAlan Somers  *  - add POLL message and NOTIFY_POLL notification
94a4856c96SAlan Somers  *
95a4856c96SAlan Somers  * 7.12
96a3a1ce37SAlan Somers  *  - add umask flag to input argument of create, mknod and mkdir
97a4856c96SAlan Somers  *  - add notification messages for invalidation of inodes and
98a4856c96SAlan Somers  *    directory entries
992ffddc5eSAlan Somers  *
1002ffddc5eSAlan Somers  * 7.13
1012ffddc5eSAlan Somers  *  - make max number of background requests and congestion threshold
1022ffddc5eSAlan Somers  *    tunables
103bb23d439SAlan Somers  *
104bb23d439SAlan Somers  * 7.14
105bb23d439SAlan Somers  *  - add splice support to fuse device
1067cbb8e8aSAlan Somers  *
1077cbb8e8aSAlan Somers  * 7.15
1087cbb8e8aSAlan Somers  *  - add store notify
1097cbb8e8aSAlan Somers  *  - add retrieve notify
110b160acd1SAlan Somers  *
111b160acd1SAlan Somers  * 7.16
112b160acd1SAlan Somers  *  - add BATCH_FORGET request
113b160acd1SAlan Somers  *  - FUSE_IOCTL_UNRESTRICTED shall now return with array of 'struct
114b160acd1SAlan Somers  *    fuse_ioctl_iovec' instead of ambiguous 'struct iovec'
115b160acd1SAlan Somers  *  - add FUSE_IOCTL_32BIT flag
116b160acd1SAlan Somers  *
117b160acd1SAlan Somers  * 7.17
118b160acd1SAlan Somers  *  - add FUSE_FLOCK_LOCKS and FUSE_RELEASE_FLOCK_UNLOCK
119b160acd1SAlan Somers  *
120b160acd1SAlan Somers  * 7.18
121b160acd1SAlan Somers  *  - add FUSE_IOCTL_DIR flag
122b160acd1SAlan Somers  *  - add FUSE_NOTIFY_DELETE
123b160acd1SAlan Somers  *
124b160acd1SAlan Somers  * 7.19
125b160acd1SAlan Somers  *  - add FUSE_FALLOCATE
126b160acd1SAlan Somers  *
127b160acd1SAlan Somers  * 7.20
128b160acd1SAlan Somers  *  - add FUSE_AUTO_INVAL_DATA
129a3a1ce37SAlan Somers  *
130b160acd1SAlan Somers  * 7.21
131b160acd1SAlan Somers  *  - add FUSE_READDIRPLUS
132b160acd1SAlan Somers  *  - send the requested events in POLL request
13387ff949aSAlan Somers  *
13487ff949aSAlan Somers  * 7.22
13587ff949aSAlan Somers  *  - add FUSE_ASYNC_DIO
13687ff949aSAlan Somers  *
13787ff949aSAlan Somers  * 7.23
13887ff949aSAlan Somers  *  - add FUSE_WRITEBACK_CACHE
13987ff949aSAlan Somers  *  - add time_gran to fuse_init_out
14087ff949aSAlan Somers  *  - add reserved space to fuse_init_out
14187ff949aSAlan Somers  *  - add FATTR_CTIME
14287ff949aSAlan Somers  *  - add ctime and ctimensec to fuse_setattr_in
14387ff949aSAlan Somers  *  - add FUSE_RENAME2 request
14487ff949aSAlan Somers  *  - add FUSE_NO_OPEN_SUPPORT flag
14537df9d3bSAlan Somers  *
14637df9d3bSAlan Somers  *  7.24
14737df9d3bSAlan Somers  *  - add FUSE_LSEEK for SEEK_HOLE and SEEK_DATA support
14892bbfe1fSAlan Somers  *
14992bbfe1fSAlan Somers  *  7.25
15092bbfe1fSAlan Somers  *  - add FUSE_PARALLEL_DIROPS
15192bbfe1fSAlan Somers  *
15292bbfe1fSAlan Somers  *  7.26
15392bbfe1fSAlan Somers  *  - add FUSE_HANDLE_KILLPRIV
15492bbfe1fSAlan Somers  *  - add FUSE_POSIX_ACL
15592bbfe1fSAlan Somers  *
15692bbfe1fSAlan Somers  *  7.27
15792bbfe1fSAlan Somers  *  - add FUSE_ABORT_ERROR
15892bbfe1fSAlan Somers  *
15992bbfe1fSAlan Somers  *  7.28
16092bbfe1fSAlan Somers  *  - add FUSE_COPY_FILE_RANGE
16192bbfe1fSAlan Somers  *  - add FOPEN_CACHE_DIR
16292bbfe1fSAlan Somers  *  - add FUSE_MAX_PAGES, add max_pages to init_out
16392bbfe1fSAlan Somers  *  - add FUSE_CACHE_SYMLINKS
164*48d92db0SClaudiu I. Palincas  *
165*48d92db0SClaudiu I. Palincas  *  7.29
166*48d92db0SClaudiu I. Palincas  *  - add FUSE_NO_OPENDIR_SUPPORT flag
167*48d92db0SClaudiu I. Palincas  *
168*48d92db0SClaudiu I. Palincas  *  7.30
169*48d92db0SClaudiu I. Palincas  *  - add FUSE_EXPLICIT_INVAL_DATA
170*48d92db0SClaudiu I. Palincas  *  - add FUSE_IOCTL_COMPAT_X32
171*48d92db0SClaudiu I. Palincas  *
172*48d92db0SClaudiu I. Palincas  *  7.31
173*48d92db0SClaudiu I. Palincas  *  - add FUSE_WRITE_KILL_PRIV flag
174*48d92db0SClaudiu I. Palincas  *  - add FUSE_SETUPMAPPING and FUSE_REMOVEMAPPING
175*48d92db0SClaudiu I. Palincas  *  - add map_alignment to fuse_init_out, add FUSE_MAP_ALIGNMENT flag
176*48d92db0SClaudiu I. Palincas  *
177*48d92db0SClaudiu I. Palincas  *  7.32
178*48d92db0SClaudiu I. Palincas  *  - add flags to fuse_attr, add FUSE_ATTR_SUBMOUNT, add FUSE_SUBMOUNTS
17916bd2d47SAlan Somers  */
18016bd2d47SAlan Somers 
18116bd2d47SAlan Somers #ifndef _FUSE_FUSE_KERNEL_H
18216bd2d47SAlan Somers #define _FUSE_FUSE_KERNEL_H
18316bd2d47SAlan Somers 
184b160acd1SAlan Somers #ifdef __linux__
185b160acd1SAlan Somers #include <linux/types.h>
186b160acd1SAlan Somers #else
1875fe58019SAttilio Rao #include <sys/types.h>
1885fe58019SAttilio Rao #endif
1895fe58019SAttilio Rao 
190a3a1ce37SAlan Somers /*
191a3a1ce37SAlan Somers  * Version negotiation:
192a3a1ce37SAlan Somers  *
193a3a1ce37SAlan Somers  * Both the kernel and userspace send the version they support in the
194a3a1ce37SAlan Somers  * INIT request and reply respectively.
195a3a1ce37SAlan Somers  *
196a3a1ce37SAlan Somers  * If the major versions match then both shall use the smallest
197a3a1ce37SAlan Somers  * of the two minor versions for communication.
198a3a1ce37SAlan Somers  *
199a3a1ce37SAlan Somers  * If the kernel supports a larger major version, then userspace shall
200a3a1ce37SAlan Somers  * reply with the major version it supports, ignore the rest of the
201a3a1ce37SAlan Somers  * INIT message and expect a new INIT message from the kernel with a
202a3a1ce37SAlan Somers  * matching major version.
203a3a1ce37SAlan Somers  *
204a3a1ce37SAlan Somers  * If the library supports a larger major version, then it shall fall
205a3a1ce37SAlan Somers  * back to the major protocol version sent by the kernel for
206a3a1ce37SAlan Somers  * communication and reply with that major version (and an arbitrary
207a3a1ce37SAlan Somers  * supported minor version).
208a3a1ce37SAlan Somers  */
209a3a1ce37SAlan Somers 
2105fe58019SAttilio Rao /** Version number of this interface */
2115fe58019SAttilio Rao #define FUSE_KERNEL_VERSION 7
2125fe58019SAttilio Rao 
2135fe58019SAttilio Rao /** Minor version number of this interface */
214*48d92db0SClaudiu I. Palincas #define FUSE_KERNEL_MINOR_VERSION 32
2155fe58019SAttilio Rao 
2165fe58019SAttilio Rao /** The node ID of the root inode */
2175fe58019SAttilio Rao #define FUSE_ROOT_ID 1
2185fe58019SAttilio Rao 
2195fe58019SAttilio Rao /* Make sure all structures are padded to 64bit boundary, so 32bit
2205fe58019SAttilio Rao    userspace works under 64bit kernels */
2215fe58019SAttilio Rao 
2225fe58019SAttilio Rao struct fuse_attr {
2238f9b3ba7SAlan Somers 	uint64_t	ino;
2248f9b3ba7SAlan Somers 	uint64_t	size;
2258f9b3ba7SAlan Somers 	uint64_t	blocks;
2268f9b3ba7SAlan Somers 	uint64_t	atime;
2278f9b3ba7SAlan Somers 	uint64_t	mtime;
2288f9b3ba7SAlan Somers 	uint64_t	ctime;
2298f9b3ba7SAlan Somers 	uint32_t	atimensec;
2308f9b3ba7SAlan Somers 	uint32_t	mtimensec;
2318f9b3ba7SAlan Somers 	uint32_t	ctimensec;
2328f9b3ba7SAlan Somers 	uint32_t	mode;
2338f9b3ba7SAlan Somers 	uint32_t	nlink;
2348f9b3ba7SAlan Somers 	uint32_t	uid;
2358f9b3ba7SAlan Somers 	uint32_t	gid;
2368f9b3ba7SAlan Somers 	uint32_t	rdev;
2378f9b3ba7SAlan Somers 	uint32_t	blksize;
238*48d92db0SClaudiu I. Palincas 	uint32_t	flags;
2395fe58019SAttilio Rao };
2405fe58019SAttilio Rao 
2415fe58019SAttilio Rao struct fuse_kstatfs {
2428f9b3ba7SAlan Somers 	uint64_t	blocks;
2438f9b3ba7SAlan Somers 	uint64_t	bfree;
2448f9b3ba7SAlan Somers 	uint64_t	bavail;
2458f9b3ba7SAlan Somers 	uint64_t	files;
2468f9b3ba7SAlan Somers 	uint64_t	ffree;
2478f9b3ba7SAlan Somers 	uint32_t	bsize;
2488f9b3ba7SAlan Somers 	uint32_t	namelen;
2498f9b3ba7SAlan Somers 	uint32_t	frsize;
2508f9b3ba7SAlan Somers 	uint32_t	padding;
2518f9b3ba7SAlan Somers 	uint32_t	spare[6];
2525fe58019SAttilio Rao };
2535fe58019SAttilio Rao 
2545fe58019SAttilio Rao struct fuse_file_lock {
2558f9b3ba7SAlan Somers 	uint64_t	start;
2568f9b3ba7SAlan Somers 	uint64_t	end;
2578f9b3ba7SAlan Somers 	uint32_t	type;
2588f9b3ba7SAlan Somers 	uint32_t	pid; /* tgid */
2595fe58019SAttilio Rao };
2605fe58019SAttilio Rao 
2615fe58019SAttilio Rao /**
2625fe58019SAttilio Rao  * Bitmasks for fuse_setattr_in.valid
2635fe58019SAttilio Rao  */
2645fe58019SAttilio Rao #define FATTR_MODE	(1 << 0)
2655fe58019SAttilio Rao #define FATTR_UID	(1 << 1)
2665fe58019SAttilio Rao #define FATTR_GID	(1 << 2)
2675fe58019SAttilio Rao #define FATTR_SIZE	(1 << 3)
2685fe58019SAttilio Rao #define FATTR_ATIME	(1 << 4)
2695fe58019SAttilio Rao #define FATTR_MTIME	(1 << 5)
2705fe58019SAttilio Rao #define FATTR_FH	(1 << 6)
27116bd2d47SAlan Somers #define FATTR_ATIME_NOW	(1 << 7)
27216bd2d47SAlan Somers #define FATTR_MTIME_NOW	(1 << 8)
27316bd2d47SAlan Somers #define FATTR_LOCKOWNER	(1 << 9)
27487ff949aSAlan Somers #define FATTR_CTIME	(1 << 10)
2755fe58019SAttilio Rao 
2765fe58019SAttilio Rao /**
2775fe58019SAttilio Rao  * Flags returned by the OPEN request
2785fe58019SAttilio Rao  *
2795fe58019SAttilio Rao  * FOPEN_DIRECT_IO: bypass page cache for this open file
2805fe58019SAttilio Rao  * FOPEN_KEEP_CACHE: don't invalidate the data cache on open
2813f105d16SAlan Somers  * FOPEN_NONSEEKABLE: the file is not seekable
28292bbfe1fSAlan Somers  * FOPEN_CACHE_DIR: allow caching this directory
283*48d92db0SClaudiu I. Palincas  * FOPEN_STREAM: the file is stream-like (no file position at all)
2845fe58019SAttilio Rao  */
2855fe58019SAttilio Rao #define FOPEN_DIRECT_IO		(1 << 0)
2865fe58019SAttilio Rao #define FOPEN_KEEP_CACHE	(1 << 1)
2873f105d16SAlan Somers #define FOPEN_NONSEEKABLE	(1 << 2)
28892bbfe1fSAlan Somers #define FOPEN_CACHE_DIR		(1 << 3)
289*48d92db0SClaudiu I. Palincas #define FOPEN_STREAM		(1 << 4)
2905fe58019SAttilio Rao 
2915fe58019SAttilio Rao /**
2925fe58019SAttilio Rao  * INIT request/reply flags
29316bd2d47SAlan Somers  *
294b160acd1SAlan Somers  * FUSE_ASYNC_READ: asynchronous read requests
295b160acd1SAlan Somers  * FUSE_POSIX_LOCKS: remote locking for POSIX file locks
296b160acd1SAlan Somers  * FUSE_FILE_OPS: kernel sends file handle for fstat, etc... (not yet supported)
297b160acd1SAlan Somers  * FUSE_ATOMIC_O_TRUNC: handles the O_TRUNC open flag in the filesystem
29816bd2d47SAlan Somers  * FUSE_EXPORT_SUPPORT: filesystem handles lookups of "." and ".."
299b160acd1SAlan Somers  * FUSE_BIG_WRITES: filesystem can handle write size larger than 4kB
300a4856c96SAlan Somers  * FUSE_DONT_MASK: don't apply umask to file mode on create operations
301b160acd1SAlan Somers  * FUSE_SPLICE_WRITE: kernel supports splice write on the device
302b160acd1SAlan Somers  * FUSE_SPLICE_MOVE: kernel supports splice move on the device
303b160acd1SAlan Somers  * FUSE_SPLICE_READ: kernel supports splice read on the device
304b160acd1SAlan Somers  * FUSE_FLOCK_LOCKS: remote locking for BSD style file locks
305b160acd1SAlan Somers  * FUSE_HAS_IOCTL_DIR: kernel supports ioctl on directories
306b160acd1SAlan Somers  * FUSE_AUTO_INVAL_DATA: automatically invalidate cached pages
307b160acd1SAlan Somers  * FUSE_DO_READDIRPLUS: do READDIRPLUS (READDIR+LOOKUP in one)
308b160acd1SAlan Somers  * FUSE_READDIRPLUS_AUTO: adaptive readdirplus
30987ff949aSAlan Somers  * FUSE_ASYNC_DIO: asynchronous direct I/O submission
31087ff949aSAlan Somers  * FUSE_WRITEBACK_CACHE: use writeback cache for buffered writes
31187ff949aSAlan Somers  * FUSE_NO_OPEN_SUPPORT: kernel supports zero-message opens
31292bbfe1fSAlan Somers  * FUSE_PARALLEL_DIROPS: allow parallel lookups and readdir
31392bbfe1fSAlan Somers  * FUSE_HANDLE_KILLPRIV: fs handles killing suid/sgid/cap on write/chown/trunc
31492bbfe1fSAlan Somers  * FUSE_POSIX_ACL: filesystem supports posix acls
31592bbfe1fSAlan Somers  * FUSE_ABORT_ERROR: reading the device after abort returns ECONNABORTED
31692bbfe1fSAlan Somers  * FUSE_MAX_PAGES: init_out.max_pages contains the max number of req pages
31792bbfe1fSAlan Somers  * FUSE_CACHE_SYMLINKS: cache READLINK responses
3187124d2bcSAlan Somers  * FUSE_NO_OPENDIR_SUPPORT: kernel supports zero-message opendir
319*48d92db0SClaudiu I. Palincas  * FUSE_EXPLICIT_INVAL_DATA: only invalidate cached pages on explicit request
320*48d92db0SClaudiu I. Palincas  * FUSE_MAP_ALIGNMENT: init_out.map_alignment contains log2(byte alignment) for
321*48d92db0SClaudiu I. Palincas  *		       foffset and moffset fields in struct
322*48d92db0SClaudiu I. Palincas  *		       fuse_setupmapping_out and fuse_removemapping_one.
323*48d92db0SClaudiu I. Palincas  * FUSE_SUBMOUNTS: kernel supports auto-mounting directory submounts
3245fe58019SAttilio Rao  */
3255fe58019SAttilio Rao #define FUSE_ASYNC_READ		(1 << 0)
3265fe58019SAttilio Rao #define FUSE_POSIX_LOCKS	(1 << 1)
32716bd2d47SAlan Somers #define FUSE_FILE_OPS		(1 << 2)
32816bd2d47SAlan Somers #define FUSE_ATOMIC_O_TRUNC	(1 << 3)
32916bd2d47SAlan Somers #define FUSE_EXPORT_SUPPORT	(1 << 4)
33016bd2d47SAlan Somers #define FUSE_BIG_WRITES		(1 << 5)
331a4856c96SAlan Somers #define FUSE_DONT_MASK		(1 << 6)
332b160acd1SAlan Somers #define FUSE_SPLICE_WRITE	(1 << 7)
333b160acd1SAlan Somers #define FUSE_SPLICE_MOVE	(1 << 8)
334b160acd1SAlan Somers #define FUSE_SPLICE_READ	(1 << 9)
335b160acd1SAlan Somers #define FUSE_FLOCK_LOCKS	(1 << 10)
336b160acd1SAlan Somers #define FUSE_HAS_IOCTL_DIR	(1 << 11)
337b160acd1SAlan Somers #define FUSE_AUTO_INVAL_DATA	(1 << 12)
338b160acd1SAlan Somers #define FUSE_DO_READDIRPLUS	(1 << 13)
339b160acd1SAlan Somers #define FUSE_READDIRPLUS_AUTO	(1 << 14)
34087ff949aSAlan Somers #define FUSE_ASYNC_DIO		(1 << 15)
34187ff949aSAlan Somers #define FUSE_WRITEBACK_CACHE	(1 << 16)
34287ff949aSAlan Somers #define FUSE_NO_OPEN_SUPPORT	(1 << 17)
34392bbfe1fSAlan Somers #define FUSE_PARALLEL_DIROPS    (1 << 18)
34492bbfe1fSAlan Somers #define FUSE_HANDLE_KILLPRIV	(1 << 19)
34592bbfe1fSAlan Somers #define FUSE_POSIX_ACL		(1 << 20)
34692bbfe1fSAlan Somers #define FUSE_ABORT_ERROR	(1 << 21)
34792bbfe1fSAlan Somers #define FUSE_MAX_PAGES		(1 << 22)
34892bbfe1fSAlan Somers #define FUSE_CACHE_SYMLINKS	(1 << 23)
3497124d2bcSAlan Somers #define FUSE_NO_OPENDIR_SUPPORT (1 << 24)
350*48d92db0SClaudiu I. Palincas #define FUSE_EXPLICIT_INVAL_DATA (1 << 25)
351*48d92db0SClaudiu I. Palincas #define FUSE_MAP_ALIGNMENT	(1 << 26)
352*48d92db0SClaudiu I. Palincas #define FUSE_SUBMOUNTS		(1 << 27)
3535fe58019SAttilio Rao 
3549c62bc70SAlan Somers #ifdef linux
3559c62bc70SAlan Somers /**
3569c62bc70SAlan Somers  * CUSE INIT request/reply flags
3579c62bc70SAlan Somers  *
3589c62bc70SAlan Somers  * CUSE_UNRESTRICTED_IOCTL:  use unrestricted ioctl
3599c62bc70SAlan Somers  */
3609c62bc70SAlan Somers #define CUSE_UNRESTRICTED_IOCTL	(1 << 0)
3619c62bc70SAlan Somers #endif /* linux */
3629c62bc70SAlan Somers 
3635fe58019SAttilio Rao /**
3645fe58019SAttilio Rao  * Release flags
3655fe58019SAttilio Rao  */
3665fe58019SAttilio Rao #define FUSE_RELEASE_FLUSH	(1 << 0)
367b160acd1SAlan Somers #define FUSE_RELEASE_FLOCK_UNLOCK	(1 << 1)
3685fe58019SAttilio Rao 
36916bd2d47SAlan Somers /**
37016bd2d47SAlan Somers  * Getattr flags
37116bd2d47SAlan Somers  */
37216bd2d47SAlan Somers #define FUSE_GETATTR_FH		(1 << 0)
37316bd2d47SAlan Somers 
37416bd2d47SAlan Somers /**
37516bd2d47SAlan Somers  * Lock flags
37616bd2d47SAlan Somers  */
37716bd2d47SAlan Somers #define FUSE_LK_FLOCK		(1 << 0)
37816bd2d47SAlan Somers 
37916bd2d47SAlan Somers /**
38016bd2d47SAlan Somers  * WRITE flags
38116bd2d47SAlan Somers  *
38216bd2d47SAlan Somers  * FUSE_WRITE_CACHE: delayed write from page cache, file handle is guessed
38316bd2d47SAlan Somers  * FUSE_WRITE_LOCKOWNER: lock_owner field is valid
384*48d92db0SClaudiu I. Palincas  * FUSE_WRITE_KILL_PRIV: kill suid and sgid bits
38516bd2d47SAlan Somers  */
38616bd2d47SAlan Somers #define FUSE_WRITE_CACHE	(1 << 0)
38716bd2d47SAlan Somers #define FUSE_WRITE_LOCKOWNER	(1 << 1)
388*48d92db0SClaudiu I. Palincas #define FUSE_WRITE_KILL_PRIV	(1 << 2)
38916bd2d47SAlan Somers 
39016bd2d47SAlan Somers /**
39116bd2d47SAlan Somers  * Read flags
39216bd2d47SAlan Somers  */
39316bd2d47SAlan Somers #define FUSE_READ_LOCKOWNER	(1 << 1)
39416bd2d47SAlan Somers 
3959c62bc70SAlan Somers /**
3969c62bc70SAlan Somers  * Ioctl flags
3979c62bc70SAlan Somers  *
3989c62bc70SAlan Somers  * FUSE_IOCTL_COMPAT: 32bit compat ioctl on 64bit machine
3999c62bc70SAlan Somers  * FUSE_IOCTL_UNRESTRICTED: not restricted to well-formed ioctls, retry allowed
4009c62bc70SAlan Somers  * FUSE_IOCTL_RETRY: retry with new iovecs
401b160acd1SAlan Somers  * FUSE_IOCTL_32BIT: 32bit ioctl
402b160acd1SAlan Somers  * FUSE_IOCTL_DIR: is a directory
403*48d92db0SClaudiu I. Palincas  * FUSE_IOCTL_COMPAT_X32: x32 compat ioctl on 64bit machine (64bit time_t)
4049c62bc70SAlan Somers  *
4059c62bc70SAlan Somers  * FUSE_IOCTL_MAX_IOV: maximum of in_iovecs + out_iovecs
4069c62bc70SAlan Somers  */
4079c62bc70SAlan Somers #define FUSE_IOCTL_COMPAT	(1 << 0)
4089c62bc70SAlan Somers #define FUSE_IOCTL_UNRESTRICTED	(1 << 1)
4099c62bc70SAlan Somers #define FUSE_IOCTL_RETRY	(1 << 2)
410b160acd1SAlan Somers #define FUSE_IOCTL_32BIT	(1 << 3)
411b160acd1SAlan Somers #define FUSE_IOCTL_DIR		(1 << 4)
412*48d92db0SClaudiu I. Palincas #define FUSE_IOCTL_COMPAT_X32	(1 << 5)
4139c62bc70SAlan Somers 
4149c62bc70SAlan Somers #define FUSE_IOCTL_MAX_IOV	256
4159c62bc70SAlan Somers 
4169c62bc70SAlan Somers /**
4179c62bc70SAlan Somers  * Poll flags
4189c62bc70SAlan Somers  *
4199c62bc70SAlan Somers  * FUSE_POLL_SCHEDULE_NOTIFY: request poll notify
4209c62bc70SAlan Somers  */
4219c62bc70SAlan Somers #define FUSE_POLL_SCHEDULE_NOTIFY (1 << 0)
4229c62bc70SAlan Somers 
423a3a1ce37SAlan Somers /**
424a3a1ce37SAlan Somers  * Fsync flags
425a3a1ce37SAlan Somers  *
426a3a1ce37SAlan Somers  * FUSE_FSYNC_FDATASYNC: Sync data only, not metadata
427a3a1ce37SAlan Somers  */
428a3a1ce37SAlan Somers #define FUSE_FSYNC_FDATASYNC	(1 << 0)
429a3a1ce37SAlan Somers 
43089d57b94SAlan Somers /**
43189d57b94SAlan Somers  * Fallocate flags.
43289d57b94SAlan Somers  */
43389d57b94SAlan Somers #define FUSE_FALLOC_FL_KEEP_SIZE	0x1
43489d57b94SAlan Somers #define FUSE_FALLOC_FL_PUNCH_HOLE	0x2
43589d57b94SAlan Somers 
436*48d92db0SClaudiu I. Palincas /**
437*48d92db0SClaudiu I. Palincas  * fuse_attr flags
438*48d92db0SClaudiu I. Palincas  *
439*48d92db0SClaudiu I. Palincas  * FUSE_ATTR_SUBMOUNT: Object is a submount root
440*48d92db0SClaudiu I. Palincas  */
441*48d92db0SClaudiu I. Palincas #define FUSE_ATTR_SUBMOUNT      (1 << 0)
442*48d92db0SClaudiu I. Palincas 
4435fe58019SAttilio Rao enum fuse_opcode {
4445fe58019SAttilio Rao 	FUSE_LOOKUP		= 1,
4455fe58019SAttilio Rao 	FUSE_FORGET		= 2,  /* no reply */
4465fe58019SAttilio Rao 	FUSE_GETATTR		= 3,
4475fe58019SAttilio Rao 	FUSE_SETATTR		= 4,
4485fe58019SAttilio Rao 	FUSE_READLINK		= 5,
4495fe58019SAttilio Rao 	FUSE_SYMLINK		= 6,
4505fe58019SAttilio Rao 	FUSE_MKNOD		= 8,
4515fe58019SAttilio Rao 	FUSE_MKDIR		= 9,
4525fe58019SAttilio Rao 	FUSE_UNLINK		= 10,
4535fe58019SAttilio Rao 	FUSE_RMDIR		= 11,
4545fe58019SAttilio Rao 	FUSE_RENAME		= 12,
4555fe58019SAttilio Rao 	FUSE_LINK		= 13,
4565fe58019SAttilio Rao 	FUSE_OPEN		= 14,
4575fe58019SAttilio Rao 	FUSE_READ		= 15,
4585fe58019SAttilio Rao 	FUSE_WRITE		= 16,
4595fe58019SAttilio Rao 	FUSE_STATFS		= 17,
4605fe58019SAttilio Rao 	FUSE_RELEASE		= 18,
4615fe58019SAttilio Rao 	FUSE_FSYNC		= 20,
4625fe58019SAttilio Rao 	FUSE_SETXATTR		= 21,
4635fe58019SAttilio Rao 	FUSE_GETXATTR		= 22,
4645fe58019SAttilio Rao 	FUSE_LISTXATTR		= 23,
4655fe58019SAttilio Rao 	FUSE_REMOVEXATTR	= 24,
4665fe58019SAttilio Rao 	FUSE_FLUSH		= 25,
4675fe58019SAttilio Rao 	FUSE_INIT		= 26,
4685fe58019SAttilio Rao 	FUSE_OPENDIR		= 27,
4695fe58019SAttilio Rao 	FUSE_READDIR		= 28,
4705fe58019SAttilio Rao 	FUSE_RELEASEDIR		= 29,
4715fe58019SAttilio Rao 	FUSE_FSYNCDIR		= 30,
4725fe58019SAttilio Rao 	FUSE_GETLK		= 31,
4735fe58019SAttilio Rao 	FUSE_SETLK		= 32,
4745fe58019SAttilio Rao 	FUSE_SETLKW		= 33,
4755fe58019SAttilio Rao 	FUSE_ACCESS		= 34,
4765fe58019SAttilio Rao 	FUSE_CREATE		= 35,
4775fe58019SAttilio Rao 	FUSE_INTERRUPT		= 36,
4785fe58019SAttilio Rao 	FUSE_BMAP		= 37,
4795fe58019SAttilio Rao 	FUSE_DESTROY		= 38,
4809c62bc70SAlan Somers 	FUSE_IOCTL		= 39,
4819c62bc70SAlan Somers 	FUSE_POLL		= 40,
4827cbb8e8aSAlan Somers 	FUSE_NOTIFY_REPLY	= 41,
483b160acd1SAlan Somers 	FUSE_BATCH_FORGET	= 42,
484b160acd1SAlan Somers 	FUSE_FALLOCATE		= 43,
485b160acd1SAlan Somers 	FUSE_READDIRPLUS	= 44,
48687ff949aSAlan Somers 	FUSE_RENAME2		= 45,
48737df9d3bSAlan Somers 	FUSE_LSEEK		= 46,
48892bbfe1fSAlan Somers 	FUSE_COPY_FILE_RANGE	= 47,
489*48d92db0SClaudiu I. Palincas 	FUSE_SETUPMAPPING	= 48,
490*48d92db0SClaudiu I. Palincas 	FUSE_REMOVEMAPPING	= 49,
4919c62bc70SAlan Somers 
4929c62bc70SAlan Somers #ifdef linux
4939c62bc70SAlan Somers 	/* CUSE specific operations */
4949c62bc70SAlan Somers 	CUSE_INIT		= 4096,
495*48d92db0SClaudiu I. Palincas 	/* Reserved opcodes: helpful to detect structure endian-ness */
496*48d92db0SClaudiu I. Palincas 	CUSE_INIT_BSWAP_RESERVED	= 1048576,	/* CUSE_INIT << 8 */
497*48d92db0SClaudiu I. Palincas 	FUSE_INIT_BSWAP_RESERVED	= 436207616,	/* FUSE_INIT << 24 */
4989c62bc70SAlan Somers #endif /* linux */
4999c62bc70SAlan Somers };
5009c62bc70SAlan Somers 
5019c62bc70SAlan Somers enum fuse_notify_code {
5029c62bc70SAlan Somers 	FUSE_NOTIFY_POLL   = 1,
503a4856c96SAlan Somers 	FUSE_NOTIFY_INVAL_INODE = 2,
504a4856c96SAlan Somers 	FUSE_NOTIFY_INVAL_ENTRY = 3,
5057cbb8e8aSAlan Somers 	FUSE_NOTIFY_STORE = 4,
5067cbb8e8aSAlan Somers 	FUSE_NOTIFY_RETRIEVE = 5,
507b160acd1SAlan Somers 	FUSE_NOTIFY_DELETE = 6,
5089c62bc70SAlan Somers 	FUSE_NOTIFY_CODE_MAX,
5095fe58019SAttilio Rao };
5105fe58019SAttilio Rao 
5115fe58019SAttilio Rao /* The read buffer is required to be at least 8k, but may be much larger */
5125fe58019SAttilio Rao #define FUSE_MIN_READ_BUFFER 8192
5135fe58019SAttilio Rao 
51416bd2d47SAlan Somers #define FUSE_COMPAT_ENTRY_OUT_SIZE 120
51516bd2d47SAlan Somers 
5165fe58019SAttilio Rao struct fuse_entry_out {
5178f9b3ba7SAlan Somers 	uint64_t	nodeid;		/* Inode ID */
5188f9b3ba7SAlan Somers 	uint64_t	generation;	/* Inode generation: nodeid:gen must
5195fe58019SAttilio Rao 					   be unique for the fs's lifetime */
5208f9b3ba7SAlan Somers 	uint64_t	entry_valid;	/* Cache timeout for the name */
5218f9b3ba7SAlan Somers 	uint64_t	attr_valid;	/* Cache timeout for the attributes */
5228f9b3ba7SAlan Somers 	uint32_t	entry_valid_nsec;
5238f9b3ba7SAlan Somers 	uint32_t	attr_valid_nsec;
5245fe58019SAttilio Rao 	struct fuse_attr attr;
5255fe58019SAttilio Rao };
5265fe58019SAttilio Rao 
5275fe58019SAttilio Rao struct fuse_forget_in {
5288f9b3ba7SAlan Somers 	uint64_t	nlookup;
5295fe58019SAttilio Rao };
5305fe58019SAttilio Rao 
531b160acd1SAlan Somers struct fuse_forget_one {
5328f9b3ba7SAlan Somers 	uint64_t	nodeid;
5338f9b3ba7SAlan Somers 	uint64_t	nlookup;
534b160acd1SAlan Somers };
535b160acd1SAlan Somers 
536b160acd1SAlan Somers struct fuse_batch_forget_in {
5378f9b3ba7SAlan Somers 	uint32_t	count;
5388f9b3ba7SAlan Somers 	uint32_t	dummy;
539b160acd1SAlan Somers };
540b160acd1SAlan Somers 
54116bd2d47SAlan Somers struct fuse_getattr_in {
5428f9b3ba7SAlan Somers 	uint32_t	getattr_flags;
5438f9b3ba7SAlan Somers 	uint32_t	dummy;
5448f9b3ba7SAlan Somers 	uint64_t	fh;
54516bd2d47SAlan Somers };
54616bd2d47SAlan Somers 
54716bd2d47SAlan Somers #define FUSE_COMPAT_ATTR_OUT_SIZE 96
54816bd2d47SAlan Somers 
5495fe58019SAttilio Rao struct fuse_attr_out {
5508f9b3ba7SAlan Somers 	uint64_t	attr_valid;	/* Cache timeout for the attributes */
5518f9b3ba7SAlan Somers 	uint32_t	attr_valid_nsec;
5528f9b3ba7SAlan Somers 	uint32_t	dummy;
5535fe58019SAttilio Rao 	struct fuse_attr attr;
5545fe58019SAttilio Rao };
5555fe58019SAttilio Rao 
556a4856c96SAlan Somers #define FUSE_COMPAT_MKNOD_IN_SIZE 8
557a4856c96SAlan Somers 
5584cbb4f88SAlan Somers struct fuse_mknod_in {
5598f9b3ba7SAlan Somers 	uint32_t	mode;
5608f9b3ba7SAlan Somers 	uint32_t	rdev;
5618f9b3ba7SAlan Somers 	uint32_t	umask;
5628f9b3ba7SAlan Somers 	uint32_t	padding;
5634cbb4f88SAlan Somers };
5644cbb4f88SAlan Somers 
5655fe58019SAttilio Rao struct fuse_mkdir_in {
5668f9b3ba7SAlan Somers 	uint32_t	mode;
5678f9b3ba7SAlan Somers 	uint32_t	umask;
5685fe58019SAttilio Rao };
5695fe58019SAttilio Rao 
5705fe58019SAttilio Rao struct fuse_rename_in {
5718f9b3ba7SAlan Somers 	uint64_t	newdir;
5725fe58019SAttilio Rao };
5735fe58019SAttilio Rao 
57487ff949aSAlan Somers struct fuse_rename2_in {
57587ff949aSAlan Somers 	uint64_t	newdir;
57687ff949aSAlan Somers 	uint32_t	flags;
57787ff949aSAlan Somers 	uint32_t	padding;
57887ff949aSAlan Somers };
57987ff949aSAlan Somers 
5805fe58019SAttilio Rao struct fuse_link_in {
5818f9b3ba7SAlan Somers 	uint64_t	oldnodeid;
5825fe58019SAttilio Rao };
5835fe58019SAttilio Rao 
5845fe58019SAttilio Rao struct fuse_setattr_in {
5858f9b3ba7SAlan Somers 	uint32_t	valid;
5868f9b3ba7SAlan Somers 	uint32_t	padding;
5878f9b3ba7SAlan Somers 	uint64_t	fh;
5888f9b3ba7SAlan Somers 	uint64_t	size;
5898f9b3ba7SAlan Somers 	uint64_t	lock_owner;
5908f9b3ba7SAlan Somers 	uint64_t	atime;
5918f9b3ba7SAlan Somers 	uint64_t	mtime;
59287ff949aSAlan Somers 	uint64_t	ctime;
5938f9b3ba7SAlan Somers 	uint32_t	atimensec;
5948f9b3ba7SAlan Somers 	uint32_t	mtimensec;
59587ff949aSAlan Somers 	uint32_t	ctimensec;
5968f9b3ba7SAlan Somers 	uint32_t	mode;
5978f9b3ba7SAlan Somers 	uint32_t	unused4;
5988f9b3ba7SAlan Somers 	uint32_t	uid;
5998f9b3ba7SAlan Somers 	uint32_t	gid;
6008f9b3ba7SAlan Somers 	uint32_t	unused5;
6015fe58019SAttilio Rao };
6025fe58019SAttilio Rao 
6035fe58019SAttilio Rao struct fuse_open_in {
6048f9b3ba7SAlan Somers 	uint32_t	flags;
6058f9b3ba7SAlan Somers 	uint32_t	unused;
606a4856c96SAlan Somers };
607a4856c96SAlan Somers 
608a4856c96SAlan Somers struct fuse_create_in {
6098f9b3ba7SAlan Somers 	uint32_t	flags;
6108f9b3ba7SAlan Somers 	uint32_t	mode;
6118f9b3ba7SAlan Somers 	uint32_t	umask;
6128f9b3ba7SAlan Somers 	uint32_t	padding;
6135fe58019SAttilio Rao };
6145fe58019SAttilio Rao 
6155fe58019SAttilio Rao struct fuse_open_out {
6168f9b3ba7SAlan Somers 	uint64_t	fh;
6178f9b3ba7SAlan Somers 	uint32_t	open_flags;
6188f9b3ba7SAlan Somers 	uint32_t	padding;
6195fe58019SAttilio Rao };
6205fe58019SAttilio Rao 
6215fe58019SAttilio Rao struct fuse_release_in {
6228f9b3ba7SAlan Somers 	uint64_t	fh;
6238f9b3ba7SAlan Somers 	uint32_t	flags;
6248f9b3ba7SAlan Somers 	uint32_t	release_flags;
6258f9b3ba7SAlan Somers 	uint64_t	lock_owner;
6265fe58019SAttilio Rao };
6275fe58019SAttilio Rao 
6285fe58019SAttilio Rao struct fuse_flush_in {
6298f9b3ba7SAlan Somers 	uint64_t	fh;
6308f9b3ba7SAlan Somers 	uint32_t	unused;
6318f9b3ba7SAlan Somers 	uint32_t	padding;
6328f9b3ba7SAlan Somers 	uint64_t	lock_owner;
6335fe58019SAttilio Rao };
6345fe58019SAttilio Rao 
6355fe58019SAttilio Rao struct fuse_read_in {
6368f9b3ba7SAlan Somers 	uint64_t	fh;
6378f9b3ba7SAlan Somers 	uint64_t	offset;
6388f9b3ba7SAlan Somers 	uint32_t	size;
6398f9b3ba7SAlan Somers 	uint32_t	read_flags;
6408f9b3ba7SAlan Somers 	uint64_t	lock_owner;
6418f9b3ba7SAlan Somers 	uint32_t	flags;
6428f9b3ba7SAlan Somers 	uint32_t	padding;
6435fe58019SAttilio Rao };
6445fe58019SAttilio Rao 
64516bd2d47SAlan Somers #define FUSE_COMPAT_WRITE_IN_SIZE 24
64616bd2d47SAlan Somers 
6475fe58019SAttilio Rao struct fuse_write_in {
6488f9b3ba7SAlan Somers 	uint64_t	fh;
6498f9b3ba7SAlan Somers 	uint64_t	offset;
6508f9b3ba7SAlan Somers 	uint32_t	size;
6518f9b3ba7SAlan Somers 	uint32_t	write_flags;
6528f9b3ba7SAlan Somers 	uint64_t	lock_owner;
6538f9b3ba7SAlan Somers 	uint32_t	flags;
6548f9b3ba7SAlan Somers 	uint32_t	padding;
6555fe58019SAttilio Rao };
6565fe58019SAttilio Rao 
6575fe58019SAttilio Rao struct fuse_write_out {
6588f9b3ba7SAlan Somers 	uint32_t	size;
6598f9b3ba7SAlan Somers 	uint32_t	padding;
6605fe58019SAttilio Rao };
6615fe58019SAttilio Rao 
6625fe58019SAttilio Rao #define FUSE_COMPAT_STATFS_SIZE 48
6635fe58019SAttilio Rao 
6645fe58019SAttilio Rao struct fuse_statfs_out {
6655fe58019SAttilio Rao 	struct fuse_kstatfs st;
6665fe58019SAttilio Rao };
6675fe58019SAttilio Rao 
6685fe58019SAttilio Rao struct fuse_fsync_in {
6698f9b3ba7SAlan Somers 	uint64_t	fh;
6708f9b3ba7SAlan Somers 	uint32_t	fsync_flags;
6718f9b3ba7SAlan Somers 	uint32_t	padding;
6725fe58019SAttilio Rao };
6735fe58019SAttilio Rao 
67496192dfcSAlan Somers struct fuse_setxattr_in {
6758f9b3ba7SAlan Somers 	uint32_t	size;
6768f9b3ba7SAlan Somers 	uint32_t	flags;
677493b4a8cSFedor Uporov };
678493b4a8cSFedor Uporov 
67996192dfcSAlan Somers struct fuse_listxattr_in {
6808f9b3ba7SAlan Somers 	uint32_t	size;
6818f9b3ba7SAlan Somers 	uint32_t	padding;
68296192dfcSAlan Somers };
68396192dfcSAlan Somers 
684493b4a8cSFedor Uporov struct fuse_listxattr_out {
6858f9b3ba7SAlan Somers 	uint32_t	size;
6868f9b3ba7SAlan Somers 	uint32_t	padding;
6875fe58019SAttilio Rao };
6885fe58019SAttilio Rao 
6895fe58019SAttilio Rao struct fuse_getxattr_in {
6908f9b3ba7SAlan Somers 	uint32_t	size;
6918f9b3ba7SAlan Somers 	uint32_t	padding;
6925fe58019SAttilio Rao };
6935fe58019SAttilio Rao 
6945fe58019SAttilio Rao struct fuse_getxattr_out {
6958f9b3ba7SAlan Somers 	uint32_t	size;
6968f9b3ba7SAlan Somers 	uint32_t	padding;
6975fe58019SAttilio Rao };
6985fe58019SAttilio Rao 
6995fe58019SAttilio Rao struct fuse_lk_in {
7008f9b3ba7SAlan Somers 	uint64_t	fh;
7018f9b3ba7SAlan Somers 	uint64_t	owner;
7025fe58019SAttilio Rao 	struct fuse_file_lock lk;
7038f9b3ba7SAlan Somers 	uint32_t	lk_flags;
7048f9b3ba7SAlan Somers 	uint32_t	padding;
7055fe58019SAttilio Rao };
7065fe58019SAttilio Rao 
7075fe58019SAttilio Rao struct fuse_lk_out {
7085fe58019SAttilio Rao 	struct fuse_file_lock lk;
7095fe58019SAttilio Rao };
7105fe58019SAttilio Rao 
7115fe58019SAttilio Rao struct fuse_access_in {
7128f9b3ba7SAlan Somers 	uint32_t	mask;
7138f9b3ba7SAlan Somers 	uint32_t	padding;
7145fe58019SAttilio Rao };
7155fe58019SAttilio Rao 
7165fe58019SAttilio Rao struct fuse_init_in {
7178f9b3ba7SAlan Somers 	uint32_t	major;
7188f9b3ba7SAlan Somers 	uint32_t	minor;
7198f9b3ba7SAlan Somers 	uint32_t	max_readahead;
7208f9b3ba7SAlan Somers 	uint32_t	flags;
7215fe58019SAttilio Rao };
7225fe58019SAttilio Rao 
72387ff949aSAlan Somers #define FUSE_COMPAT_INIT_OUT_SIZE 8
72487ff949aSAlan Somers #define FUSE_COMPAT_22_INIT_OUT_SIZE 24
72587ff949aSAlan Somers 
7265fe58019SAttilio Rao struct fuse_init_out {
7278f9b3ba7SAlan Somers 	uint32_t	major;
7288f9b3ba7SAlan Somers 	uint32_t	minor;
7298f9b3ba7SAlan Somers 	uint32_t	max_readahead;
7308f9b3ba7SAlan Somers 	uint32_t	flags;
7318f9b3ba7SAlan Somers 	uint16_t	max_background;
7328f9b3ba7SAlan Somers 	uint16_t	congestion_threshold;
7338f9b3ba7SAlan Somers 	uint32_t	max_write;
73487ff949aSAlan Somers 	uint32_t	time_gran;
73592bbfe1fSAlan Somers 	uint16_t	max_pages;
736*48d92db0SClaudiu I. Palincas 	uint16_t	map_alignment;
73792bbfe1fSAlan Somers 	uint32_t	unused[8];
7385fe58019SAttilio Rao };
7395fe58019SAttilio Rao 
7409c62bc70SAlan Somers #ifdef linux
7419c62bc70SAlan Somers #define CUSE_INIT_INFO_MAX 4096
7429c62bc70SAlan Somers 
7439c62bc70SAlan Somers struct cuse_init_in {
7448f9b3ba7SAlan Somers 	uint32_t	major;
7458f9b3ba7SAlan Somers 	uint32_t	minor;
7468f9b3ba7SAlan Somers 	uint32_t	unused;
7478f9b3ba7SAlan Somers 	uint32_t	flags;
7489c62bc70SAlan Somers };
7499c62bc70SAlan Somers 
7509c62bc70SAlan Somers struct cuse_init_out {
7518f9b3ba7SAlan Somers 	uint32_t	major;
7528f9b3ba7SAlan Somers 	uint32_t	minor;
7538f9b3ba7SAlan Somers 	uint32_t	unused;
7548f9b3ba7SAlan Somers 	uint32_t	flags;
7558f9b3ba7SAlan Somers 	uint32_t	max_read;
7568f9b3ba7SAlan Somers 	uint32_t	max_write;
7578f9b3ba7SAlan Somers 	uint32_t	dev_major;		/* chardev major */
7588f9b3ba7SAlan Somers 	uint32_t	dev_minor;		/* chardev minor */
7598f9b3ba7SAlan Somers 	uint32_t	spare[10];
7609c62bc70SAlan Somers };
7619c62bc70SAlan Somers #endif /* linux */
7629c62bc70SAlan Somers 
7635fe58019SAttilio Rao struct fuse_interrupt_in {
7648f9b3ba7SAlan Somers 	uint64_t	unique;
7655fe58019SAttilio Rao };
7665fe58019SAttilio Rao 
7675fe58019SAttilio Rao struct fuse_bmap_in {
7688f9b3ba7SAlan Somers 	uint64_t	block;
7698f9b3ba7SAlan Somers 	uint32_t	blocksize;
7708f9b3ba7SAlan Somers 	uint32_t	padding;
7715fe58019SAttilio Rao };
7725fe58019SAttilio Rao 
7735fe58019SAttilio Rao struct fuse_bmap_out {
7748f9b3ba7SAlan Somers 	uint64_t	block;
7755fe58019SAttilio Rao };
7765fe58019SAttilio Rao 
7779c62bc70SAlan Somers struct fuse_ioctl_in {
7788f9b3ba7SAlan Somers 	uint64_t	fh;
7798f9b3ba7SAlan Somers 	uint32_t	flags;
7808f9b3ba7SAlan Somers 	uint32_t	cmd;
7818f9b3ba7SAlan Somers 	uint64_t	arg;
7828f9b3ba7SAlan Somers 	uint32_t	in_size;
7838f9b3ba7SAlan Somers 	uint32_t	out_size;
7849c62bc70SAlan Somers };
7859c62bc70SAlan Somers 
786b160acd1SAlan Somers struct fuse_ioctl_iovec {
7878f9b3ba7SAlan Somers 	uint64_t	base;
7888f9b3ba7SAlan Somers 	uint64_t	len;
789b160acd1SAlan Somers };
790b160acd1SAlan Somers 
7919c62bc70SAlan Somers struct fuse_ioctl_out {
7928f9b3ba7SAlan Somers 	int32_t		result;
7938f9b3ba7SAlan Somers 	uint32_t	flags;
7948f9b3ba7SAlan Somers 	uint32_t	in_iovs;
7958f9b3ba7SAlan Somers 	uint32_t	out_iovs;
7969c62bc70SAlan Somers };
7979c62bc70SAlan Somers 
7989c62bc70SAlan Somers struct fuse_poll_in {
7998f9b3ba7SAlan Somers 	uint64_t	fh;
8008f9b3ba7SAlan Somers 	uint64_t	kh;
8018f9b3ba7SAlan Somers 	uint32_t	flags;
8028f9b3ba7SAlan Somers 	uint32_t	events;
8039c62bc70SAlan Somers };
8049c62bc70SAlan Somers 
8059c62bc70SAlan Somers struct fuse_poll_out {
8068f9b3ba7SAlan Somers 	uint32_t	revents;
8078f9b3ba7SAlan Somers 	uint32_t	padding;
8089c62bc70SAlan Somers };
8099c62bc70SAlan Somers 
8109c62bc70SAlan Somers struct fuse_notify_poll_wakeup_out {
8118f9b3ba7SAlan Somers 	uint64_t	kh;
8129c62bc70SAlan Somers };
8139c62bc70SAlan Somers 
814b160acd1SAlan Somers struct fuse_fallocate_in {
8158f9b3ba7SAlan Somers 	uint64_t	fh;
8168f9b3ba7SAlan Somers 	uint64_t	offset;
8178f9b3ba7SAlan Somers 	uint64_t	length;
8188f9b3ba7SAlan Somers 	uint32_t	mode;
8198f9b3ba7SAlan Somers 	uint32_t	padding;
820b160acd1SAlan Somers };
821b160acd1SAlan Somers 
8225fe58019SAttilio Rao struct fuse_in_header {
8238f9b3ba7SAlan Somers 	uint32_t	len;
8248f9b3ba7SAlan Somers 	uint32_t	opcode;
8258f9b3ba7SAlan Somers 	uint64_t	unique;
8268f9b3ba7SAlan Somers 	uint64_t	nodeid;
8278f9b3ba7SAlan Somers 	uint32_t	uid;
8288f9b3ba7SAlan Somers 	uint32_t	gid;
8298f9b3ba7SAlan Somers 	uint32_t	pid;
8308f9b3ba7SAlan Somers 	uint32_t	padding;
8315fe58019SAttilio Rao };
8325fe58019SAttilio Rao 
8335fe58019SAttilio Rao struct fuse_out_header {
8348f9b3ba7SAlan Somers 	uint32_t	len;
8358f9b3ba7SAlan Somers 	int32_t		error;
8368f9b3ba7SAlan Somers 	uint64_t	unique;
8375fe58019SAttilio Rao };
8385fe58019SAttilio Rao 
8395fe58019SAttilio Rao struct fuse_dirent {
8408f9b3ba7SAlan Somers 	uint64_t	ino;
8418f9b3ba7SAlan Somers 	uint64_t	off;
8428f9b3ba7SAlan Somers 	uint32_t	namelen;
8438f9b3ba7SAlan Somers 	uint32_t	type;
844b160acd1SAlan Somers 	char name[];
8455fe58019SAttilio Rao };
8465fe58019SAttilio Rao 
8475fe58019SAttilio Rao #define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name)
84887ff949aSAlan Somers #define FUSE_DIRENT_ALIGN(x) \
84987ff949aSAlan Somers 	(((x) + sizeof(uint64_t) - 1) & ~(sizeof(uint64_t) - 1))
8505fe58019SAttilio Rao #define FUSE_DIRENT_SIZE(d) \
8515fe58019SAttilio Rao 	FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)
85216bd2d47SAlan Somers 
853b160acd1SAlan Somers struct fuse_direntplus {
854b160acd1SAlan Somers 	struct fuse_entry_out entry_out;
855b160acd1SAlan Somers 	struct fuse_dirent dirent;
856b160acd1SAlan Somers };
857b160acd1SAlan Somers 
858b160acd1SAlan Somers #define FUSE_NAME_OFFSET_DIRENTPLUS \
859b160acd1SAlan Somers 	offsetof(struct fuse_direntplus, dirent.name)
860b160acd1SAlan Somers #define FUSE_DIRENTPLUS_SIZE(d) \
861b160acd1SAlan Somers 	FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET_DIRENTPLUS + (d)->dirent.namelen)
862b160acd1SAlan Somers 
863a4856c96SAlan Somers struct fuse_notify_inval_inode_out {
8648f9b3ba7SAlan Somers 	uint64_t	ino;
8658f9b3ba7SAlan Somers 	int64_t		off;
8668f9b3ba7SAlan Somers 	int64_t		len;
867a4856c96SAlan Somers };
868a4856c96SAlan Somers 
869a4856c96SAlan Somers struct fuse_notify_inval_entry_out {
8708f9b3ba7SAlan Somers 	uint64_t	parent;
8718f9b3ba7SAlan Somers 	uint32_t	namelen;
8728f9b3ba7SAlan Somers 	uint32_t	padding;
873a4856c96SAlan Somers };
874a4856c96SAlan Somers 
875b160acd1SAlan Somers struct fuse_notify_delete_out {
8768f9b3ba7SAlan Somers 	uint64_t	parent;
8778f9b3ba7SAlan Somers 	uint64_t	child;
8788f9b3ba7SAlan Somers 	uint32_t	namelen;
8798f9b3ba7SAlan Somers 	uint32_t	padding;
880b160acd1SAlan Somers };
881b160acd1SAlan Somers 
882ecb48915SAlan Somers struct fuse_notify_store_out {
8838f9b3ba7SAlan Somers 	uint64_t	nodeid;
8848f9b3ba7SAlan Somers 	uint64_t	offset;
8858f9b3ba7SAlan Somers 	uint32_t	size;
8868f9b3ba7SAlan Somers 	uint32_t	padding;
887ecb48915SAlan Somers };
888ecb48915SAlan Somers 
889ecb48915SAlan Somers struct fuse_notify_retrieve_out {
8908f9b3ba7SAlan Somers 	uint64_t	notify_unique;
8918f9b3ba7SAlan Somers 	uint64_t	nodeid;
8928f9b3ba7SAlan Somers 	uint64_t	offset;
8938f9b3ba7SAlan Somers 	uint32_t	size;
8948f9b3ba7SAlan Somers 	uint32_t	padding;
895ecb48915SAlan Somers };
896ecb48915SAlan Somers 
897ecb48915SAlan Somers /* Matches the size of fuse_write_in */
898ecb48915SAlan Somers struct fuse_notify_retrieve_in {
8998f9b3ba7SAlan Somers 	uint64_t	dummy1;
9008f9b3ba7SAlan Somers 	uint64_t	offset;
9018f9b3ba7SAlan Somers 	uint32_t	size;
9028f9b3ba7SAlan Somers 	uint32_t	dummy2;
9038f9b3ba7SAlan Somers 	uint64_t	dummy3;
9048f9b3ba7SAlan Somers 	uint64_t	dummy4;
905ecb48915SAlan Somers };
906ecb48915SAlan Somers 
907*48d92db0SClaudiu I. Palincas /* Device ioctls: */
908*48d92db0SClaudiu I. Palincas #define FUSE_DEV_IOC_CLONE	_IOR(229, 0, uint32_t)
909*48d92db0SClaudiu I. Palincas 
91037df9d3bSAlan Somers struct fuse_lseek_in {
91137df9d3bSAlan Somers 	uint64_t	fh;
91237df9d3bSAlan Somers 	uint64_t	offset;
91337df9d3bSAlan Somers 	uint32_t	whence;
91437df9d3bSAlan Somers 	uint32_t	padding;
91537df9d3bSAlan Somers };
91637df9d3bSAlan Somers 
91737df9d3bSAlan Somers struct fuse_lseek_out {
91837df9d3bSAlan Somers 	uint64_t	offset;
91937df9d3bSAlan Somers };
92037df9d3bSAlan Somers 
92192bbfe1fSAlan Somers struct fuse_copy_file_range_in {
92292bbfe1fSAlan Somers 	uint64_t	fh_in;
92392bbfe1fSAlan Somers 	uint64_t	off_in;
92492bbfe1fSAlan Somers 	uint64_t	nodeid_out;
92592bbfe1fSAlan Somers 	uint64_t	fh_out;
92692bbfe1fSAlan Somers 	uint64_t	off_out;
92792bbfe1fSAlan Somers 	uint64_t	len;
92892bbfe1fSAlan Somers 	uint64_t	flags;
92992bbfe1fSAlan Somers };
93092bbfe1fSAlan Somers 
931*48d92db0SClaudiu I. Palincas 
932*48d92db0SClaudiu I. Palincas #define FUSE_SETUPMAPPING_FLAG_WRITE (1ull << 0)
933*48d92db0SClaudiu I. Palincas #define FUSE_SETUPMAPPING_FLAG_READ (1ull << 1)
934*48d92db0SClaudiu I. Palincas struct fuse_setupmapping_in {
935*48d92db0SClaudiu I. Palincas 	/* An already open handle */
936*48d92db0SClaudiu I. Palincas 	uint64_t	fh;
937*48d92db0SClaudiu I. Palincas 	/* Offset into the file to start the mapping */
938*48d92db0SClaudiu I. Palincas 	uint64_t	foffset;
939*48d92db0SClaudiu I. Palincas 	/* Length of mapping required */
940*48d92db0SClaudiu I. Palincas 	uint64_t	len;
941*48d92db0SClaudiu I. Palincas 	/* Flags, FUSE_SETUPMAPPING_FLAG_* */
942*48d92db0SClaudiu I. Palincas 	uint64_t	flags;
943*48d92db0SClaudiu I. Palincas 	/* Offset in Memory Window */
944*48d92db0SClaudiu I. Palincas 	uint64_t	moffset;
945*48d92db0SClaudiu I. Palincas };
946*48d92db0SClaudiu I. Palincas 
947*48d92db0SClaudiu I. Palincas struct fuse_removemapping_in {
948*48d92db0SClaudiu I. Palincas 	/* number of fuse_removemapping_one follows */
949*48d92db0SClaudiu I. Palincas 	uint32_t        count;
950*48d92db0SClaudiu I. Palincas };
951*48d92db0SClaudiu I. Palincas 
952*48d92db0SClaudiu I. Palincas struct fuse_removemapping_one {
953*48d92db0SClaudiu I. Palincas 	/* Offset into the dax window start the unmapping */
954*48d92db0SClaudiu I. Palincas 	uint64_t        moffset;
955*48d92db0SClaudiu I. Palincas 	/* Length of mapping required */
956*48d92db0SClaudiu I. Palincas 	uint64_t	len;
957*48d92db0SClaudiu I. Palincas };
958*48d92db0SClaudiu I. Palincas 
959*48d92db0SClaudiu I. Palincas #define FUSE_REMOVEMAPPING_MAX_ENTRY   \
960*48d92db0SClaudiu I. Palincas 	(PAGE_SIZE / sizeof(struct fuse_removemapping_one))
961*48d92db0SClaudiu I. Palincas 
96216bd2d47SAlan Somers #endif /* _FUSE_FUSE_KERNEL_H */
963