Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) */
0002 /*
0003     This file defines the kernel interface of FUSE
0004     Copyright (C) 2001-2008  Miklos Szeredi <miklos@szeredi.hu>
0005 
0006     This program can be distributed under the terms of the GNU GPL.
0007     See the file COPYING.
0008 
0009     This -- and only this -- header file may also be distributed under
0010     the terms of the BSD Licence as follows:
0011 
0012     Copyright (C) 2001-2007 Miklos Szeredi. All rights reserved.
0013 
0014     Redistribution and use in source and binary forms, with or without
0015     modification, are permitted provided that the following conditions
0016     are met:
0017     1. Redistributions of source code must retain the above copyright
0018        notice, this list of conditions and the following disclaimer.
0019     2. Redistributions in binary form must reproduce the above copyright
0020        notice, this list of conditions and the following disclaimer in the
0021        documentation and/or other materials provided with the distribution.
0022 
0023     THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
0024     ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0025     IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0026     ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
0027     FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
0028     DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
0029     OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
0030     HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
0031     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
0032     OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
0033     SUCH DAMAGE.
0034 */
0035 
0036 /*
0037  * This file defines the kernel interface of FUSE
0038  *
0039  * Protocol changelog:
0040  *
0041  * 7.1:
0042  *  - add the following messages:
0043  *      FUSE_SETATTR, FUSE_SYMLINK, FUSE_MKNOD, FUSE_MKDIR, FUSE_UNLINK,
0044  *      FUSE_RMDIR, FUSE_RENAME, FUSE_LINK, FUSE_OPEN, FUSE_READ, FUSE_WRITE,
0045  *      FUSE_RELEASE, FUSE_FSYNC, FUSE_FLUSH, FUSE_SETXATTR, FUSE_GETXATTR,
0046  *      FUSE_LISTXATTR, FUSE_REMOVEXATTR, FUSE_OPENDIR, FUSE_READDIR,
0047  *      FUSE_RELEASEDIR
0048  *  - add padding to messages to accommodate 32-bit servers on 64-bit kernels
0049  *
0050  * 7.2:
0051  *  - add FOPEN_DIRECT_IO and FOPEN_KEEP_CACHE flags
0052  *  - add FUSE_FSYNCDIR message
0053  *
0054  * 7.3:
0055  *  - add FUSE_ACCESS message
0056  *  - add FUSE_CREATE message
0057  *  - add filehandle to fuse_setattr_in
0058  *
0059  * 7.4:
0060  *  - add frsize to fuse_kstatfs
0061  *  - clean up request size limit checking
0062  *
0063  * 7.5:
0064  *  - add flags and max_write to fuse_init_out
0065  *
0066  * 7.6:
0067  *  - add max_readahead to fuse_init_in and fuse_init_out
0068  *
0069  * 7.7:
0070  *  - add FUSE_INTERRUPT message
0071  *  - add POSIX file lock support
0072  *
0073  * 7.8:
0074  *  - add lock_owner and flags fields to fuse_release_in
0075  *  - add FUSE_BMAP message
0076  *  - add FUSE_DESTROY message
0077  *
0078  * 7.9:
0079  *  - new fuse_getattr_in input argument of GETATTR
0080  *  - add lk_flags in fuse_lk_in
0081  *  - add lock_owner field to fuse_setattr_in, fuse_read_in and fuse_write_in
0082  *  - add blksize field to fuse_attr
0083  *  - add file flags field to fuse_read_in and fuse_write_in
0084  *  - Add ATIME_NOW and MTIME_NOW flags to fuse_setattr_in
0085  *
0086  * 7.10
0087  *  - add nonseekable open flag
0088  *
0089  * 7.11
0090  *  - add IOCTL message
0091  *  - add unsolicited notification support
0092  *  - add POLL message and NOTIFY_POLL notification
0093  *
0094  * 7.12
0095  *  - add umask flag to input argument of create, mknod and mkdir
0096  *  - add notification messages for invalidation of inodes and
0097  *    directory entries
0098  *
0099  * 7.13
0100  *  - make max number of background requests and congestion threshold
0101  *    tunables
0102  *
0103  * 7.14
0104  *  - add splice support to fuse device
0105  *
0106  * 7.15
0107  *  - add store notify
0108  *  - add retrieve notify
0109  *
0110  * 7.16
0111  *  - add BATCH_FORGET request
0112  *  - FUSE_IOCTL_UNRESTRICTED shall now return with array of 'struct
0113  *    fuse_ioctl_iovec' instead of ambiguous 'struct iovec'
0114  *  - add FUSE_IOCTL_32BIT flag
0115  *
0116  * 7.17
0117  *  - add FUSE_FLOCK_LOCKS and FUSE_RELEASE_FLOCK_UNLOCK
0118  *
0119  * 7.18
0120  *  - add FUSE_IOCTL_DIR flag
0121  *  - add FUSE_NOTIFY_DELETE
0122  *
0123  * 7.19
0124  *  - add FUSE_FALLOCATE
0125  *
0126  * 7.20
0127  *  - add FUSE_AUTO_INVAL_DATA
0128  *
0129  * 7.21
0130  *  - add FUSE_READDIRPLUS
0131  *  - send the requested events in POLL request
0132  *
0133  * 7.22
0134  *  - add FUSE_ASYNC_DIO
0135  *
0136  * 7.23
0137  *  - add FUSE_WRITEBACK_CACHE
0138  *  - add time_gran to fuse_init_out
0139  *  - add reserved space to fuse_init_out
0140  *  - add FATTR_CTIME
0141  *  - add ctime and ctimensec to fuse_setattr_in
0142  *  - add FUSE_RENAME2 request
0143  *  - add FUSE_NO_OPEN_SUPPORT flag
0144  *
0145  *  7.24
0146  *  - add FUSE_LSEEK for SEEK_HOLE and SEEK_DATA support
0147  *
0148  *  7.25
0149  *  - add FUSE_PARALLEL_DIROPS
0150  *
0151  *  7.26
0152  *  - add FUSE_HANDLE_KILLPRIV
0153  *  - add FUSE_POSIX_ACL
0154  *
0155  *  7.27
0156  *  - add FUSE_ABORT_ERROR
0157  *
0158  *  7.28
0159  *  - add FUSE_COPY_FILE_RANGE
0160  *  - add FOPEN_CACHE_DIR
0161  *  - add FUSE_MAX_PAGES, add max_pages to init_out
0162  *  - add FUSE_CACHE_SYMLINKS
0163  *
0164  *  7.29
0165  *  - add FUSE_NO_OPENDIR_SUPPORT flag
0166  *
0167  *  7.30
0168  *  - add FUSE_EXPLICIT_INVAL_DATA
0169  *  - add FUSE_IOCTL_COMPAT_X32
0170  *
0171  *  7.31
0172  *  - add FUSE_WRITE_KILL_PRIV flag
0173  *  - add FUSE_SETUPMAPPING and FUSE_REMOVEMAPPING
0174  *  - add map_alignment to fuse_init_out, add FUSE_MAP_ALIGNMENT flag
0175  *
0176  *  7.32
0177  *  - add flags to fuse_attr, add FUSE_ATTR_SUBMOUNT, add FUSE_SUBMOUNTS
0178  *
0179  *  7.33
0180  *  - add FUSE_HANDLE_KILLPRIV_V2, FUSE_WRITE_KILL_SUIDGID, FATTR_KILL_SUIDGID
0181  *  - add FUSE_OPEN_KILL_SUIDGID
0182  *  - extend fuse_setxattr_in, add FUSE_SETXATTR_EXT
0183  *  - add FUSE_SETXATTR_ACL_KILL_SGID
0184  *
0185  *  7.34
0186  *  - add FUSE_SYNCFS
0187  *
0188  *  7.35
0189  *  - add FOPEN_NOFLUSH
0190  *
0191  *  7.36
0192  *  - extend fuse_init_in with reserved fields, add FUSE_INIT_EXT init flag
0193  *  - add flags2 to fuse_init_in and fuse_init_out
0194  *  - add FUSE_SECURITY_CTX init flag
0195  *  - add security context to create, mkdir, symlink, and mknod requests
0196  *  - add FUSE_HAS_INODE_DAX, FUSE_ATTR_DAX
0197  */
0198 
0199 #ifndef _LINUX_FUSE_H
0200 #define _LINUX_FUSE_H
0201 
0202 #ifdef __KERNEL__
0203 #include <linux/types.h>
0204 #else
0205 #include <stdint.h>
0206 #endif
0207 
0208 /*
0209  * Version negotiation:
0210  *
0211  * Both the kernel and userspace send the version they support in the
0212  * INIT request and reply respectively.
0213  *
0214  * If the major versions match then both shall use the smallest
0215  * of the two minor versions for communication.
0216  *
0217  * If the kernel supports a larger major version, then userspace shall
0218  * reply with the major version it supports, ignore the rest of the
0219  * INIT message and expect a new INIT message from the kernel with a
0220  * matching major version.
0221  *
0222  * If the library supports a larger major version, then it shall fall
0223  * back to the major protocol version sent by the kernel for
0224  * communication and reply with that major version (and an arbitrary
0225  * supported minor version).
0226  */
0227 
0228 /** Version number of this interface */
0229 #define FUSE_KERNEL_VERSION 7
0230 
0231 /** Minor version number of this interface */
0232 #define FUSE_KERNEL_MINOR_VERSION 36
0233 
0234 /** The node ID of the root inode */
0235 #define FUSE_ROOT_ID 1
0236 
0237 /* Make sure all structures are padded to 64bit boundary, so 32bit
0238    userspace works under 64bit kernels */
0239 
0240 struct fuse_attr {
0241     uint64_t    ino;
0242     uint64_t    size;
0243     uint64_t    blocks;
0244     uint64_t    atime;
0245     uint64_t    mtime;
0246     uint64_t    ctime;
0247     uint32_t    atimensec;
0248     uint32_t    mtimensec;
0249     uint32_t    ctimensec;
0250     uint32_t    mode;
0251     uint32_t    nlink;
0252     uint32_t    uid;
0253     uint32_t    gid;
0254     uint32_t    rdev;
0255     uint32_t    blksize;
0256     uint32_t    flags;
0257 };
0258 
0259 struct fuse_kstatfs {
0260     uint64_t    blocks;
0261     uint64_t    bfree;
0262     uint64_t    bavail;
0263     uint64_t    files;
0264     uint64_t    ffree;
0265     uint32_t    bsize;
0266     uint32_t    namelen;
0267     uint32_t    frsize;
0268     uint32_t    padding;
0269     uint32_t    spare[6];
0270 };
0271 
0272 struct fuse_file_lock {
0273     uint64_t    start;
0274     uint64_t    end;
0275     uint32_t    type;
0276     uint32_t    pid; /* tgid */
0277 };
0278 
0279 /**
0280  * Bitmasks for fuse_setattr_in.valid
0281  */
0282 #define FATTR_MODE  (1 << 0)
0283 #define FATTR_UID   (1 << 1)
0284 #define FATTR_GID   (1 << 2)
0285 #define FATTR_SIZE  (1 << 3)
0286 #define FATTR_ATIME (1 << 4)
0287 #define FATTR_MTIME (1 << 5)
0288 #define FATTR_FH    (1 << 6)
0289 #define FATTR_ATIME_NOW (1 << 7)
0290 #define FATTR_MTIME_NOW (1 << 8)
0291 #define FATTR_LOCKOWNER (1 << 9)
0292 #define FATTR_CTIME (1 << 10)
0293 #define FATTR_KILL_SUIDGID  (1 << 11)
0294 
0295 /**
0296  * Flags returned by the OPEN request
0297  *
0298  * FOPEN_DIRECT_IO: bypass page cache for this open file
0299  * FOPEN_KEEP_CACHE: don't invalidate the data cache on open
0300  * FOPEN_NONSEEKABLE: the file is not seekable
0301  * FOPEN_CACHE_DIR: allow caching this directory
0302  * FOPEN_STREAM: the file is stream-like (no file position at all)
0303  * FOPEN_NOFLUSH: don't flush data cache on close (unless FUSE_WRITEBACK_CACHE)
0304  */
0305 #define FOPEN_DIRECT_IO     (1 << 0)
0306 #define FOPEN_KEEP_CACHE    (1 << 1)
0307 #define FOPEN_NONSEEKABLE   (1 << 2)
0308 #define FOPEN_CACHE_DIR     (1 << 3)
0309 #define FOPEN_STREAM        (1 << 4)
0310 #define FOPEN_NOFLUSH       (1 << 5)
0311 
0312 /**
0313  * INIT request/reply flags
0314  *
0315  * FUSE_ASYNC_READ: asynchronous read requests
0316  * FUSE_POSIX_LOCKS: remote locking for POSIX file locks
0317  * FUSE_FILE_OPS: kernel sends file handle for fstat, etc... (not yet supported)
0318  * FUSE_ATOMIC_O_TRUNC: handles the O_TRUNC open flag in the filesystem
0319  * FUSE_EXPORT_SUPPORT: filesystem handles lookups of "." and ".."
0320  * FUSE_BIG_WRITES: filesystem can handle write size larger than 4kB
0321  * FUSE_DONT_MASK: don't apply umask to file mode on create operations
0322  * FUSE_SPLICE_WRITE: kernel supports splice write on the device
0323  * FUSE_SPLICE_MOVE: kernel supports splice move on the device
0324  * FUSE_SPLICE_READ: kernel supports splice read on the device
0325  * FUSE_FLOCK_LOCKS: remote locking for BSD style file locks
0326  * FUSE_HAS_IOCTL_DIR: kernel supports ioctl on directories
0327  * FUSE_AUTO_INVAL_DATA: automatically invalidate cached pages
0328  * FUSE_DO_READDIRPLUS: do READDIRPLUS (READDIR+LOOKUP in one)
0329  * FUSE_READDIRPLUS_AUTO: adaptive readdirplus
0330  * FUSE_ASYNC_DIO: asynchronous direct I/O submission
0331  * FUSE_WRITEBACK_CACHE: use writeback cache for buffered writes
0332  * FUSE_NO_OPEN_SUPPORT: kernel supports zero-message opens
0333  * FUSE_PARALLEL_DIROPS: allow parallel lookups and readdir
0334  * FUSE_HANDLE_KILLPRIV: fs handles killing suid/sgid/cap on write/chown/trunc
0335  * FUSE_POSIX_ACL: filesystem supports posix acls
0336  * FUSE_ABORT_ERROR: reading the device after abort returns ECONNABORTED
0337  * FUSE_MAX_PAGES: init_out.max_pages contains the max number of req pages
0338  * FUSE_CACHE_SYMLINKS: cache READLINK responses
0339  * FUSE_NO_OPENDIR_SUPPORT: kernel supports zero-message opendir
0340  * FUSE_EXPLICIT_INVAL_DATA: only invalidate cached pages on explicit request
0341  * FUSE_MAP_ALIGNMENT: init_out.map_alignment contains log2(byte alignment) for
0342  *             foffset and moffset fields in struct
0343  *             fuse_setupmapping_out and fuse_removemapping_one.
0344  * FUSE_SUBMOUNTS: kernel supports auto-mounting directory submounts
0345  * FUSE_HANDLE_KILLPRIV_V2: fs kills suid/sgid/cap on write/chown/trunc.
0346  *          Upon write/truncate suid/sgid is only killed if caller
0347  *          does not have CAP_FSETID. Additionally upon
0348  *          write/truncate sgid is killed only if file has group
0349  *          execute permission. (Same as Linux VFS behavior).
0350  * FUSE_SETXATTR_EXT:   Server supports extended struct fuse_setxattr_in
0351  * FUSE_INIT_EXT: extended fuse_init_in request
0352  * FUSE_INIT_RESERVED: reserved, do not use
0353  * FUSE_SECURITY_CTX:   add security context to create, mkdir, symlink, and
0354  *          mknod
0355  * FUSE_HAS_INODE_DAX:  use per inode DAX
0356  */
0357 #define FUSE_ASYNC_READ     (1 << 0)
0358 #define FUSE_POSIX_LOCKS    (1 << 1)
0359 #define FUSE_FILE_OPS       (1 << 2)
0360 #define FUSE_ATOMIC_O_TRUNC (1 << 3)
0361 #define FUSE_EXPORT_SUPPORT (1 << 4)
0362 #define FUSE_BIG_WRITES     (1 << 5)
0363 #define FUSE_DONT_MASK      (1 << 6)
0364 #define FUSE_SPLICE_WRITE   (1 << 7)
0365 #define FUSE_SPLICE_MOVE    (1 << 8)
0366 #define FUSE_SPLICE_READ    (1 << 9)
0367 #define FUSE_FLOCK_LOCKS    (1 << 10)
0368 #define FUSE_HAS_IOCTL_DIR  (1 << 11)
0369 #define FUSE_AUTO_INVAL_DATA    (1 << 12)
0370 #define FUSE_DO_READDIRPLUS (1 << 13)
0371 #define FUSE_READDIRPLUS_AUTO   (1 << 14)
0372 #define FUSE_ASYNC_DIO      (1 << 15)
0373 #define FUSE_WRITEBACK_CACHE    (1 << 16)
0374 #define FUSE_NO_OPEN_SUPPORT    (1 << 17)
0375 #define FUSE_PARALLEL_DIROPS    (1 << 18)
0376 #define FUSE_HANDLE_KILLPRIV    (1 << 19)
0377 #define FUSE_POSIX_ACL      (1 << 20)
0378 #define FUSE_ABORT_ERROR    (1 << 21)
0379 #define FUSE_MAX_PAGES      (1 << 22)
0380 #define FUSE_CACHE_SYMLINKS (1 << 23)
0381 #define FUSE_NO_OPENDIR_SUPPORT (1 << 24)
0382 #define FUSE_EXPLICIT_INVAL_DATA (1 << 25)
0383 #define FUSE_MAP_ALIGNMENT  (1 << 26)
0384 #define FUSE_SUBMOUNTS      (1 << 27)
0385 #define FUSE_HANDLE_KILLPRIV_V2 (1 << 28)
0386 #define FUSE_SETXATTR_EXT   (1 << 29)
0387 #define FUSE_INIT_EXT       (1 << 30)
0388 #define FUSE_INIT_RESERVED  (1 << 31)
0389 /* bits 32..63 get shifted down 32 bits into the flags2 field */
0390 #define FUSE_SECURITY_CTX   (1ULL << 32)
0391 #define FUSE_HAS_INODE_DAX  (1ULL << 33)
0392 
0393 /**
0394  * CUSE INIT request/reply flags
0395  *
0396  * CUSE_UNRESTRICTED_IOCTL:  use unrestricted ioctl
0397  */
0398 #define CUSE_UNRESTRICTED_IOCTL (1 << 0)
0399 
0400 /**
0401  * Release flags
0402  */
0403 #define FUSE_RELEASE_FLUSH  (1 << 0)
0404 #define FUSE_RELEASE_FLOCK_UNLOCK   (1 << 1)
0405 
0406 /**
0407  * Getattr flags
0408  */
0409 #define FUSE_GETATTR_FH     (1 << 0)
0410 
0411 /**
0412  * Lock flags
0413  */
0414 #define FUSE_LK_FLOCK       (1 << 0)
0415 
0416 /**
0417  * WRITE flags
0418  *
0419  * FUSE_WRITE_CACHE: delayed write from page cache, file handle is guessed
0420  * FUSE_WRITE_LOCKOWNER: lock_owner field is valid
0421  * FUSE_WRITE_KILL_SUIDGID: kill suid and sgid bits
0422  */
0423 #define FUSE_WRITE_CACHE    (1 << 0)
0424 #define FUSE_WRITE_LOCKOWNER    (1 << 1)
0425 #define FUSE_WRITE_KILL_SUIDGID (1 << 2)
0426 
0427 /* Obsolete alias; this flag implies killing suid/sgid only. */
0428 #define FUSE_WRITE_KILL_PRIV    FUSE_WRITE_KILL_SUIDGID
0429 
0430 /**
0431  * Read flags
0432  */
0433 #define FUSE_READ_LOCKOWNER (1 << 1)
0434 
0435 /**
0436  * Ioctl flags
0437  *
0438  * FUSE_IOCTL_COMPAT: 32bit compat ioctl on 64bit machine
0439  * FUSE_IOCTL_UNRESTRICTED: not restricted to well-formed ioctls, retry allowed
0440  * FUSE_IOCTL_RETRY: retry with new iovecs
0441  * FUSE_IOCTL_32BIT: 32bit ioctl
0442  * FUSE_IOCTL_DIR: is a directory
0443  * FUSE_IOCTL_COMPAT_X32: x32 compat ioctl on 64bit machine (64bit time_t)
0444  *
0445  * FUSE_IOCTL_MAX_IOV: maximum of in_iovecs + out_iovecs
0446  */
0447 #define FUSE_IOCTL_COMPAT   (1 << 0)
0448 #define FUSE_IOCTL_UNRESTRICTED (1 << 1)
0449 #define FUSE_IOCTL_RETRY    (1 << 2)
0450 #define FUSE_IOCTL_32BIT    (1 << 3)
0451 #define FUSE_IOCTL_DIR      (1 << 4)
0452 #define FUSE_IOCTL_COMPAT_X32   (1 << 5)
0453 
0454 #define FUSE_IOCTL_MAX_IOV  256
0455 
0456 /**
0457  * Poll flags
0458  *
0459  * FUSE_POLL_SCHEDULE_NOTIFY: request poll notify
0460  */
0461 #define FUSE_POLL_SCHEDULE_NOTIFY (1 << 0)
0462 
0463 /**
0464  * Fsync flags
0465  *
0466  * FUSE_FSYNC_FDATASYNC: Sync data only, not metadata
0467  */
0468 #define FUSE_FSYNC_FDATASYNC    (1 << 0)
0469 
0470 /**
0471  * fuse_attr flags
0472  *
0473  * FUSE_ATTR_SUBMOUNT: Object is a submount root
0474  * FUSE_ATTR_DAX: Enable DAX for this file in per inode DAX mode
0475  */
0476 #define FUSE_ATTR_SUBMOUNT      (1 << 0)
0477 #define FUSE_ATTR_DAX       (1 << 1)
0478 
0479 /**
0480  * Open flags
0481  * FUSE_OPEN_KILL_SUIDGID: Kill suid and sgid if executable
0482  */
0483 #define FUSE_OPEN_KILL_SUIDGID  (1 << 0)
0484 
0485 /**
0486  * setxattr flags
0487  * FUSE_SETXATTR_ACL_KILL_SGID: Clear SGID when system.posix_acl_access is set
0488  */
0489 #define FUSE_SETXATTR_ACL_KILL_SGID (1 << 0)
0490 
0491 enum fuse_opcode {
0492     FUSE_LOOKUP     = 1,
0493     FUSE_FORGET     = 2,  /* no reply */
0494     FUSE_GETATTR        = 3,
0495     FUSE_SETATTR        = 4,
0496     FUSE_READLINK       = 5,
0497     FUSE_SYMLINK        = 6,
0498     FUSE_MKNOD      = 8,
0499     FUSE_MKDIR      = 9,
0500     FUSE_UNLINK     = 10,
0501     FUSE_RMDIR      = 11,
0502     FUSE_RENAME     = 12,
0503     FUSE_LINK       = 13,
0504     FUSE_OPEN       = 14,
0505     FUSE_READ       = 15,
0506     FUSE_WRITE      = 16,
0507     FUSE_STATFS     = 17,
0508     FUSE_RELEASE        = 18,
0509     FUSE_FSYNC      = 20,
0510     FUSE_SETXATTR       = 21,
0511     FUSE_GETXATTR       = 22,
0512     FUSE_LISTXATTR      = 23,
0513     FUSE_REMOVEXATTR    = 24,
0514     FUSE_FLUSH      = 25,
0515     FUSE_INIT       = 26,
0516     FUSE_OPENDIR        = 27,
0517     FUSE_READDIR        = 28,
0518     FUSE_RELEASEDIR     = 29,
0519     FUSE_FSYNCDIR       = 30,
0520     FUSE_GETLK      = 31,
0521     FUSE_SETLK      = 32,
0522     FUSE_SETLKW     = 33,
0523     FUSE_ACCESS     = 34,
0524     FUSE_CREATE     = 35,
0525     FUSE_INTERRUPT      = 36,
0526     FUSE_BMAP       = 37,
0527     FUSE_DESTROY        = 38,
0528     FUSE_IOCTL      = 39,
0529     FUSE_POLL       = 40,
0530     FUSE_NOTIFY_REPLY   = 41,
0531     FUSE_BATCH_FORGET   = 42,
0532     FUSE_FALLOCATE      = 43,
0533     FUSE_READDIRPLUS    = 44,
0534     FUSE_RENAME2        = 45,
0535     FUSE_LSEEK      = 46,
0536     FUSE_COPY_FILE_RANGE    = 47,
0537     FUSE_SETUPMAPPING   = 48,
0538     FUSE_REMOVEMAPPING  = 49,
0539     FUSE_SYNCFS     = 50,
0540 
0541     /* CUSE specific operations */
0542     CUSE_INIT       = 4096,
0543 
0544     /* Reserved opcodes: helpful to detect structure endian-ness */
0545     CUSE_INIT_BSWAP_RESERVED    = 1048576,  /* CUSE_INIT << 8 */
0546     FUSE_INIT_BSWAP_RESERVED    = 436207616,    /* FUSE_INIT << 24 */
0547 };
0548 
0549 enum fuse_notify_code {
0550     FUSE_NOTIFY_POLL   = 1,
0551     FUSE_NOTIFY_INVAL_INODE = 2,
0552     FUSE_NOTIFY_INVAL_ENTRY = 3,
0553     FUSE_NOTIFY_STORE = 4,
0554     FUSE_NOTIFY_RETRIEVE = 5,
0555     FUSE_NOTIFY_DELETE = 6,
0556     FUSE_NOTIFY_CODE_MAX,
0557 };
0558 
0559 /* The read buffer is required to be at least 8k, but may be much larger */
0560 #define FUSE_MIN_READ_BUFFER 8192
0561 
0562 #define FUSE_COMPAT_ENTRY_OUT_SIZE 120
0563 
0564 struct fuse_entry_out {
0565     uint64_t    nodeid;     /* Inode ID */
0566     uint64_t    generation; /* Inode generation: nodeid:gen must
0567                        be unique for the fs's lifetime */
0568     uint64_t    entry_valid;    /* Cache timeout for the name */
0569     uint64_t    attr_valid; /* Cache timeout for the attributes */
0570     uint32_t    entry_valid_nsec;
0571     uint32_t    attr_valid_nsec;
0572     struct fuse_attr attr;
0573 };
0574 
0575 struct fuse_forget_in {
0576     uint64_t    nlookup;
0577 };
0578 
0579 struct fuse_forget_one {
0580     uint64_t    nodeid;
0581     uint64_t    nlookup;
0582 };
0583 
0584 struct fuse_batch_forget_in {
0585     uint32_t    count;
0586     uint32_t    dummy;
0587 };
0588 
0589 struct fuse_getattr_in {
0590     uint32_t    getattr_flags;
0591     uint32_t    dummy;
0592     uint64_t    fh;
0593 };
0594 
0595 #define FUSE_COMPAT_ATTR_OUT_SIZE 96
0596 
0597 struct fuse_attr_out {
0598     uint64_t    attr_valid; /* Cache timeout for the attributes */
0599     uint32_t    attr_valid_nsec;
0600     uint32_t    dummy;
0601     struct fuse_attr attr;
0602 };
0603 
0604 #define FUSE_COMPAT_MKNOD_IN_SIZE 8
0605 
0606 struct fuse_mknod_in {
0607     uint32_t    mode;
0608     uint32_t    rdev;
0609     uint32_t    umask;
0610     uint32_t    padding;
0611 };
0612 
0613 struct fuse_mkdir_in {
0614     uint32_t    mode;
0615     uint32_t    umask;
0616 };
0617 
0618 struct fuse_rename_in {
0619     uint64_t    newdir;
0620 };
0621 
0622 struct fuse_rename2_in {
0623     uint64_t    newdir;
0624     uint32_t    flags;
0625     uint32_t    padding;
0626 };
0627 
0628 struct fuse_link_in {
0629     uint64_t    oldnodeid;
0630 };
0631 
0632 struct fuse_setattr_in {
0633     uint32_t    valid;
0634     uint32_t    padding;
0635     uint64_t    fh;
0636     uint64_t    size;
0637     uint64_t    lock_owner;
0638     uint64_t    atime;
0639     uint64_t    mtime;
0640     uint64_t    ctime;
0641     uint32_t    atimensec;
0642     uint32_t    mtimensec;
0643     uint32_t    ctimensec;
0644     uint32_t    mode;
0645     uint32_t    unused4;
0646     uint32_t    uid;
0647     uint32_t    gid;
0648     uint32_t    unused5;
0649 };
0650 
0651 struct fuse_open_in {
0652     uint32_t    flags;
0653     uint32_t    open_flags; /* FUSE_OPEN_... */
0654 };
0655 
0656 struct fuse_create_in {
0657     uint32_t    flags;
0658     uint32_t    mode;
0659     uint32_t    umask;
0660     uint32_t    open_flags; /* FUSE_OPEN_... */
0661 };
0662 
0663 struct fuse_open_out {
0664     uint64_t    fh;
0665     uint32_t    open_flags;
0666     uint32_t    padding;
0667 };
0668 
0669 struct fuse_release_in {
0670     uint64_t    fh;
0671     uint32_t    flags;
0672     uint32_t    release_flags;
0673     uint64_t    lock_owner;
0674 };
0675 
0676 struct fuse_flush_in {
0677     uint64_t    fh;
0678     uint32_t    unused;
0679     uint32_t    padding;
0680     uint64_t    lock_owner;
0681 };
0682 
0683 struct fuse_read_in {
0684     uint64_t    fh;
0685     uint64_t    offset;
0686     uint32_t    size;
0687     uint32_t    read_flags;
0688     uint64_t    lock_owner;
0689     uint32_t    flags;
0690     uint32_t    padding;
0691 };
0692 
0693 #define FUSE_COMPAT_WRITE_IN_SIZE 24
0694 
0695 struct fuse_write_in {
0696     uint64_t    fh;
0697     uint64_t    offset;
0698     uint32_t    size;
0699     uint32_t    write_flags;
0700     uint64_t    lock_owner;
0701     uint32_t    flags;
0702     uint32_t    padding;
0703 };
0704 
0705 struct fuse_write_out {
0706     uint32_t    size;
0707     uint32_t    padding;
0708 };
0709 
0710 #define FUSE_COMPAT_STATFS_SIZE 48
0711 
0712 struct fuse_statfs_out {
0713     struct fuse_kstatfs st;
0714 };
0715 
0716 struct fuse_fsync_in {
0717     uint64_t    fh;
0718     uint32_t    fsync_flags;
0719     uint32_t    padding;
0720 };
0721 
0722 #define FUSE_COMPAT_SETXATTR_IN_SIZE 8
0723 
0724 struct fuse_setxattr_in {
0725     uint32_t    size;
0726     uint32_t    flags;
0727     uint32_t    setxattr_flags;
0728     uint32_t    padding;
0729 };
0730 
0731 struct fuse_getxattr_in {
0732     uint32_t    size;
0733     uint32_t    padding;
0734 };
0735 
0736 struct fuse_getxattr_out {
0737     uint32_t    size;
0738     uint32_t    padding;
0739 };
0740 
0741 struct fuse_lk_in {
0742     uint64_t    fh;
0743     uint64_t    owner;
0744     struct fuse_file_lock lk;
0745     uint32_t    lk_flags;
0746     uint32_t    padding;
0747 };
0748 
0749 struct fuse_lk_out {
0750     struct fuse_file_lock lk;
0751 };
0752 
0753 struct fuse_access_in {
0754     uint32_t    mask;
0755     uint32_t    padding;
0756 };
0757 
0758 struct fuse_init_in {
0759     uint32_t    major;
0760     uint32_t    minor;
0761     uint32_t    max_readahead;
0762     uint32_t    flags;
0763     uint32_t    flags2;
0764     uint32_t    unused[11];
0765 };
0766 
0767 #define FUSE_COMPAT_INIT_OUT_SIZE 8
0768 #define FUSE_COMPAT_22_INIT_OUT_SIZE 24
0769 
0770 struct fuse_init_out {
0771     uint32_t    major;
0772     uint32_t    minor;
0773     uint32_t    max_readahead;
0774     uint32_t    flags;
0775     uint16_t    max_background;
0776     uint16_t    congestion_threshold;
0777     uint32_t    max_write;
0778     uint32_t    time_gran;
0779     uint16_t    max_pages;
0780     uint16_t    map_alignment;
0781     uint32_t    flags2;
0782     uint32_t    unused[7];
0783 };
0784 
0785 #define CUSE_INIT_INFO_MAX 4096
0786 
0787 struct cuse_init_in {
0788     uint32_t    major;
0789     uint32_t    minor;
0790     uint32_t    unused;
0791     uint32_t    flags;
0792 };
0793 
0794 struct cuse_init_out {
0795     uint32_t    major;
0796     uint32_t    minor;
0797     uint32_t    unused;
0798     uint32_t    flags;
0799     uint32_t    max_read;
0800     uint32_t    max_write;
0801     uint32_t    dev_major;      /* chardev major */
0802     uint32_t    dev_minor;      /* chardev minor */
0803     uint32_t    spare[10];
0804 };
0805 
0806 struct fuse_interrupt_in {
0807     uint64_t    unique;
0808 };
0809 
0810 struct fuse_bmap_in {
0811     uint64_t    block;
0812     uint32_t    blocksize;
0813     uint32_t    padding;
0814 };
0815 
0816 struct fuse_bmap_out {
0817     uint64_t    block;
0818 };
0819 
0820 struct fuse_ioctl_in {
0821     uint64_t    fh;
0822     uint32_t    flags;
0823     uint32_t    cmd;
0824     uint64_t    arg;
0825     uint32_t    in_size;
0826     uint32_t    out_size;
0827 };
0828 
0829 struct fuse_ioctl_iovec {
0830     uint64_t    base;
0831     uint64_t    len;
0832 };
0833 
0834 struct fuse_ioctl_out {
0835     int32_t     result;
0836     uint32_t    flags;
0837     uint32_t    in_iovs;
0838     uint32_t    out_iovs;
0839 };
0840 
0841 struct fuse_poll_in {
0842     uint64_t    fh;
0843     uint64_t    kh;
0844     uint32_t    flags;
0845     uint32_t    events;
0846 };
0847 
0848 struct fuse_poll_out {
0849     uint32_t    revents;
0850     uint32_t    padding;
0851 };
0852 
0853 struct fuse_notify_poll_wakeup_out {
0854     uint64_t    kh;
0855 };
0856 
0857 struct fuse_fallocate_in {
0858     uint64_t    fh;
0859     uint64_t    offset;
0860     uint64_t    length;
0861     uint32_t    mode;
0862     uint32_t    padding;
0863 };
0864 
0865 struct fuse_in_header {
0866     uint32_t    len;
0867     uint32_t    opcode;
0868     uint64_t    unique;
0869     uint64_t    nodeid;
0870     uint32_t    uid;
0871     uint32_t    gid;
0872     uint32_t    pid;
0873     uint32_t    padding;
0874 };
0875 
0876 struct fuse_out_header {
0877     uint32_t    len;
0878     int32_t     error;
0879     uint64_t    unique;
0880 };
0881 
0882 struct fuse_dirent {
0883     uint64_t    ino;
0884     uint64_t    off;
0885     uint32_t    namelen;
0886     uint32_t    type;
0887     char name[];
0888 };
0889 
0890 /* Align variable length records to 64bit boundary */
0891 #define FUSE_REC_ALIGN(x) \
0892     (((x) + sizeof(uint64_t) - 1) & ~(sizeof(uint64_t) - 1))
0893 
0894 #define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name)
0895 #define FUSE_DIRENT_ALIGN(x) FUSE_REC_ALIGN(x)
0896 #define FUSE_DIRENT_SIZE(d) \
0897     FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)
0898 
0899 struct fuse_direntplus {
0900     struct fuse_entry_out entry_out;
0901     struct fuse_dirent dirent;
0902 };
0903 
0904 #define FUSE_NAME_OFFSET_DIRENTPLUS \
0905     offsetof(struct fuse_direntplus, dirent.name)
0906 #define FUSE_DIRENTPLUS_SIZE(d) \
0907     FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET_DIRENTPLUS + (d)->dirent.namelen)
0908 
0909 struct fuse_notify_inval_inode_out {
0910     uint64_t    ino;
0911     int64_t     off;
0912     int64_t     len;
0913 };
0914 
0915 struct fuse_notify_inval_entry_out {
0916     uint64_t    parent;
0917     uint32_t    namelen;
0918     uint32_t    padding;
0919 };
0920 
0921 struct fuse_notify_delete_out {
0922     uint64_t    parent;
0923     uint64_t    child;
0924     uint32_t    namelen;
0925     uint32_t    padding;
0926 };
0927 
0928 struct fuse_notify_store_out {
0929     uint64_t    nodeid;
0930     uint64_t    offset;
0931     uint32_t    size;
0932     uint32_t    padding;
0933 };
0934 
0935 struct fuse_notify_retrieve_out {
0936     uint64_t    notify_unique;
0937     uint64_t    nodeid;
0938     uint64_t    offset;
0939     uint32_t    size;
0940     uint32_t    padding;
0941 };
0942 
0943 /* Matches the size of fuse_write_in */
0944 struct fuse_notify_retrieve_in {
0945     uint64_t    dummy1;
0946     uint64_t    offset;
0947     uint32_t    size;
0948     uint32_t    dummy2;
0949     uint64_t    dummy3;
0950     uint64_t    dummy4;
0951 };
0952 
0953 /* Device ioctls: */
0954 #define FUSE_DEV_IOC_MAGIC      229
0955 #define FUSE_DEV_IOC_CLONE      _IOR(FUSE_DEV_IOC_MAGIC, 0, uint32_t)
0956 
0957 struct fuse_lseek_in {
0958     uint64_t    fh;
0959     uint64_t    offset;
0960     uint32_t    whence;
0961     uint32_t    padding;
0962 };
0963 
0964 struct fuse_lseek_out {
0965     uint64_t    offset;
0966 };
0967 
0968 struct fuse_copy_file_range_in {
0969     uint64_t    fh_in;
0970     uint64_t    off_in;
0971     uint64_t    nodeid_out;
0972     uint64_t    fh_out;
0973     uint64_t    off_out;
0974     uint64_t    len;
0975     uint64_t    flags;
0976 };
0977 
0978 #define FUSE_SETUPMAPPING_FLAG_WRITE (1ull << 0)
0979 #define FUSE_SETUPMAPPING_FLAG_READ (1ull << 1)
0980 struct fuse_setupmapping_in {
0981     /* An already open handle */
0982     uint64_t    fh;
0983     /* Offset into the file to start the mapping */
0984     uint64_t    foffset;
0985     /* Length of mapping required */
0986     uint64_t    len;
0987     /* Flags, FUSE_SETUPMAPPING_FLAG_* */
0988     uint64_t    flags;
0989     /* Offset in Memory Window */
0990     uint64_t    moffset;
0991 };
0992 
0993 struct fuse_removemapping_in {
0994     /* number of fuse_removemapping_one follows */
0995     uint32_t        count;
0996 };
0997 
0998 struct fuse_removemapping_one {
0999     /* Offset into the dax window start the unmapping */
1000     uint64_t        moffset;
1001     /* Length of mapping required */
1002     uint64_t    len;
1003 };
1004 
1005 #define FUSE_REMOVEMAPPING_MAX_ENTRY   \
1006         (PAGE_SIZE / sizeof(struct fuse_removemapping_one))
1007 
1008 struct fuse_syncfs_in {
1009     uint64_t    padding;
1010 };
1011 
1012 /*
1013  * For each security context, send fuse_secctx with size of security context
1014  * fuse_secctx will be followed by security context name and this in turn
1015  * will be followed by actual context label.
1016  * fuse_secctx, name, context
1017  */
1018 struct fuse_secctx {
1019     uint32_t    size;
1020     uint32_t    padding;
1021 };
1022 
1023 /*
1024  * Contains the information about how many fuse_secctx structures are being
1025  * sent and what's the total size of all security contexts (including
1026  * size of fuse_secctx_header).
1027  *
1028  */
1029 struct fuse_secctx_header {
1030     uint32_t    size;
1031     uint32_t    nr_secctx;
1032 };
1033 
1034 #endif /* _LINUX_FUSE_H */