1 /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) */ 2 /* 3 This file defines the kernel interface of FUSE 4 Copyright (C) 2001-2008 Miklos Szeredi <[email protected]> 5 6 This program can be distributed under the terms of the GNU GPL. 7 See the file COPYING. 8 9 This -- and only this -- header file may also be distributed under 10 the terms of the BSD Licence as follows: 11 12 Copyright (C) 2001-2007 Miklos Szeredi. All rights reserved. 13 14 Redistribution and use in source and binary forms, with or without 15 modification, are permitted provided that the following conditions 16 are met: 17 1. Redistributions of source code must retain the above copyright 18 notice, this list of conditions and the following disclaimer. 19 2. Redistributions in binary form must reproduce the above copyright 20 notice, this list of conditions and the following disclaimer in the 21 documentation and/or other materials provided with the distribution. 22 23 THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 24 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 27 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 SUCH DAMAGE. 34 */ 35 36 /* 37 * This file defines the kernel interface of FUSE 38 * 39 * Protocol changelog: 40 * 41 * 7.1: 42 * - add the following messages: 43 * FUSE_SETATTR, FUSE_SYMLINK, FUSE_MKNOD, FUSE_MKDIR, FUSE_UNLINK, 44 * FUSE_RMDIR, FUSE_RENAME, FUSE_LINK, FUSE_OPEN, FUSE_READ, FUSE_WRITE, 45 * FUSE_RELEASE, FUSE_FSYNC, FUSE_FLUSH, FUSE_SETXATTR, FUSE_GETXATTR, 46 * FUSE_LISTXATTR, FUSE_REMOVEXATTR, FUSE_OPENDIR, FUSE_READDIR, 47 * FUSE_RELEASEDIR 48 * - add padding to messages to accommodate 32-bit servers on 64-bit kernels 49 * 50 * 7.2: 51 * - add FOPEN_DIRECT_IO and FOPEN_KEEP_CACHE flags 52 * - add FUSE_FSYNCDIR message 53 * 54 * 7.3: 55 * - add FUSE_ACCESS message 56 * - add FUSE_CREATE message 57 * - add filehandle to fuse_setattr_in 58 * 59 * 7.4: 60 * - add frsize to fuse_kstatfs 61 * - clean up request size limit checking 62 * 63 * 7.5: 64 * - add flags and max_write to fuse_init_out 65 * 66 * 7.6: 67 * - add max_readahead to fuse_init_in and fuse_init_out 68 * 69 * 7.7: 70 * - add FUSE_INTERRUPT message 71 * - add POSIX file lock support 72 * 73 * 7.8: 74 * - add lock_owner and flags fields to fuse_release_in 75 * - add FUSE_BMAP message 76 * - add FUSE_DESTROY message 77 * 78 * 7.9: 79 * - new fuse_getattr_in input argument of GETATTR 80 * - add lk_flags in fuse_lk_in 81 * - add lock_owner field to fuse_setattr_in, fuse_read_in and fuse_write_in 82 * - add blksize field to fuse_attr 83 * - add file flags field to fuse_read_in and fuse_write_in 84 * - Add ATIME_NOW and MTIME_NOW flags to fuse_setattr_in 85 * 86 * 7.10 87 * - add nonseekable open flag 88 * 89 * 7.11 90 * - add IOCTL message 91 * - add unsolicited notification support 92 * - add POLL message and NOTIFY_POLL notification 93 * 94 * 7.12 95 * - add umask flag to input argument of create, mknod and mkdir 96 * - add notification messages for invalidation of inodes and 97 * directory entries 98 * 99 * 7.13 100 * - make max number of background requests and congestion threshold 101 * tunables 102 * 103 * 7.14 104 * - add splice support to fuse device 105 * 106 * 7.15 107 * - add store notify 108 * - add retrieve notify 109 * 110 * 7.16 111 * - add BATCH_FORGET request 112 * - FUSE_IOCTL_UNRESTRICTED shall now return with array of 'struct 113 * fuse_ioctl_iovec' instead of ambiguous 'struct iovec' 114 * - add FUSE_IOCTL_32BIT flag 115 * 116 * 7.17 117 * - add FUSE_FLOCK_LOCKS and FUSE_RELEASE_FLOCK_UNLOCK 118 * 119 * 7.18 120 * - add FUSE_IOCTL_DIR flag 121 * - add FUSE_NOTIFY_DELETE 122 * 123 * 7.19 124 * - add FUSE_FALLOCATE 125 * 126 * 7.20 127 * - add FUSE_AUTO_INVAL_DATA 128 * 129 * 7.21 130 * - add FUSE_READDIRPLUS 131 * - send the requested events in POLL request 132 * 133 * 7.22 134 * - add FUSE_ASYNC_DIO 135 * 136 * 7.23 137 * - add FUSE_WRITEBACK_CACHE 138 * - add time_gran to fuse_init_out 139 * - add reserved space to fuse_init_out 140 * - add FATTR_CTIME 141 * - add ctime and ctimensec to fuse_setattr_in 142 * - add FUSE_RENAME2 request 143 * - add FUSE_NO_OPEN_SUPPORT flag 144 * 145 * 7.24 146 * - add FUSE_LSEEK for SEEK_HOLE and SEEK_DATA support 147 * 148 * 7.25 149 * - add FUSE_PARALLEL_DIROPS 150 * 151 * 7.26 152 * - add FUSE_HANDLE_KILLPRIV 153 * - add FUSE_POSIX_ACL 154 * 155 * 7.27 156 * - add FUSE_ABORT_ERROR 157 * 158 * 7.28 159 * - add FUSE_COPY_FILE_RANGE 160 * - add FOPEN_CACHE_DIR 161 * - add FUSE_MAX_PAGES, add max_pages to init_out 162 * - add FUSE_CACHE_SYMLINKS 163 * 164 * 7.29 165 * - add FUSE_NO_OPENDIR_SUPPORT flag 166 * 167 * 7.30 168 * - add FUSE_EXPLICIT_INVAL_DATA 169 * - add FUSE_IOCTL_COMPAT_X32 170 * 171 * 7.31 172 * - add FUSE_WRITE_KILL_PRIV flag 173 * - add FUSE_SETUPMAPPING and FUSE_REMOVEMAPPING 174 * - add map_alignment to fuse_init_out, add FUSE_MAP_ALIGNMENT flag 175 * 176 * 7.32 177 * - add flags to fuse_attr, add FUSE_ATTR_SUBMOUNT, add FUSE_SUBMOUNTS 178 * 179 * 7.33 180 * - add FUSE_HANDLE_KILLPRIV_V2, FUSE_WRITE_KILL_SUIDGID, FATTR_KILL_SUIDGID 181 * - add FUSE_OPEN_KILL_SUIDGID 182 * - extend fuse_setxattr_in, add FUSE_SETXATTR_EXT 183 * - add FUSE_SETXATTR_ACL_KILL_SGID 184 * 185 * 7.34 186 * - add FUSE_SYNCFS 187 * 188 * 7.35 189 * - add FOPEN_NOFLUSH 190 * 191 * 7.36 192 * - extend fuse_init_in with reserved fields, add FUSE_INIT_EXT init flag 193 * - add flags2 to fuse_init_in and fuse_init_out 194 * - add FUSE_SECURITY_CTX init flag 195 * - add security context to create, mkdir, symlink, and mknod requests 196 * - add FUSE_HAS_INODE_DAX, FUSE_ATTR_DAX 197 * 198 * 7.37 199 * - add FUSE_TMPFILE 200 * 201 * 7.38 202 * - add FUSE_EXPIRE_ONLY flag to fuse_notify_inval_entry 203 * - add FOPEN_PARALLEL_DIRECT_WRITES 204 * - add total_extlen to fuse_in_header 205 * - add FUSE_MAX_NR_SECCTX 206 * - add extension header 207 * - add FUSE_EXT_GROUPS 208 * - add FUSE_CREATE_SUPP_GROUP 209 * - add FUSE_HAS_EXPIRE_ONLY 210 * 211 * 7.39 212 * - add FUSE_DIRECT_IO_RELAX 213 */ 214 215 #ifndef _LINUX_FUSE_H 216 #define _LINUX_FUSE_H 217 218 #ifdef __KERNEL__ 219 #include <linux/types.h> 220 #else 221 #include <stdint.h> 222 #endif 223 224 /* 225 * Version negotiation: 226 * 227 * Both the kernel and userspace send the version they support in the 228 * INIT request and reply respectively. 229 * 230 * If the major versions match then both shall use the smallest 231 * of the two minor versions for communication. 232 * 233 * If the kernel supports a larger major version, then userspace shall 234 * reply with the major version it supports, ignore the rest of the 235 * INIT message and expect a new INIT message from the kernel with a 236 * matching major version. 237 * 238 * If the library supports a larger major version, then it shall fall 239 * back to the major protocol version sent by the kernel for 240 * communication and reply with that major version (and an arbitrary 241 * supported minor version). 242 */ 243 244 /** Version number of this interface */ 245 #define FUSE_KERNEL_VERSION 7 246 247 /** Minor version number of this interface */ 248 #define FUSE_KERNEL_MINOR_VERSION 39 249 250 /** The node ID of the root inode */ 251 #define FUSE_ROOT_ID 1 252 253 /* Make sure all structures are padded to 64bit boundary, so 32bit 254 userspace works under 64bit kernels */ 255 256 struct fuse_attr { 257 uint64_t ino; 258 uint64_t size; 259 uint64_t blocks; 260 uint64_t atime; 261 uint64_t mtime; 262 uint64_t ctime; 263 uint32_t atimensec; 264 uint32_t mtimensec; 265 uint32_t ctimensec; 266 uint32_t mode; 267 uint32_t nlink; 268 uint32_t uid; 269 uint32_t gid; 270 uint32_t rdev; 271 uint32_t blksize; 272 uint32_t flags; 273 }; 274 275 struct fuse_kstatfs { 276 uint64_t blocks; 277 uint64_t bfree; 278 uint64_t bavail; 279 uint64_t files; 280 uint64_t ffree; 281 uint32_t bsize; 282 uint32_t namelen; 283 uint32_t frsize; 284 uint32_t padding; 285 uint32_t spare[6]; 286 }; 287 288 struct fuse_file_lock { 289 uint64_t start; 290 uint64_t end; 291 uint32_t type; 292 uint32_t pid; /* tgid */ 293 }; 294 295 /** 296 * Bitmasks for fuse_setattr_in.valid 297 */ 298 #define FATTR_MODE (1 << 0) 299 #define FATTR_UID (1 << 1) 300 #define FATTR_GID (1 << 2) 301 #define FATTR_SIZE (1 << 3) 302 #define FATTR_ATIME (1 << 4) 303 #define FATTR_MTIME (1 << 5) 304 #define FATTR_FH (1 << 6) 305 #define FATTR_ATIME_NOW (1 << 7) 306 #define FATTR_MTIME_NOW (1 << 8) 307 #define FATTR_LOCKOWNER (1 << 9) 308 #define FATTR_CTIME (1 << 10) 309 #define FATTR_KILL_SUIDGID (1 << 11) 310 311 /** 312 * Flags returned by the OPEN request 313 * 314 * FOPEN_DIRECT_IO: bypass page cache for this open file 315 * FOPEN_KEEP_CACHE: don't invalidate the data cache on open 316 * FOPEN_NONSEEKABLE: the file is not seekable 317 * FOPEN_CACHE_DIR: allow caching this directory 318 * FOPEN_STREAM: the file is stream-like (no file position at all) 319 * FOPEN_NOFLUSH: don't flush data cache on close (unless FUSE_WRITEBACK_CACHE) 320 * FOPEN_PARALLEL_DIRECT_WRITES: Allow concurrent direct writes on the same inode 321 */ 322 #define FOPEN_DIRECT_IO (1 << 0) 323 #define FOPEN_KEEP_CACHE (1 << 1) 324 #define FOPEN_NONSEEKABLE (1 << 2) 325 #define FOPEN_CACHE_DIR (1 << 3) 326 #define FOPEN_STREAM (1 << 4) 327 #define FOPEN_NOFLUSH (1 << 5) 328 #define FOPEN_PARALLEL_DIRECT_WRITES (1 << 6) 329 330 /** 331 * INIT request/reply flags 332 * 333 * FUSE_ASYNC_READ: asynchronous read requests 334 * FUSE_POSIX_LOCKS: remote locking for POSIX file locks 335 * FUSE_FILE_OPS: kernel sends file handle for fstat, etc... (not yet supported) 336 * FUSE_ATOMIC_O_TRUNC: handles the O_TRUNC open flag in the filesystem 337 * FUSE_EXPORT_SUPPORT: filesystem handles lookups of "." and ".." 338 * FUSE_BIG_WRITES: filesystem can handle write size larger than 4kB 339 * FUSE_DONT_MASK: don't apply umask to file mode on create operations 340 * FUSE_SPLICE_WRITE: kernel supports splice write on the device 341 * FUSE_SPLICE_MOVE: kernel supports splice move on the device 342 * FUSE_SPLICE_READ: kernel supports splice read on the device 343 * FUSE_FLOCK_LOCKS: remote locking for BSD style file locks 344 * FUSE_HAS_IOCTL_DIR: kernel supports ioctl on directories 345 * FUSE_AUTO_INVAL_DATA: automatically invalidate cached pages 346 * FUSE_DO_READDIRPLUS: do READDIRPLUS (READDIR+LOOKUP in one) 347 * FUSE_READDIRPLUS_AUTO: adaptive readdirplus 348 * FUSE_ASYNC_DIO: asynchronous direct I/O submission 349 * FUSE_WRITEBACK_CACHE: use writeback cache for buffered writes 350 * FUSE_NO_OPEN_SUPPORT: kernel supports zero-message opens 351 * FUSE_PARALLEL_DIROPS: allow parallel lookups and readdir 352 * FUSE_HANDLE_KILLPRIV: fs handles killing suid/sgid/cap on write/chown/trunc 353 * FUSE_POSIX_ACL: filesystem supports posix acls 354 * FUSE_ABORT_ERROR: reading the device after abort returns ECONNABORTED 355 * FUSE_MAX_PAGES: init_out.max_pages contains the max number of req pages 356 * FUSE_CACHE_SYMLINKS: cache READLINK responses 357 * FUSE_NO_OPENDIR_SUPPORT: kernel supports zero-message opendir 358 * FUSE_EXPLICIT_INVAL_DATA: only invalidate cached pages on explicit request 359 * FUSE_MAP_ALIGNMENT: init_out.map_alignment contains log2(byte alignment) for 360 * foffset and moffset fields in struct 361 * fuse_setupmapping_out and fuse_removemapping_one. 362 * FUSE_SUBMOUNTS: kernel supports auto-mounting directory submounts 363 * FUSE_HANDLE_KILLPRIV_V2: fs kills suid/sgid/cap on write/chown/trunc. 364 * Upon write/truncate suid/sgid is only killed if caller 365 * does not have CAP_FSETID. Additionally upon 366 * write/truncate sgid is killed only if file has group 367 * execute permission. (Same as Linux VFS behavior). 368 * FUSE_SETXATTR_EXT: Server supports extended struct fuse_setxattr_in 369 * FUSE_INIT_EXT: extended fuse_init_in request 370 * FUSE_INIT_RESERVED: reserved, do not use 371 * FUSE_SECURITY_CTX: add security context to create, mkdir, symlink, and 372 * mknod 373 * FUSE_HAS_INODE_DAX: use per inode DAX 374 * FUSE_CREATE_SUPP_GROUP: add supplementary group info to create, mkdir, 375 * symlink and mknod (single group that matches parent) 376 * FUSE_HAS_EXPIRE_ONLY: kernel supports expiry-only entry invalidation 377 * FUSE_DIRECT_IO_RELAX: relax restrictions in FOPEN_DIRECT_IO mode, for now 378 * allow shared mmap 379 */ 380 #define FUSE_ASYNC_READ (1 << 0) 381 #define FUSE_POSIX_LOCKS (1 << 1) 382 #define FUSE_FILE_OPS (1 << 2) 383 #define FUSE_ATOMIC_O_TRUNC (1 << 3) 384 #define FUSE_EXPORT_SUPPORT (1 << 4) 385 #define FUSE_BIG_WRITES (1 << 5) 386 #define FUSE_DONT_MASK (1 << 6) 387 #define FUSE_SPLICE_WRITE (1 << 7) 388 #define FUSE_SPLICE_MOVE (1 << 8) 389 #define FUSE_SPLICE_READ (1 << 9) 390 #define FUSE_FLOCK_LOCKS (1 << 10) 391 #define FUSE_HAS_IOCTL_DIR (1 << 11) 392 #define FUSE_AUTO_INVAL_DATA (1 << 12) 393 #define FUSE_DO_READDIRPLUS (1 << 13) 394 #define FUSE_READDIRPLUS_AUTO (1 << 14) 395 #define FUSE_ASYNC_DIO (1 << 15) 396 #define FUSE_WRITEBACK_CACHE (1 << 16) 397 #define FUSE_NO_OPEN_SUPPORT (1 << 17) 398 #define FUSE_PARALLEL_DIROPS (1 << 18) 399 #define FUSE_HANDLE_KILLPRIV (1 << 19) 400 #define FUSE_POSIX_ACL (1 << 20) 401 #define FUSE_ABORT_ERROR (1 << 21) 402 #define FUSE_MAX_PAGES (1 << 22) 403 #define FUSE_CACHE_SYMLINKS (1 << 23) 404 #define FUSE_NO_OPENDIR_SUPPORT (1 << 24) 405 #define FUSE_EXPLICIT_INVAL_DATA (1 << 25) 406 #define FUSE_MAP_ALIGNMENT (1 << 26) 407 #define FUSE_SUBMOUNTS (1 << 27) 408 #define FUSE_HANDLE_KILLPRIV_V2 (1 << 28) 409 #define FUSE_SETXATTR_EXT (1 << 29) 410 #define FUSE_INIT_EXT (1 << 30) 411 #define FUSE_INIT_RESERVED (1 << 31) 412 /* bits 32..63 get shifted down 32 bits into the flags2 field */ 413 #define FUSE_SECURITY_CTX (1ULL << 32) 414 #define FUSE_HAS_INODE_DAX (1ULL << 33) 415 #define FUSE_CREATE_SUPP_GROUP (1ULL << 34) 416 #define FUSE_HAS_EXPIRE_ONLY (1ULL << 35) 417 #define FUSE_DIRECT_IO_RELAX (1ULL << 36) 418 419 /** 420 * CUSE INIT request/reply flags 421 * 422 * CUSE_UNRESTRICTED_IOCTL: use unrestricted ioctl 423 */ 424 #define CUSE_UNRESTRICTED_IOCTL (1 << 0) 425 426 /** 427 * Release flags 428 */ 429 #define FUSE_RELEASE_FLUSH (1 << 0) 430 #define FUSE_RELEASE_FLOCK_UNLOCK (1 << 1) 431 432 /** 433 * Getattr flags 434 */ 435 #define FUSE_GETATTR_FH (1 << 0) 436 437 /** 438 * Lock flags 439 */ 440 #define FUSE_LK_FLOCK (1 << 0) 441 442 /** 443 * WRITE flags 444 * 445 * FUSE_WRITE_CACHE: delayed write from page cache, file handle is guessed 446 * FUSE_WRITE_LOCKOWNER: lock_owner field is valid 447 * FUSE_WRITE_KILL_SUIDGID: kill suid and sgid bits 448 */ 449 #define FUSE_WRITE_CACHE (1 << 0) 450 #define FUSE_WRITE_LOCKOWNER (1 << 1) 451 #define FUSE_WRITE_KILL_SUIDGID (1 << 2) 452 453 /* Obsolete alias; this flag implies killing suid/sgid only. */ 454 #define FUSE_WRITE_KILL_PRIV FUSE_WRITE_KILL_SUIDGID 455 456 /** 457 * Read flags 458 */ 459 #define FUSE_READ_LOCKOWNER (1 << 1) 460 461 /** 462 * Ioctl flags 463 * 464 * FUSE_IOCTL_COMPAT: 32bit compat ioctl on 64bit machine 465 * FUSE_IOCTL_UNRESTRICTED: not restricted to well-formed ioctls, retry allowed 466 * FUSE_IOCTL_RETRY: retry with new iovecs 467 * FUSE_IOCTL_32BIT: 32bit ioctl 468 * FUSE_IOCTL_DIR: is a directory 469 * FUSE_IOCTL_COMPAT_X32: x32 compat ioctl on 64bit machine (64bit time_t) 470 * 471 * FUSE_IOCTL_MAX_IOV: maximum of in_iovecs + out_iovecs 472 */ 473 #define FUSE_IOCTL_COMPAT (1 << 0) 474 #define FUSE_IOCTL_UNRESTRICTED (1 << 1) 475 #define FUSE_IOCTL_RETRY (1 << 2) 476 #define FUSE_IOCTL_32BIT (1 << 3) 477 #define FUSE_IOCTL_DIR (1 << 4) 478 #define FUSE_IOCTL_COMPAT_X32 (1 << 5) 479 480 #define FUSE_IOCTL_MAX_IOV 256 481 482 /** 483 * Poll flags 484 * 485 * FUSE_POLL_SCHEDULE_NOTIFY: request poll notify 486 */ 487 #define FUSE_POLL_SCHEDULE_NOTIFY (1 << 0) 488 489 /** 490 * Fsync flags 491 * 492 * FUSE_FSYNC_FDATASYNC: Sync data only, not metadata 493 */ 494 #define FUSE_FSYNC_FDATASYNC (1 << 0) 495 496 /** 497 * fuse_attr flags 498 * 499 * FUSE_ATTR_SUBMOUNT: Object is a submount root 500 * FUSE_ATTR_DAX: Enable DAX for this file in per inode DAX mode 501 */ 502 #define FUSE_ATTR_SUBMOUNT (1 << 0) 503 #define FUSE_ATTR_DAX (1 << 1) 504 505 /** 506 * Open flags 507 * FUSE_OPEN_KILL_SUIDGID: Kill suid and sgid if executable 508 */ 509 #define FUSE_OPEN_KILL_SUIDGID (1 << 0) 510 511 /** 512 * setxattr flags 513 * FUSE_SETXATTR_ACL_KILL_SGID: Clear SGID when system.posix_acl_access is set 514 */ 515 #define FUSE_SETXATTR_ACL_KILL_SGID (1 << 0) 516 517 /** 518 * notify_inval_entry flags 519 * FUSE_EXPIRE_ONLY 520 */ 521 #define FUSE_EXPIRE_ONLY (1 << 0) 522 523 /** 524 * extension type 525 * FUSE_MAX_NR_SECCTX: maximum value of &fuse_secctx_header.nr_secctx 526 * FUSE_EXT_GROUPS: &fuse_supp_groups extension 527 */ 528 enum fuse_ext_type { 529 /* Types 0..31 are reserved for fuse_secctx_header */ 530 FUSE_MAX_NR_SECCTX = 31, 531 FUSE_EXT_GROUPS = 32, 532 }; 533 534 enum fuse_opcode { 535 FUSE_LOOKUP = 1, 536 FUSE_FORGET = 2, /* no reply */ 537 FUSE_GETATTR = 3, 538 FUSE_SETATTR = 4, 539 FUSE_READLINK = 5, 540 FUSE_SYMLINK = 6, 541 FUSE_MKNOD = 8, 542 FUSE_MKDIR = 9, 543 FUSE_UNLINK = 10, 544 FUSE_RMDIR = 11, 545 FUSE_RENAME = 12, 546 FUSE_LINK = 13, 547 FUSE_OPEN = 14, 548 FUSE_READ = 15, 549 FUSE_WRITE = 16, 550 FUSE_STATFS = 17, 551 FUSE_RELEASE = 18, 552 FUSE_FSYNC = 20, 553 FUSE_SETXATTR = 21, 554 FUSE_GETXATTR = 22, 555 FUSE_LISTXATTR = 23, 556 FUSE_REMOVEXATTR = 24, 557 FUSE_FLUSH = 25, 558 FUSE_INIT = 26, 559 FUSE_OPENDIR = 27, 560 FUSE_READDIR = 28, 561 FUSE_RELEASEDIR = 29, 562 FUSE_FSYNCDIR = 30, 563 FUSE_GETLK = 31, 564 FUSE_SETLK = 32, 565 FUSE_SETLKW = 33, 566 FUSE_ACCESS = 34, 567 FUSE_CREATE = 35, 568 FUSE_INTERRUPT = 36, 569 FUSE_BMAP = 37, 570 FUSE_DESTROY = 38, 571 FUSE_IOCTL = 39, 572 FUSE_POLL = 40, 573 FUSE_NOTIFY_REPLY = 41, 574 FUSE_BATCH_FORGET = 42, 575 FUSE_FALLOCATE = 43, 576 FUSE_READDIRPLUS = 44, 577 FUSE_RENAME2 = 45, 578 FUSE_LSEEK = 46, 579 FUSE_COPY_FILE_RANGE = 47, 580 FUSE_SETUPMAPPING = 48, 581 FUSE_REMOVEMAPPING = 49, 582 FUSE_SYNCFS = 50, 583 FUSE_TMPFILE = 51, 584 585 /* CUSE specific operations */ 586 CUSE_INIT = 4096, 587 588 /* Reserved opcodes: helpful to detect structure endian-ness */ 589 CUSE_INIT_BSWAP_RESERVED = 1048576, /* CUSE_INIT << 8 */ 590 FUSE_INIT_BSWAP_RESERVED = 436207616, /* FUSE_INIT << 24 */ 591 }; 592 593 enum fuse_notify_code { 594 FUSE_NOTIFY_POLL = 1, 595 FUSE_NOTIFY_INVAL_INODE = 2, 596 FUSE_NOTIFY_INVAL_ENTRY = 3, 597 FUSE_NOTIFY_STORE = 4, 598 FUSE_NOTIFY_RETRIEVE = 5, 599 FUSE_NOTIFY_DELETE = 6, 600 FUSE_NOTIFY_CODE_MAX, 601 }; 602 603 /* The read buffer is required to be at least 8k, but may be much larger */ 604 #define FUSE_MIN_READ_BUFFER 8192 605 606 #define FUSE_COMPAT_ENTRY_OUT_SIZE 120 607 608 struct fuse_entry_out { 609 uint64_t nodeid; /* Inode ID */ 610 uint64_t generation; /* Inode generation: nodeid:gen must 611 be unique for the fs's lifetime */ 612 uint64_t entry_valid; /* Cache timeout for the name */ 613 uint64_t attr_valid; /* Cache timeout for the attributes */ 614 uint32_t entry_valid_nsec; 615 uint32_t attr_valid_nsec; 616 struct fuse_attr attr; 617 }; 618 619 struct fuse_forget_in { 620 uint64_t nlookup; 621 }; 622 623 struct fuse_forget_one { 624 uint64_t nodeid; 625 uint64_t nlookup; 626 }; 627 628 struct fuse_batch_forget_in { 629 uint32_t count; 630 uint32_t dummy; 631 }; 632 633 struct fuse_getattr_in { 634 uint32_t getattr_flags; 635 uint32_t dummy; 636 uint64_t fh; 637 }; 638 639 #define FUSE_COMPAT_ATTR_OUT_SIZE 96 640 641 struct fuse_attr_out { 642 uint64_t attr_valid; /* Cache timeout for the attributes */ 643 uint32_t attr_valid_nsec; 644 uint32_t dummy; 645 struct fuse_attr attr; 646 }; 647 648 #define FUSE_COMPAT_MKNOD_IN_SIZE 8 649 650 struct fuse_mknod_in { 651 uint32_t mode; 652 uint32_t rdev; 653 uint32_t umask; 654 uint32_t padding; 655 }; 656 657 struct fuse_mkdir_in { 658 uint32_t mode; 659 uint32_t umask; 660 }; 661 662 struct fuse_rename_in { 663 uint64_t newdir; 664 }; 665 666 struct fuse_rename2_in { 667 uint64_t newdir; 668 uint32_t flags; 669 uint32_t padding; 670 }; 671 672 struct fuse_link_in { 673 uint64_t oldnodeid; 674 }; 675 676 struct fuse_setattr_in { 677 uint32_t valid; 678 uint32_t padding; 679 uint64_t fh; 680 uint64_t size; 681 uint64_t lock_owner; 682 uint64_t atime; 683 uint64_t mtime; 684 uint64_t ctime; 685 uint32_t atimensec; 686 uint32_t mtimensec; 687 uint32_t ctimensec; 688 uint32_t mode; 689 uint32_t unused4; 690 uint32_t uid; 691 uint32_t gid; 692 uint32_t unused5; 693 }; 694 695 struct fuse_open_in { 696 uint32_t flags; 697 uint32_t open_flags; /* FUSE_OPEN_... */ 698 }; 699 700 struct fuse_create_in { 701 uint32_t flags; 702 uint32_t mode; 703 uint32_t umask; 704 uint32_t open_flags; /* FUSE_OPEN_... */ 705 }; 706 707 struct fuse_open_out { 708 uint64_t fh; 709 uint32_t open_flags; 710 uint32_t padding; 711 }; 712 713 struct fuse_release_in { 714 uint64_t fh; 715 uint32_t flags; 716 uint32_t release_flags; 717 uint64_t lock_owner; 718 }; 719 720 struct fuse_flush_in { 721 uint64_t fh; 722 uint32_t unused; 723 uint32_t padding; 724 uint64_t lock_owner; 725 }; 726 727 struct fuse_read_in { 728 uint64_t fh; 729 uint64_t offset; 730 uint32_t size; 731 uint32_t read_flags; 732 uint64_t lock_owner; 733 uint32_t flags; 734 uint32_t padding; 735 }; 736 737 #define FUSE_COMPAT_WRITE_IN_SIZE 24 738 739 struct fuse_write_in { 740 uint64_t fh; 741 uint64_t offset; 742 uint32_t size; 743 uint32_t write_flags; 744 uint64_t lock_owner; 745 uint32_t flags; 746 uint32_t padding; 747 }; 748 749 struct fuse_write_out { 750 uint32_t size; 751 uint32_t padding; 752 }; 753 754 #define FUSE_COMPAT_STATFS_SIZE 48 755 756 struct fuse_statfs_out { 757 struct fuse_kstatfs st; 758 }; 759 760 struct fuse_fsync_in { 761 uint64_t fh; 762 uint32_t fsync_flags; 763 uint32_t padding; 764 }; 765 766 #define FUSE_COMPAT_SETXATTR_IN_SIZE 8 767 768 struct fuse_setxattr_in { 769 uint32_t size; 770 uint32_t flags; 771 uint32_t setxattr_flags; 772 uint32_t padding; 773 }; 774 775 struct fuse_getxattr_in { 776 uint32_t size; 777 uint32_t padding; 778 }; 779 780 struct fuse_getxattr_out { 781 uint32_t size; 782 uint32_t padding; 783 }; 784 785 struct fuse_lk_in { 786 uint64_t fh; 787 uint64_t owner; 788 struct fuse_file_lock lk; 789 uint32_t lk_flags; 790 uint32_t padding; 791 }; 792 793 struct fuse_lk_out { 794 struct fuse_file_lock lk; 795 }; 796 797 struct fuse_access_in { 798 uint32_t mask; 799 uint32_t padding; 800 }; 801 802 struct fuse_init_in { 803 uint32_t major; 804 uint32_t minor; 805 uint32_t max_readahead; 806 uint32_t flags; 807 uint32_t flags2; 808 uint32_t unused[11]; 809 }; 810 811 #define FUSE_COMPAT_INIT_OUT_SIZE 8 812 #define FUSE_COMPAT_22_INIT_OUT_SIZE 24 813 814 struct fuse_init_out { 815 uint32_t major; 816 uint32_t minor; 817 uint32_t max_readahead; 818 uint32_t flags; 819 uint16_t max_background; 820 uint16_t congestion_threshold; 821 uint32_t max_write; 822 uint32_t time_gran; 823 uint16_t max_pages; 824 uint16_t map_alignment; 825 uint32_t flags2; 826 uint32_t unused[7]; 827 }; 828 829 #define CUSE_INIT_INFO_MAX 4096 830 831 struct cuse_init_in { 832 uint32_t major; 833 uint32_t minor; 834 uint32_t unused; 835 uint32_t flags; 836 }; 837 838 struct cuse_init_out { 839 uint32_t major; 840 uint32_t minor; 841 uint32_t unused; 842 uint32_t flags; 843 uint32_t max_read; 844 uint32_t max_write; 845 uint32_t dev_major; /* chardev major */ 846 uint32_t dev_minor; /* chardev minor */ 847 uint32_t spare[10]; 848 }; 849 850 struct fuse_interrupt_in { 851 uint64_t unique; 852 }; 853 854 struct fuse_bmap_in { 855 uint64_t block; 856 uint32_t blocksize; 857 uint32_t padding; 858 }; 859 860 struct fuse_bmap_out { 861 uint64_t block; 862 }; 863 864 struct fuse_ioctl_in { 865 uint64_t fh; 866 uint32_t flags; 867 uint32_t cmd; 868 uint64_t arg; 869 uint32_t in_size; 870 uint32_t out_size; 871 }; 872 873 struct fuse_ioctl_iovec { 874 uint64_t base; 875 uint64_t len; 876 }; 877 878 struct fuse_ioctl_out { 879 int32_t result; 880 uint32_t flags; 881 uint32_t in_iovs; 882 uint32_t out_iovs; 883 }; 884 885 struct fuse_poll_in { 886 uint64_t fh; 887 uint64_t kh; 888 uint32_t flags; 889 uint32_t events; 890 }; 891 892 struct fuse_poll_out { 893 uint32_t revents; 894 uint32_t padding; 895 }; 896 897 struct fuse_notify_poll_wakeup_out { 898 uint64_t kh; 899 }; 900 901 struct fuse_fallocate_in { 902 uint64_t fh; 903 uint64_t offset; 904 uint64_t length; 905 uint32_t mode; 906 uint32_t padding; 907 }; 908 909 struct fuse_in_header { 910 uint32_t len; 911 uint32_t opcode; 912 uint64_t unique; 913 uint64_t nodeid; 914 uint32_t uid; 915 uint32_t gid; 916 uint32_t pid; 917 uint16_t total_extlen; /* length of extensions in 8byte units */ 918 uint16_t padding; 919 }; 920 921 struct fuse_out_header { 922 uint32_t len; 923 int32_t error; 924 uint64_t unique; 925 }; 926 927 struct fuse_dirent { 928 uint64_t ino; 929 uint64_t off; 930 uint32_t namelen; 931 uint32_t type; 932 char name[]; 933 }; 934 935 /* Align variable length records to 64bit boundary */ 936 #define FUSE_REC_ALIGN(x) \ 937 (((x) + sizeof(uint64_t) - 1) & ~(sizeof(uint64_t) - 1)) 938 939 #define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name) 940 #define FUSE_DIRENT_ALIGN(x) FUSE_REC_ALIGN(x) 941 #define FUSE_DIRENT_SIZE(d) \ 942 FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen) 943 944 struct fuse_direntplus { 945 struct fuse_entry_out entry_out; 946 struct fuse_dirent dirent; 947 }; 948 949 #define FUSE_NAME_OFFSET_DIRENTPLUS \ 950 offsetof(struct fuse_direntplus, dirent.name) 951 #define FUSE_DIRENTPLUS_SIZE(d) \ 952 FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET_DIRENTPLUS + (d)->dirent.namelen) 953 954 struct fuse_notify_inval_inode_out { 955 uint64_t ino; 956 int64_t off; 957 int64_t len; 958 }; 959 960 struct fuse_notify_inval_entry_out { 961 uint64_t parent; 962 uint32_t namelen; 963 uint32_t flags; 964 }; 965 966 struct fuse_notify_delete_out { 967 uint64_t parent; 968 uint64_t child; 969 uint32_t namelen; 970 uint32_t padding; 971 }; 972 973 struct fuse_notify_store_out { 974 uint64_t nodeid; 975 uint64_t offset; 976 uint32_t size; 977 uint32_t padding; 978 }; 979 980 struct fuse_notify_retrieve_out { 981 uint64_t notify_unique; 982 uint64_t nodeid; 983 uint64_t offset; 984 uint32_t size; 985 uint32_t padding; 986 }; 987 988 /* Matches the size of fuse_write_in */ 989 struct fuse_notify_retrieve_in { 990 uint64_t dummy1; 991 uint64_t offset; 992 uint32_t size; 993 uint32_t dummy2; 994 uint64_t dummy3; 995 uint64_t dummy4; 996 }; 997 998 /* Device ioctls: */ 999 #define FUSE_DEV_IOC_MAGIC 229 1000 #define FUSE_DEV_IOC_CLONE _IOR(FUSE_DEV_IOC_MAGIC, 0, uint32_t) 1001 1002 struct fuse_lseek_in { 1003 uint64_t fh; 1004 uint64_t offset; 1005 uint32_t whence; 1006 uint32_t padding; 1007 }; 1008 1009 struct fuse_lseek_out { 1010 uint64_t offset; 1011 }; 1012 1013 struct fuse_copy_file_range_in { 1014 uint64_t fh_in; 1015 uint64_t off_in; 1016 uint64_t nodeid_out; 1017 uint64_t fh_out; 1018 uint64_t off_out; 1019 uint64_t len; 1020 uint64_t flags; 1021 }; 1022 1023 #define FUSE_SETUPMAPPING_FLAG_WRITE (1ull << 0) 1024 #define FUSE_SETUPMAPPING_FLAG_READ (1ull << 1) 1025 struct fuse_setupmapping_in { 1026 /* An already open handle */ 1027 uint64_t fh; 1028 /* Offset into the file to start the mapping */ 1029 uint64_t foffset; 1030 /* Length of mapping required */ 1031 uint64_t len; 1032 /* Flags, FUSE_SETUPMAPPING_FLAG_* */ 1033 uint64_t flags; 1034 /* Offset in Memory Window */ 1035 uint64_t moffset; 1036 }; 1037 1038 struct fuse_removemapping_in { 1039 /* number of fuse_removemapping_one follows */ 1040 uint32_t count; 1041 }; 1042 1043 struct fuse_removemapping_one { 1044 /* Offset into the dax window start the unmapping */ 1045 uint64_t moffset; 1046 /* Length of mapping required */ 1047 uint64_t len; 1048 }; 1049 1050 #define FUSE_REMOVEMAPPING_MAX_ENTRY \ 1051 (PAGE_SIZE / sizeof(struct fuse_removemapping_one)) 1052 1053 struct fuse_syncfs_in { 1054 uint64_t padding; 1055 }; 1056 1057 /* 1058 * For each security context, send fuse_secctx with size of security context 1059 * fuse_secctx will be followed by security context name and this in turn 1060 * will be followed by actual context label. 1061 * fuse_secctx, name, context 1062 */ 1063 struct fuse_secctx { 1064 uint32_t size; 1065 uint32_t padding; 1066 }; 1067 1068 /* 1069 * Contains the information about how many fuse_secctx structures are being 1070 * sent and what's the total size of all security contexts (including 1071 * size of fuse_secctx_header). 1072 * 1073 */ 1074 struct fuse_secctx_header { 1075 uint32_t size; 1076 uint32_t nr_secctx; 1077 }; 1078 1079 /** 1080 * struct fuse_ext_header - extension header 1081 * @size: total size of this extension including this header 1082 * @type: type of extension 1083 * 1084 * This is made compatible with fuse_secctx_header by using type values > 1085 * FUSE_MAX_NR_SECCTX 1086 */ 1087 struct fuse_ext_header { 1088 uint32_t size; 1089 uint32_t type; 1090 }; 1091 1092 /** 1093 * struct fuse_supp_groups - Supplementary group extension 1094 * @nr_groups: number of supplementary groups 1095 * @groups: flexible array of group IDs 1096 */ 1097 struct fuse_supp_groups { 1098 uint32_t nr_groups; 1099 uint32_t groups[]; 1100 }; 1101 1102 #endif /* _LINUX_FUSE_H */ 1103