151369649SPedro F. Giffuni /*-- 25fe58019SAttilio Rao * This file defines the kernel interface of FUSE 39c62bc70SAlan Somers * Copyright (C) 2001-2008 Miklos Szeredi <miklos@szeredi.hu> 45fe58019SAttilio Rao * 55fe58019SAttilio Rao * This program can be distributed under the terms of the GNU GPL. 65fe58019SAttilio Rao * See the file COPYING. 75fe58019SAttilio Rao * 85fe58019SAttilio Rao * This -- and only this -- header file may also be distributed under 95fe58019SAttilio Rao * the terms of the BSD Licence as follows: 105fe58019SAttilio Rao * 115fe58019SAttilio Rao * Copyright (C) 2001-2007 Miklos Szeredi. All rights reserved. 125fe58019SAttilio Rao * 135fe58019SAttilio Rao * Redistribution and use in source and binary forms, with or without 145fe58019SAttilio Rao * modification, are permitted provided that the following conditions 155fe58019SAttilio Rao * are met: 165fe58019SAttilio Rao * 1. Redistributions of source code must retain the above copyright 175fe58019SAttilio Rao * notice, this list of conditions and the following disclaimer. 185fe58019SAttilio Rao * 2. Redistributions in binary form must reproduce the above copyright 195fe58019SAttilio Rao * notice, this list of conditions and the following disclaimer in the 205fe58019SAttilio Rao * documentation and/or other materials provided with the distribution. 215fe58019SAttilio Rao * 225fe58019SAttilio Rao * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 235fe58019SAttilio Rao * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 245fe58019SAttilio Rao * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 255fe58019SAttilio Rao * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 265fe58019SAttilio Rao * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 275fe58019SAttilio Rao * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 285fe58019SAttilio Rao * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 295fe58019SAttilio Rao * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 305fe58019SAttilio Rao * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 315fe58019SAttilio Rao * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 325fe58019SAttilio Rao * SUCH DAMAGE. 335fe58019SAttilio Rao * 345fe58019SAttilio Rao * $FreeBSD$ 355fe58019SAttilio Rao */ 365fe58019SAttilio Rao 3716bd2d47SAlan Somers /* 3816bd2d47SAlan Somers * This file defines the kernel interface of FUSE 3916bd2d47SAlan Somers * 4016bd2d47SAlan Somers * Protocol changelog: 4116bd2d47SAlan Somers * 4216bd2d47SAlan Somers * 7.9: 4316bd2d47SAlan Somers * - new fuse_getattr_in input argument of GETATTR 4416bd2d47SAlan Somers * - add lk_flags in fuse_lk_in 4516bd2d47SAlan Somers * - add lock_owner field to fuse_setattr_in, fuse_read_in and fuse_write_in 4616bd2d47SAlan Somers * - add blksize field to fuse_attr 4716bd2d47SAlan Somers * - add file flags field to fuse_read_in and fuse_write_in 483f105d16SAlan Somers * 493f105d16SAlan Somers * 7.10 503f105d16SAlan Somers * - add nonseekable open flag 519c62bc70SAlan Somers * 529c62bc70SAlan Somers * 7.11 539c62bc70SAlan Somers * - add IOCTL message 549c62bc70SAlan Somers * - add unsolicited notification support 55a4856c96SAlan Somers * 56a4856c96SAlan Somers * 7.12 57a4856c96SAlan Somers * - add umask flag to input argument of open, mknod and mkdir 58a4856c96SAlan Somers * - add notification messages for invalidation of inodes and 59a4856c96SAlan Somers * directory entries 602ffddc5eSAlan Somers * 612ffddc5eSAlan Somers * 7.13 622ffddc5eSAlan Somers * - make max number of background requests and congestion threshold 632ffddc5eSAlan Somers * tunables 64bb23d439SAlan Somers * 65bb23d439SAlan Somers * 7.14 66bb23d439SAlan Somers * - add splice support to fuse device 677cbb8e8aSAlan Somers * 687cbb8e8aSAlan Somers * 7.15 697cbb8e8aSAlan Somers * - add store notify 707cbb8e8aSAlan Somers * - add retrieve notify 71b160acd1SAlan Somers * 72b160acd1SAlan Somers * 7.16 73b160acd1SAlan Somers * - add BATCH_FORGET request 74b160acd1SAlan Somers * - FUSE_IOCTL_UNRESTRICTED shall now return with array of 'struct 75b160acd1SAlan Somers * fuse_ioctl_iovec' instead of ambiguous 'struct iovec' 76b160acd1SAlan Somers * - add FUSE_IOCTL_32BIT flag 77b160acd1SAlan Somers * 78b160acd1SAlan Somers * 7.17 79b160acd1SAlan Somers * - add FUSE_FLOCK_LOCKS and FUSE_RELEASE_FLOCK_UNLOCK 80b160acd1SAlan Somers * 81b160acd1SAlan Somers * 7.18 82b160acd1SAlan Somers * - add FUSE_IOCTL_DIR flag 83b160acd1SAlan Somers * - add FUSE_NOTIFY_DELETE 84b160acd1SAlan Somers * 85b160acd1SAlan Somers * 7.19 86b160acd1SAlan Somers * - add FUSE_FALLOCATE 87b160acd1SAlan Somers * 88b160acd1SAlan Somers * 7.20 89b160acd1SAlan Somers * - add FUSE_AUTO_INVAL_DATA 90b160acd1SAlan Somers * 7.21 91b160acd1SAlan Somers * - add FUSE_READDIRPLUS 92b160acd1SAlan Somers * - send the requested events in POLL request 93*87ff949aSAlan Somers * 94*87ff949aSAlan Somers * 7.22 95*87ff949aSAlan Somers * - add FUSE_ASYNC_DIO 96*87ff949aSAlan Somers * 97*87ff949aSAlan Somers * 7.23 98*87ff949aSAlan Somers * - add FUSE_WRITEBACK_CACHE 99*87ff949aSAlan Somers * - add time_gran to fuse_init_out 100*87ff949aSAlan Somers * - add reserved space to fuse_init_out 101*87ff949aSAlan Somers * - add FATTR_CTIME 102*87ff949aSAlan Somers * - add ctime and ctimensec to fuse_setattr_in 103*87ff949aSAlan Somers * - add FUSE_RENAME2 request 104*87ff949aSAlan Somers * - add FUSE_NO_OPEN_SUPPORT flag 10516bd2d47SAlan Somers */ 10616bd2d47SAlan Somers 10716bd2d47SAlan Somers #ifndef _FUSE_FUSE_KERNEL_H 10816bd2d47SAlan Somers #define _FUSE_FUSE_KERNEL_H 10916bd2d47SAlan Somers 110b160acd1SAlan Somers #ifdef __linux__ 111b160acd1SAlan Somers #include <linux/types.h> 112b160acd1SAlan Somers #else 1135fe58019SAttilio Rao #include <sys/types.h> 1145fe58019SAttilio Rao #endif 1155fe58019SAttilio Rao 1165fe58019SAttilio Rao /** Version number of this interface */ 1175fe58019SAttilio Rao #define FUSE_KERNEL_VERSION 7 1185fe58019SAttilio Rao 1195fe58019SAttilio Rao /** Minor version number of this interface */ 120*87ff949aSAlan Somers #define FUSE_KERNEL_MINOR_VERSION 23 1215fe58019SAttilio Rao 1225fe58019SAttilio Rao /** The node ID of the root inode */ 1235fe58019SAttilio Rao #define FUSE_ROOT_ID 1 1245fe58019SAttilio Rao 1255fe58019SAttilio Rao /* Make sure all structures are padded to 64bit boundary, so 32bit 1265fe58019SAttilio Rao userspace works under 64bit kernels */ 1275fe58019SAttilio Rao 1285fe58019SAttilio Rao struct fuse_attr { 1298f9b3ba7SAlan Somers uint64_t ino; 1308f9b3ba7SAlan Somers uint64_t size; 1318f9b3ba7SAlan Somers uint64_t blocks; 1328f9b3ba7SAlan Somers uint64_t atime; 1338f9b3ba7SAlan Somers uint64_t mtime; 1348f9b3ba7SAlan Somers uint64_t ctime; 1358f9b3ba7SAlan Somers uint32_t atimensec; 1368f9b3ba7SAlan Somers uint32_t mtimensec; 1378f9b3ba7SAlan Somers uint32_t ctimensec; 1388f9b3ba7SAlan Somers uint32_t mode; 1398f9b3ba7SAlan Somers uint32_t nlink; 1408f9b3ba7SAlan Somers uint32_t uid; 1418f9b3ba7SAlan Somers uint32_t gid; 1428f9b3ba7SAlan Somers uint32_t rdev; 1438f9b3ba7SAlan Somers uint32_t blksize; 1448f9b3ba7SAlan Somers uint32_t padding; 1455fe58019SAttilio Rao }; 1465fe58019SAttilio Rao 1475fe58019SAttilio Rao struct fuse_kstatfs { 1488f9b3ba7SAlan Somers uint64_t blocks; 1498f9b3ba7SAlan Somers uint64_t bfree; 1508f9b3ba7SAlan Somers uint64_t bavail; 1518f9b3ba7SAlan Somers uint64_t files; 1528f9b3ba7SAlan Somers uint64_t ffree; 1538f9b3ba7SAlan Somers uint32_t bsize; 1548f9b3ba7SAlan Somers uint32_t namelen; 1558f9b3ba7SAlan Somers uint32_t frsize; 1568f9b3ba7SAlan Somers uint32_t padding; 1578f9b3ba7SAlan Somers uint32_t spare[6]; 1585fe58019SAttilio Rao }; 1595fe58019SAttilio Rao 1605fe58019SAttilio Rao struct fuse_file_lock { 1618f9b3ba7SAlan Somers uint64_t start; 1628f9b3ba7SAlan Somers uint64_t end; 1638f9b3ba7SAlan Somers uint32_t type; 1648f9b3ba7SAlan Somers uint32_t pid; /* tgid */ 1655fe58019SAttilio Rao }; 1665fe58019SAttilio Rao 1675fe58019SAttilio Rao /** 1685fe58019SAttilio Rao * Bitmasks for fuse_setattr_in.valid 1695fe58019SAttilio Rao */ 1705fe58019SAttilio Rao #define FATTR_MODE (1 << 0) 1715fe58019SAttilio Rao #define FATTR_UID (1 << 1) 1725fe58019SAttilio Rao #define FATTR_GID (1 << 2) 1735fe58019SAttilio Rao #define FATTR_SIZE (1 << 3) 1745fe58019SAttilio Rao #define FATTR_ATIME (1 << 4) 1755fe58019SAttilio Rao #define FATTR_MTIME (1 << 5) 1765fe58019SAttilio Rao #define FATTR_FH (1 << 6) 17716bd2d47SAlan Somers #define FATTR_ATIME_NOW (1 << 7) 17816bd2d47SAlan Somers #define FATTR_MTIME_NOW (1 << 8) 17916bd2d47SAlan Somers #define FATTR_LOCKOWNER (1 << 9) 180*87ff949aSAlan Somers #define FATTR_CTIME (1 << 10) 1815fe58019SAttilio Rao 1825fe58019SAttilio Rao /** 1835fe58019SAttilio Rao * Flags returned by the OPEN request 1845fe58019SAttilio Rao * 1855fe58019SAttilio Rao * FOPEN_DIRECT_IO: bypass page cache for this open file 1865fe58019SAttilio Rao * FOPEN_KEEP_CACHE: don't invalidate the data cache on open 1873f105d16SAlan Somers * FOPEN_NONSEEKABLE: the file is not seekable 1885fe58019SAttilio Rao */ 1895fe58019SAttilio Rao #define FOPEN_DIRECT_IO (1 << 0) 1905fe58019SAttilio Rao #define FOPEN_KEEP_CACHE (1 << 1) 1913f105d16SAlan Somers #define FOPEN_NONSEEKABLE (1 << 2) 1925fe58019SAttilio Rao 1935fe58019SAttilio Rao /** 1945fe58019SAttilio Rao * INIT request/reply flags 19516bd2d47SAlan Somers * 196b160acd1SAlan Somers * FUSE_ASYNC_READ: asynchronous read requests 197b160acd1SAlan Somers * FUSE_POSIX_LOCKS: remote locking for POSIX file locks 198b160acd1SAlan Somers * FUSE_FILE_OPS: kernel sends file handle for fstat, etc... (not yet supported) 199b160acd1SAlan Somers * FUSE_ATOMIC_O_TRUNC: handles the O_TRUNC open flag in the filesystem 20016bd2d47SAlan Somers * FUSE_EXPORT_SUPPORT: filesystem handles lookups of "." and ".." 201b160acd1SAlan Somers * FUSE_BIG_WRITES: filesystem can handle write size larger than 4kB 202a4856c96SAlan Somers * FUSE_DONT_MASK: don't apply umask to file mode on create operations 203b160acd1SAlan Somers * FUSE_SPLICE_WRITE: kernel supports splice write on the device 204b160acd1SAlan Somers * FUSE_SPLICE_MOVE: kernel supports splice move on the device 205b160acd1SAlan Somers * FUSE_SPLICE_READ: kernel supports splice read on the device 206b160acd1SAlan Somers * FUSE_FLOCK_LOCKS: remote locking for BSD style file locks 207b160acd1SAlan Somers * FUSE_HAS_IOCTL_DIR: kernel supports ioctl on directories 208b160acd1SAlan Somers * FUSE_AUTO_INVAL_DATA: automatically invalidate cached pages 209b160acd1SAlan Somers * FUSE_DO_READDIRPLUS: do READDIRPLUS (READDIR+LOOKUP in one) 210b160acd1SAlan Somers * FUSE_READDIRPLUS_AUTO: adaptive readdirplus 211*87ff949aSAlan Somers * FUSE_ASYNC_DIO: asynchronous direct I/O submission 212*87ff949aSAlan Somers * FUSE_WRITEBACK_CACHE: use writeback cache for buffered writes 213*87ff949aSAlan Somers * FUSE_NO_OPEN_SUPPORT: kernel supports zero-message opens 2145fe58019SAttilio Rao */ 2155fe58019SAttilio Rao #define FUSE_ASYNC_READ (1 << 0) 2165fe58019SAttilio Rao #define FUSE_POSIX_LOCKS (1 << 1) 21716bd2d47SAlan Somers #define FUSE_FILE_OPS (1 << 2) 21816bd2d47SAlan Somers #define FUSE_ATOMIC_O_TRUNC (1 << 3) 21916bd2d47SAlan Somers #define FUSE_EXPORT_SUPPORT (1 << 4) 22016bd2d47SAlan Somers #define FUSE_BIG_WRITES (1 << 5) 221a4856c96SAlan Somers #define FUSE_DONT_MASK (1 << 6) 222b160acd1SAlan Somers #define FUSE_SPLICE_WRITE (1 << 7) 223b160acd1SAlan Somers #define FUSE_SPLICE_MOVE (1 << 8) 224b160acd1SAlan Somers #define FUSE_SPLICE_READ (1 << 9) 225b160acd1SAlan Somers #define FUSE_FLOCK_LOCKS (1 << 10) 226b160acd1SAlan Somers #define FUSE_HAS_IOCTL_DIR (1 << 11) 227b160acd1SAlan Somers #define FUSE_AUTO_INVAL_DATA (1 << 12) 228b160acd1SAlan Somers #define FUSE_DO_READDIRPLUS (1 << 13) 229b160acd1SAlan Somers #define FUSE_READDIRPLUS_AUTO (1 << 14) 230*87ff949aSAlan Somers #define FUSE_ASYNC_DIO (1 << 15) 231*87ff949aSAlan Somers #define FUSE_WRITEBACK_CACHE (1 << 16) 232*87ff949aSAlan Somers #define FUSE_NO_OPEN_SUPPORT (1 << 17) 2335fe58019SAttilio Rao 2349c62bc70SAlan Somers #ifdef linux 2359c62bc70SAlan Somers /** 2369c62bc70SAlan Somers * CUSE INIT request/reply flags 2379c62bc70SAlan Somers * 2389c62bc70SAlan Somers * CUSE_UNRESTRICTED_IOCTL: use unrestricted ioctl 2399c62bc70SAlan Somers */ 2409c62bc70SAlan Somers #define CUSE_UNRESTRICTED_IOCTL (1 << 0) 2419c62bc70SAlan Somers #endif /* linux */ 2429c62bc70SAlan Somers 2435fe58019SAttilio Rao /** 2445fe58019SAttilio Rao * Release flags 2455fe58019SAttilio Rao */ 2465fe58019SAttilio Rao #define FUSE_RELEASE_FLUSH (1 << 0) 247b160acd1SAlan Somers #define FUSE_RELEASE_FLOCK_UNLOCK (1 << 1) 2485fe58019SAttilio Rao 24916bd2d47SAlan Somers /** 25016bd2d47SAlan Somers * Getattr flags 25116bd2d47SAlan Somers */ 25216bd2d47SAlan Somers #define FUSE_GETATTR_FH (1 << 0) 25316bd2d47SAlan Somers 25416bd2d47SAlan Somers /** 25516bd2d47SAlan Somers * Lock flags 25616bd2d47SAlan Somers */ 25716bd2d47SAlan Somers #define FUSE_LK_FLOCK (1 << 0) 25816bd2d47SAlan Somers 25916bd2d47SAlan Somers /** 26016bd2d47SAlan Somers * WRITE flags 26116bd2d47SAlan Somers * 26216bd2d47SAlan Somers * FUSE_WRITE_CACHE: delayed write from page cache, file handle is guessed 26316bd2d47SAlan Somers * FUSE_WRITE_LOCKOWNER: lock_owner field is valid 26416bd2d47SAlan Somers */ 26516bd2d47SAlan Somers #define FUSE_WRITE_CACHE (1 << 0) 26616bd2d47SAlan Somers #define FUSE_WRITE_LOCKOWNER (1 << 1) 26716bd2d47SAlan Somers 26816bd2d47SAlan Somers /** 26916bd2d47SAlan Somers * Read flags 27016bd2d47SAlan Somers */ 27116bd2d47SAlan Somers #define FUSE_READ_LOCKOWNER (1 << 1) 27216bd2d47SAlan Somers 2739c62bc70SAlan Somers /** 2749c62bc70SAlan Somers * Ioctl flags 2759c62bc70SAlan Somers * 2769c62bc70SAlan Somers * FUSE_IOCTL_COMPAT: 32bit compat ioctl on 64bit machine 2779c62bc70SAlan Somers * FUSE_IOCTL_UNRESTRICTED: not restricted to well-formed ioctls, retry allowed 2789c62bc70SAlan Somers * FUSE_IOCTL_RETRY: retry with new iovecs 279b160acd1SAlan Somers * FUSE_IOCTL_32BIT: 32bit ioctl 280b160acd1SAlan Somers * FUSE_IOCTL_DIR: is a directory 2819c62bc70SAlan Somers * 2829c62bc70SAlan Somers * FUSE_IOCTL_MAX_IOV: maximum of in_iovecs + out_iovecs 2839c62bc70SAlan Somers */ 2849c62bc70SAlan Somers #define FUSE_IOCTL_COMPAT (1 << 0) 2859c62bc70SAlan Somers #define FUSE_IOCTL_UNRESTRICTED (1 << 1) 2869c62bc70SAlan Somers #define FUSE_IOCTL_RETRY (1 << 2) 287b160acd1SAlan Somers #define FUSE_IOCTL_32BIT (1 << 3) 288b160acd1SAlan Somers #define FUSE_IOCTL_DIR (1 << 4) 2899c62bc70SAlan Somers 2909c62bc70SAlan Somers #define FUSE_IOCTL_MAX_IOV 256 2919c62bc70SAlan Somers 2929c62bc70SAlan Somers /** 2939c62bc70SAlan Somers * Poll flags 2949c62bc70SAlan Somers * 2959c62bc70SAlan Somers * FUSE_POLL_SCHEDULE_NOTIFY: request poll notify 2969c62bc70SAlan Somers */ 2979c62bc70SAlan Somers #define FUSE_POLL_SCHEDULE_NOTIFY (1 << 0) 2989c62bc70SAlan Somers 2995fe58019SAttilio Rao enum fuse_opcode { 3005fe58019SAttilio Rao FUSE_LOOKUP = 1, 3015fe58019SAttilio Rao FUSE_FORGET = 2, /* no reply */ 3025fe58019SAttilio Rao FUSE_GETATTR = 3, 3035fe58019SAttilio Rao FUSE_SETATTR = 4, 3045fe58019SAttilio Rao FUSE_READLINK = 5, 3055fe58019SAttilio Rao FUSE_SYMLINK = 6, 3065fe58019SAttilio Rao FUSE_MKNOD = 8, 3075fe58019SAttilio Rao FUSE_MKDIR = 9, 3085fe58019SAttilio Rao FUSE_UNLINK = 10, 3095fe58019SAttilio Rao FUSE_RMDIR = 11, 3105fe58019SAttilio Rao FUSE_RENAME = 12, 3115fe58019SAttilio Rao FUSE_LINK = 13, 3125fe58019SAttilio Rao FUSE_OPEN = 14, 3135fe58019SAttilio Rao FUSE_READ = 15, 3145fe58019SAttilio Rao FUSE_WRITE = 16, 3155fe58019SAttilio Rao FUSE_STATFS = 17, 3165fe58019SAttilio Rao FUSE_RELEASE = 18, 3175fe58019SAttilio Rao FUSE_FSYNC = 20, 3185fe58019SAttilio Rao FUSE_SETXATTR = 21, 3195fe58019SAttilio Rao FUSE_GETXATTR = 22, 3205fe58019SAttilio Rao FUSE_LISTXATTR = 23, 3215fe58019SAttilio Rao FUSE_REMOVEXATTR = 24, 3225fe58019SAttilio Rao FUSE_FLUSH = 25, 3235fe58019SAttilio Rao FUSE_INIT = 26, 3245fe58019SAttilio Rao FUSE_OPENDIR = 27, 3255fe58019SAttilio Rao FUSE_READDIR = 28, 3265fe58019SAttilio Rao FUSE_RELEASEDIR = 29, 3275fe58019SAttilio Rao FUSE_FSYNCDIR = 30, 3285fe58019SAttilio Rao FUSE_GETLK = 31, 3295fe58019SAttilio Rao FUSE_SETLK = 32, 3305fe58019SAttilio Rao FUSE_SETLKW = 33, 3315fe58019SAttilio Rao FUSE_ACCESS = 34, 3325fe58019SAttilio Rao FUSE_CREATE = 35, 3335fe58019SAttilio Rao FUSE_INTERRUPT = 36, 3345fe58019SAttilio Rao FUSE_BMAP = 37, 3355fe58019SAttilio Rao FUSE_DESTROY = 38, 3369c62bc70SAlan Somers FUSE_IOCTL = 39, 3379c62bc70SAlan Somers FUSE_POLL = 40, 3387cbb8e8aSAlan Somers FUSE_NOTIFY_REPLY = 41, 339b160acd1SAlan Somers FUSE_BATCH_FORGET = 42, 340b160acd1SAlan Somers FUSE_FALLOCATE = 43, 341b160acd1SAlan Somers FUSE_READDIRPLUS = 44, 342*87ff949aSAlan Somers FUSE_RENAME2 = 45, 3439c62bc70SAlan Somers 3449c62bc70SAlan Somers #ifdef linux 3459c62bc70SAlan Somers /* CUSE specific operations */ 3469c62bc70SAlan Somers CUSE_INIT = 4096, 3479c62bc70SAlan Somers #endif /* linux */ 3489c62bc70SAlan Somers }; 3499c62bc70SAlan Somers 3509c62bc70SAlan Somers enum fuse_notify_code { 3519c62bc70SAlan Somers FUSE_NOTIFY_POLL = 1, 352a4856c96SAlan Somers FUSE_NOTIFY_INVAL_INODE = 2, 353a4856c96SAlan Somers FUSE_NOTIFY_INVAL_ENTRY = 3, 3547cbb8e8aSAlan Somers FUSE_NOTIFY_STORE = 4, 3557cbb8e8aSAlan Somers FUSE_NOTIFY_RETRIEVE = 5, 356b160acd1SAlan Somers FUSE_NOTIFY_DELETE = 6, 3579c62bc70SAlan Somers FUSE_NOTIFY_CODE_MAX, 3585fe58019SAttilio Rao }; 3595fe58019SAttilio Rao 3605fe58019SAttilio Rao /* The read buffer is required to be at least 8k, but may be much larger */ 3615fe58019SAttilio Rao #define FUSE_MIN_READ_BUFFER 8192 3625fe58019SAttilio Rao 36316bd2d47SAlan Somers #define FUSE_COMPAT_ENTRY_OUT_SIZE 120 36416bd2d47SAlan Somers 3655fe58019SAttilio Rao struct fuse_entry_out { 3668f9b3ba7SAlan Somers uint64_t nodeid; /* Inode ID */ 3678f9b3ba7SAlan Somers uint64_t generation; /* Inode generation: nodeid:gen must 3685fe58019SAttilio Rao be unique for the fs's lifetime */ 3698f9b3ba7SAlan Somers uint64_t entry_valid; /* Cache timeout for the name */ 3708f9b3ba7SAlan Somers uint64_t attr_valid; /* Cache timeout for the attributes */ 3718f9b3ba7SAlan Somers uint32_t entry_valid_nsec; 3728f9b3ba7SAlan Somers uint32_t attr_valid_nsec; 3735fe58019SAttilio Rao struct fuse_attr attr; 3745fe58019SAttilio Rao }; 3755fe58019SAttilio Rao 3765fe58019SAttilio Rao struct fuse_forget_in { 3778f9b3ba7SAlan Somers uint64_t nlookup; 3785fe58019SAttilio Rao }; 3795fe58019SAttilio Rao 380b160acd1SAlan Somers struct fuse_forget_one { 3818f9b3ba7SAlan Somers uint64_t nodeid; 3828f9b3ba7SAlan Somers uint64_t nlookup; 383b160acd1SAlan Somers }; 384b160acd1SAlan Somers 385b160acd1SAlan Somers struct fuse_batch_forget_in { 3868f9b3ba7SAlan Somers uint32_t count; 3878f9b3ba7SAlan Somers uint32_t dummy; 388b160acd1SAlan Somers }; 389b160acd1SAlan Somers 39016bd2d47SAlan Somers struct fuse_getattr_in { 3918f9b3ba7SAlan Somers uint32_t getattr_flags; 3928f9b3ba7SAlan Somers uint32_t dummy; 3938f9b3ba7SAlan Somers uint64_t fh; 39416bd2d47SAlan Somers }; 39516bd2d47SAlan Somers 39616bd2d47SAlan Somers #define FUSE_COMPAT_ATTR_OUT_SIZE 96 39716bd2d47SAlan Somers 3985fe58019SAttilio Rao struct fuse_attr_out { 3998f9b3ba7SAlan Somers uint64_t attr_valid; /* Cache timeout for the attributes */ 4008f9b3ba7SAlan Somers uint32_t attr_valid_nsec; 4018f9b3ba7SAlan Somers uint32_t dummy; 4025fe58019SAttilio Rao struct fuse_attr attr; 4035fe58019SAttilio Rao }; 4045fe58019SAttilio Rao 405a4856c96SAlan Somers #define FUSE_COMPAT_MKNOD_IN_SIZE 8 406a4856c96SAlan Somers 4074cbb4f88SAlan Somers struct fuse_mknod_in { 4088f9b3ba7SAlan Somers uint32_t mode; 4098f9b3ba7SAlan Somers uint32_t rdev; 4108f9b3ba7SAlan Somers uint32_t umask; 4118f9b3ba7SAlan Somers uint32_t padding; 4124cbb4f88SAlan Somers }; 4134cbb4f88SAlan Somers 4145fe58019SAttilio Rao struct fuse_mkdir_in { 4158f9b3ba7SAlan Somers uint32_t mode; 4168f9b3ba7SAlan Somers uint32_t umask; 4175fe58019SAttilio Rao }; 4185fe58019SAttilio Rao 4195fe58019SAttilio Rao struct fuse_rename_in { 4208f9b3ba7SAlan Somers uint64_t newdir; 4215fe58019SAttilio Rao }; 4225fe58019SAttilio Rao 423*87ff949aSAlan Somers struct fuse_rename2_in { 424*87ff949aSAlan Somers uint64_t newdir; 425*87ff949aSAlan Somers uint32_t flags; 426*87ff949aSAlan Somers uint32_t padding; 427*87ff949aSAlan Somers }; 428*87ff949aSAlan Somers 4295fe58019SAttilio Rao struct fuse_link_in { 4308f9b3ba7SAlan Somers uint64_t oldnodeid; 4315fe58019SAttilio Rao }; 4325fe58019SAttilio Rao 4335fe58019SAttilio Rao struct fuse_setattr_in { 4348f9b3ba7SAlan Somers uint32_t valid; 4358f9b3ba7SAlan Somers uint32_t padding; 4368f9b3ba7SAlan Somers uint64_t fh; 4378f9b3ba7SAlan Somers uint64_t size; 4388f9b3ba7SAlan Somers uint64_t lock_owner; 4398f9b3ba7SAlan Somers uint64_t atime; 4408f9b3ba7SAlan Somers uint64_t mtime; 441*87ff949aSAlan Somers uint64_t ctime; 4428f9b3ba7SAlan Somers uint32_t atimensec; 4438f9b3ba7SAlan Somers uint32_t mtimensec; 444*87ff949aSAlan Somers uint32_t ctimensec; 4458f9b3ba7SAlan Somers uint32_t mode; 4468f9b3ba7SAlan Somers uint32_t unused4; 4478f9b3ba7SAlan Somers uint32_t uid; 4488f9b3ba7SAlan Somers uint32_t gid; 4498f9b3ba7SAlan Somers uint32_t unused5; 4505fe58019SAttilio Rao }; 4515fe58019SAttilio Rao 4525fe58019SAttilio Rao struct fuse_open_in { 4538f9b3ba7SAlan Somers uint32_t flags; 4548f9b3ba7SAlan Somers uint32_t unused; 455a4856c96SAlan Somers }; 456a4856c96SAlan Somers 457a4856c96SAlan Somers struct fuse_create_in { 4588f9b3ba7SAlan Somers uint32_t flags; 4598f9b3ba7SAlan Somers uint32_t mode; 4608f9b3ba7SAlan Somers uint32_t umask; 4618f9b3ba7SAlan Somers uint32_t padding; 4625fe58019SAttilio Rao }; 4635fe58019SAttilio Rao 4645fe58019SAttilio Rao struct fuse_open_out { 4658f9b3ba7SAlan Somers uint64_t fh; 4668f9b3ba7SAlan Somers uint32_t open_flags; 4678f9b3ba7SAlan Somers uint32_t padding; 4685fe58019SAttilio Rao }; 4695fe58019SAttilio Rao 4705fe58019SAttilio Rao struct fuse_release_in { 4718f9b3ba7SAlan Somers uint64_t fh; 4728f9b3ba7SAlan Somers uint32_t flags; 4738f9b3ba7SAlan Somers uint32_t release_flags; 4748f9b3ba7SAlan Somers uint64_t lock_owner; 4755fe58019SAttilio Rao }; 4765fe58019SAttilio Rao 4775fe58019SAttilio Rao struct fuse_flush_in { 4788f9b3ba7SAlan Somers uint64_t fh; 4798f9b3ba7SAlan Somers uint32_t unused; 4808f9b3ba7SAlan Somers uint32_t padding; 4818f9b3ba7SAlan Somers uint64_t lock_owner; 4825fe58019SAttilio Rao }; 4835fe58019SAttilio Rao 4845fe58019SAttilio Rao struct fuse_read_in { 4858f9b3ba7SAlan Somers uint64_t fh; 4868f9b3ba7SAlan Somers uint64_t offset; 4878f9b3ba7SAlan Somers uint32_t size; 4888f9b3ba7SAlan Somers uint32_t read_flags; 4898f9b3ba7SAlan Somers uint64_t lock_owner; 4908f9b3ba7SAlan Somers uint32_t flags; 4918f9b3ba7SAlan Somers uint32_t padding; 4925fe58019SAttilio Rao }; 4935fe58019SAttilio Rao 49416bd2d47SAlan Somers #define FUSE_COMPAT_WRITE_IN_SIZE 24 49516bd2d47SAlan Somers 4965fe58019SAttilio Rao struct fuse_write_in { 4978f9b3ba7SAlan Somers uint64_t fh; 4988f9b3ba7SAlan Somers uint64_t offset; 4998f9b3ba7SAlan Somers uint32_t size; 5008f9b3ba7SAlan Somers uint32_t write_flags; 5018f9b3ba7SAlan Somers uint64_t lock_owner; 5028f9b3ba7SAlan Somers uint32_t flags; 5038f9b3ba7SAlan Somers uint32_t padding; 5045fe58019SAttilio Rao }; 5055fe58019SAttilio Rao 5065fe58019SAttilio Rao struct fuse_write_out { 5078f9b3ba7SAlan Somers uint32_t size; 5088f9b3ba7SAlan Somers uint32_t padding; 5095fe58019SAttilio Rao }; 5105fe58019SAttilio Rao 5115fe58019SAttilio Rao #define FUSE_COMPAT_STATFS_SIZE 48 5125fe58019SAttilio Rao 5135fe58019SAttilio Rao struct fuse_statfs_out { 5145fe58019SAttilio Rao struct fuse_kstatfs st; 5155fe58019SAttilio Rao }; 5165fe58019SAttilio Rao 5175fe58019SAttilio Rao struct fuse_fsync_in { 5188f9b3ba7SAlan Somers uint64_t fh; 5198f9b3ba7SAlan Somers uint32_t fsync_flags; 5208f9b3ba7SAlan Somers uint32_t padding; 5215fe58019SAttilio Rao }; 5225fe58019SAttilio Rao 52396192dfcSAlan Somers struct fuse_setxattr_in { 5248f9b3ba7SAlan Somers uint32_t size; 5258f9b3ba7SAlan Somers uint32_t flags; 526493b4a8cSFedor Uporov }; 527493b4a8cSFedor Uporov 52896192dfcSAlan Somers struct fuse_listxattr_in { 5298f9b3ba7SAlan Somers uint32_t size; 5308f9b3ba7SAlan Somers uint32_t padding; 53196192dfcSAlan Somers }; 53296192dfcSAlan Somers 533493b4a8cSFedor Uporov struct fuse_listxattr_out { 5348f9b3ba7SAlan Somers uint32_t size; 5358f9b3ba7SAlan Somers uint32_t padding; 5365fe58019SAttilio Rao }; 5375fe58019SAttilio Rao 5385fe58019SAttilio Rao struct fuse_getxattr_in { 5398f9b3ba7SAlan Somers uint32_t size; 5408f9b3ba7SAlan Somers uint32_t padding; 5415fe58019SAttilio Rao }; 5425fe58019SAttilio Rao 5435fe58019SAttilio Rao struct fuse_getxattr_out { 5448f9b3ba7SAlan Somers uint32_t size; 5458f9b3ba7SAlan Somers uint32_t padding; 5465fe58019SAttilio Rao }; 5475fe58019SAttilio Rao 5485fe58019SAttilio Rao struct fuse_lk_in { 5498f9b3ba7SAlan Somers uint64_t fh; 5508f9b3ba7SAlan Somers uint64_t owner; 5515fe58019SAttilio Rao struct fuse_file_lock lk; 5528f9b3ba7SAlan Somers uint32_t lk_flags; 5538f9b3ba7SAlan Somers uint32_t padding; 5545fe58019SAttilio Rao }; 5555fe58019SAttilio Rao 5565fe58019SAttilio Rao struct fuse_lk_out { 5575fe58019SAttilio Rao struct fuse_file_lock lk; 5585fe58019SAttilio Rao }; 5595fe58019SAttilio Rao 5605fe58019SAttilio Rao struct fuse_access_in { 5618f9b3ba7SAlan Somers uint32_t mask; 5628f9b3ba7SAlan Somers uint32_t padding; 5635fe58019SAttilio Rao }; 5645fe58019SAttilio Rao 5655fe58019SAttilio Rao struct fuse_init_in { 5668f9b3ba7SAlan Somers uint32_t major; 5678f9b3ba7SAlan Somers uint32_t minor; 5688f9b3ba7SAlan Somers uint32_t max_readahead; 5698f9b3ba7SAlan Somers uint32_t flags; 5705fe58019SAttilio Rao }; 5715fe58019SAttilio Rao 572*87ff949aSAlan Somers #define FUSE_COMPAT_INIT_OUT_SIZE 8 573*87ff949aSAlan Somers #define FUSE_COMPAT_22_INIT_OUT_SIZE 24 574*87ff949aSAlan Somers 5755fe58019SAttilio Rao struct fuse_init_out { 5768f9b3ba7SAlan Somers uint32_t major; 5778f9b3ba7SAlan Somers uint32_t minor; 5788f9b3ba7SAlan Somers uint32_t max_readahead; 5798f9b3ba7SAlan Somers uint32_t flags; 5808f9b3ba7SAlan Somers uint16_t max_background; 5818f9b3ba7SAlan Somers uint16_t congestion_threshold; 5828f9b3ba7SAlan Somers uint32_t max_write; 583*87ff949aSAlan Somers uint32_t time_gran; 584*87ff949aSAlan Somers uint32_t unused[9]; 5855fe58019SAttilio Rao }; 5865fe58019SAttilio Rao 5879c62bc70SAlan Somers #ifdef linux 5889c62bc70SAlan Somers #define CUSE_INIT_INFO_MAX 4096 5899c62bc70SAlan Somers 5909c62bc70SAlan Somers struct cuse_init_in { 5918f9b3ba7SAlan Somers uint32_t major; 5928f9b3ba7SAlan Somers uint32_t minor; 5938f9b3ba7SAlan Somers uint32_t unused; 5948f9b3ba7SAlan Somers uint32_t flags; 5959c62bc70SAlan Somers }; 5969c62bc70SAlan Somers 5979c62bc70SAlan Somers struct cuse_init_out { 5988f9b3ba7SAlan Somers uint32_t major; 5998f9b3ba7SAlan Somers uint32_t minor; 6008f9b3ba7SAlan Somers uint32_t unused; 6018f9b3ba7SAlan Somers uint32_t flags; 6028f9b3ba7SAlan Somers uint32_t max_read; 6038f9b3ba7SAlan Somers uint32_t max_write; 6048f9b3ba7SAlan Somers uint32_t dev_major; /* chardev major */ 6058f9b3ba7SAlan Somers uint32_t dev_minor; /* chardev minor */ 6068f9b3ba7SAlan Somers uint32_t spare[10]; 6079c62bc70SAlan Somers }; 6089c62bc70SAlan Somers #endif /* linux */ 6099c62bc70SAlan Somers 6105fe58019SAttilio Rao struct fuse_interrupt_in { 6118f9b3ba7SAlan Somers uint64_t unique; 6125fe58019SAttilio Rao }; 6135fe58019SAttilio Rao 6145fe58019SAttilio Rao struct fuse_bmap_in { 6158f9b3ba7SAlan Somers uint64_t block; 6168f9b3ba7SAlan Somers uint32_t blocksize; 6178f9b3ba7SAlan Somers uint32_t padding; 6185fe58019SAttilio Rao }; 6195fe58019SAttilio Rao 6205fe58019SAttilio Rao struct fuse_bmap_out { 6218f9b3ba7SAlan Somers uint64_t block; 6225fe58019SAttilio Rao }; 6235fe58019SAttilio Rao 6249c62bc70SAlan Somers struct fuse_ioctl_in { 6258f9b3ba7SAlan Somers uint64_t fh; 6268f9b3ba7SAlan Somers uint32_t flags; 6278f9b3ba7SAlan Somers uint32_t cmd; 6288f9b3ba7SAlan Somers uint64_t arg; 6298f9b3ba7SAlan Somers uint32_t in_size; 6308f9b3ba7SAlan Somers uint32_t out_size; 6319c62bc70SAlan Somers }; 6329c62bc70SAlan Somers 633b160acd1SAlan Somers struct fuse_ioctl_iovec { 6348f9b3ba7SAlan Somers uint64_t base; 6358f9b3ba7SAlan Somers uint64_t len; 636b160acd1SAlan Somers }; 637b160acd1SAlan Somers 6389c62bc70SAlan Somers struct fuse_ioctl_out { 6398f9b3ba7SAlan Somers int32_t result; 6408f9b3ba7SAlan Somers uint32_t flags; 6418f9b3ba7SAlan Somers uint32_t in_iovs; 6428f9b3ba7SAlan Somers uint32_t out_iovs; 6439c62bc70SAlan Somers }; 6449c62bc70SAlan Somers 6459c62bc70SAlan Somers struct fuse_poll_in { 6468f9b3ba7SAlan Somers uint64_t fh; 6478f9b3ba7SAlan Somers uint64_t kh; 6488f9b3ba7SAlan Somers uint32_t flags; 6498f9b3ba7SAlan Somers uint32_t events; 6509c62bc70SAlan Somers }; 6519c62bc70SAlan Somers 6529c62bc70SAlan Somers struct fuse_poll_out { 6538f9b3ba7SAlan Somers uint32_t revents; 6548f9b3ba7SAlan Somers uint32_t padding; 6559c62bc70SAlan Somers }; 6569c62bc70SAlan Somers 6579c62bc70SAlan Somers struct fuse_notify_poll_wakeup_out { 6588f9b3ba7SAlan Somers uint64_t kh; 6599c62bc70SAlan Somers }; 6609c62bc70SAlan Somers 661b160acd1SAlan Somers struct fuse_fallocate_in { 6628f9b3ba7SAlan Somers uint64_t fh; 6638f9b3ba7SAlan Somers uint64_t offset; 6648f9b3ba7SAlan Somers uint64_t length; 6658f9b3ba7SAlan Somers uint32_t mode; 6668f9b3ba7SAlan Somers uint32_t padding; 667b160acd1SAlan Somers }; 668b160acd1SAlan Somers 6695fe58019SAttilio Rao struct fuse_in_header { 6708f9b3ba7SAlan Somers uint32_t len; 6718f9b3ba7SAlan Somers uint32_t opcode; 6728f9b3ba7SAlan Somers uint64_t unique; 6738f9b3ba7SAlan Somers uint64_t nodeid; 6748f9b3ba7SAlan Somers uint32_t uid; 6758f9b3ba7SAlan Somers uint32_t gid; 6768f9b3ba7SAlan Somers uint32_t pid; 6778f9b3ba7SAlan Somers uint32_t padding; 6785fe58019SAttilio Rao }; 6795fe58019SAttilio Rao 6805fe58019SAttilio Rao struct fuse_out_header { 6818f9b3ba7SAlan Somers uint32_t len; 6828f9b3ba7SAlan Somers int32_t error; 6838f9b3ba7SAlan Somers uint64_t unique; 6845fe58019SAttilio Rao }; 6855fe58019SAttilio Rao 6865fe58019SAttilio Rao struct fuse_dirent { 6878f9b3ba7SAlan Somers uint64_t ino; 6888f9b3ba7SAlan Somers uint64_t off; 6898f9b3ba7SAlan Somers uint32_t namelen; 6908f9b3ba7SAlan Somers uint32_t type; 691b160acd1SAlan Somers char name[]; 6925fe58019SAttilio Rao }; 6935fe58019SAttilio Rao 6945fe58019SAttilio Rao #define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name) 695*87ff949aSAlan Somers #define FUSE_DIRENT_ALIGN(x) \ 696*87ff949aSAlan Somers (((x) + sizeof(uint64_t) - 1) & ~(sizeof(uint64_t) - 1)) 6975fe58019SAttilio Rao #define FUSE_DIRENT_SIZE(d) \ 6985fe58019SAttilio Rao FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen) 69916bd2d47SAlan Somers 700b160acd1SAlan Somers struct fuse_direntplus { 701b160acd1SAlan Somers struct fuse_entry_out entry_out; 702b160acd1SAlan Somers struct fuse_dirent dirent; 703b160acd1SAlan Somers }; 704b160acd1SAlan Somers 705b160acd1SAlan Somers #define FUSE_NAME_OFFSET_DIRENTPLUS \ 706b160acd1SAlan Somers offsetof(struct fuse_direntplus, dirent.name) 707b160acd1SAlan Somers #define FUSE_DIRENTPLUS_SIZE(d) \ 708b160acd1SAlan Somers FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET_DIRENTPLUS + (d)->dirent.namelen) 709b160acd1SAlan Somers 710a4856c96SAlan Somers struct fuse_notify_inval_inode_out { 7118f9b3ba7SAlan Somers uint64_t ino; 7128f9b3ba7SAlan Somers int64_t off; 7138f9b3ba7SAlan Somers int64_t len; 714a4856c96SAlan Somers }; 715a4856c96SAlan Somers 716a4856c96SAlan Somers struct fuse_notify_inval_entry_out { 7178f9b3ba7SAlan Somers uint64_t parent; 7188f9b3ba7SAlan Somers uint32_t namelen; 7198f9b3ba7SAlan Somers uint32_t padding; 720a4856c96SAlan Somers }; 721a4856c96SAlan Somers 722b160acd1SAlan Somers struct fuse_notify_delete_out { 7238f9b3ba7SAlan Somers uint64_t parent; 7248f9b3ba7SAlan Somers uint64_t child; 7258f9b3ba7SAlan Somers uint32_t namelen; 7268f9b3ba7SAlan Somers uint32_t padding; 727b160acd1SAlan Somers }; 728b160acd1SAlan Somers 729ecb48915SAlan Somers struct fuse_notify_store_out { 7308f9b3ba7SAlan Somers uint64_t nodeid; 7318f9b3ba7SAlan Somers uint64_t offset; 7328f9b3ba7SAlan Somers uint32_t size; 7338f9b3ba7SAlan Somers uint32_t padding; 734ecb48915SAlan Somers }; 735ecb48915SAlan Somers 736ecb48915SAlan Somers struct fuse_notify_retrieve_out { 7378f9b3ba7SAlan Somers uint64_t notify_unique; 7388f9b3ba7SAlan Somers uint64_t nodeid; 7398f9b3ba7SAlan Somers uint64_t offset; 7408f9b3ba7SAlan Somers uint32_t size; 7418f9b3ba7SAlan Somers uint32_t padding; 742ecb48915SAlan Somers }; 743ecb48915SAlan Somers 744ecb48915SAlan Somers /* Matches the size of fuse_write_in */ 745ecb48915SAlan Somers struct fuse_notify_retrieve_in { 7468f9b3ba7SAlan Somers uint64_t dummy1; 7478f9b3ba7SAlan Somers uint64_t offset; 7488f9b3ba7SAlan Somers uint32_t size; 7498f9b3ba7SAlan Somers uint32_t dummy2; 7508f9b3ba7SAlan Somers uint64_t dummy3; 7518f9b3ba7SAlan Somers uint64_t dummy4; 752ecb48915SAlan Somers }; 753ecb48915SAlan Somers 75416bd2d47SAlan Somers #endif /* _FUSE_FUSE_KERNEL_H */ 755