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 <miklos@szeredi.hu> 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_ALLOW_MMAP 213 * - add FUSE_STATX and related structures 214 * 215 * 7.40 216 * - add max_stack_depth to fuse_init_out, add FUSE_PASSTHROUGH init flag 217 * - add backing_id to fuse_open_out, add FOPEN_PASSTHROUGH open flag 218 * - add FUSE_NO_EXPORT_SUPPORT init flag 219 * - add FUSE_NOTIFY_RESEND, add FUSE_HAS_RESEND init flag 220 * 221 * 7.41 222 * - add FUSE_ALLOW_IDMAP 223 * 7.42 224 * - Add FUSE_OVER_IO_URING and all other io-uring related flags and data 225 * structures: 226 * - struct fuse_uring_ent_in_out 227 * - struct fuse_uring_req_header 228 * - struct fuse_uring_cmd_req 229 * - FUSE_URING_IN_OUT_HEADER_SZ 230 * - FUSE_URING_OP_IN_OUT_SZ 231 * - enum fuse_uring_cmd 232 * 233 * 7.43 234 * - add FUSE_REQUEST_TIMEOUT 235 * 236 * 7.44 237 * - add FUSE_NOTIFY_INC_EPOCH 238 * 239 * 7.45 240 * - add FUSE_COPY_FILE_RANGE_64 241 * - add struct fuse_copy_file_range_out 242 * - add FUSE_NOTIFY_PRUNE 243 * 244 * 7.46 245 * - add FUSE_IO_URING_CMD_ADD_QUEUE 246 * - add FUSE_HAS_IO_URING_BUFPOOL 247 * - add fuse_uring_cmd_req bufpool struct 248 * - add bufpool offset field to fuse_uring_ent_in_out struct 249 * - add FUSE_URING_ZERO_COPY, FUSE_URING_ENT_ZERO_COPY, and 250 * FOPEN_IO_URING_ZERO_COPY flag 251 */ 252 253 #ifndef _LINUX_FUSE_H 254 #define _LINUX_FUSE_H 255 256 #ifdef __KERNEL__ 257 #include <linux/types.h> 258 #else 259 #include <stdint.h> 260 #endif 261 262 /* 263 * Version negotiation: 264 * 265 * Both the kernel and userspace send the version they support in the 266 * INIT request and reply respectively. 267 * 268 * If the major versions match then both shall use the smallest 269 * of the two minor versions for communication. 270 * 271 * If the kernel supports a larger major version, then userspace shall 272 * reply with the major version it supports, ignore the rest of the 273 * INIT message and expect a new INIT message from the kernel with a 274 * matching major version. 275 * 276 * If the library supports a larger major version, then it shall fall 277 * back to the major protocol version sent by the kernel for 278 * communication and reply with that major version (and an arbitrary 279 * supported minor version). 280 */ 281 282 /** Version number of this interface */ 283 #define FUSE_KERNEL_VERSION 7 284 285 /** Minor version number of this interface */ 286 #define FUSE_KERNEL_MINOR_VERSION 46 287 288 /** The node ID of the root inode */ 289 #define FUSE_ROOT_ID 1 290 291 /* Make sure all structures are padded to 64bit boundary, so 32bit 292 userspace works under 64bit kernels */ 293 294 struct fuse_attr { 295 uint64_t ino; 296 uint64_t size; 297 uint64_t blocks; 298 uint64_t atime; 299 uint64_t mtime; 300 uint64_t ctime; 301 uint32_t atimensec; 302 uint32_t mtimensec; 303 uint32_t ctimensec; 304 uint32_t mode; 305 uint32_t nlink; 306 uint32_t uid; 307 uint32_t gid; 308 uint32_t rdev; 309 uint32_t blksize; 310 uint32_t flags; 311 }; 312 313 /* 314 * The following structures are bit-for-bit compatible with the statx(2) ABI in 315 * Linux. 316 */ 317 struct fuse_sx_time { 318 int64_t tv_sec; 319 uint32_t tv_nsec; 320 int32_t __reserved; 321 }; 322 323 struct fuse_statx { 324 uint32_t mask; 325 uint32_t blksize; 326 uint64_t attributes; 327 uint32_t nlink; 328 uint32_t uid; 329 uint32_t gid; 330 uint16_t mode; 331 uint16_t __spare0[1]; 332 uint64_t ino; 333 uint64_t size; 334 uint64_t blocks; 335 uint64_t attributes_mask; 336 struct fuse_sx_time atime; 337 struct fuse_sx_time btime; 338 struct fuse_sx_time ctime; 339 struct fuse_sx_time mtime; 340 uint32_t rdev_major; 341 uint32_t rdev_minor; 342 uint32_t dev_major; 343 uint32_t dev_minor; 344 uint64_t __spare2[14]; 345 }; 346 347 struct fuse_kstatfs { 348 uint64_t blocks; 349 uint64_t bfree; 350 uint64_t bavail; 351 uint64_t files; 352 uint64_t ffree; 353 uint32_t bsize; 354 uint32_t namelen; 355 uint32_t frsize; 356 uint32_t padding; 357 uint32_t spare[6]; 358 }; 359 360 struct fuse_file_lock { 361 uint64_t start; 362 uint64_t end; 363 uint32_t type; 364 uint32_t pid; /* tgid */ 365 }; 366 367 /** 368 * Bitmasks for fuse_setattr_in.valid 369 */ 370 #define FATTR_MODE (1 << 0) 371 #define FATTR_UID (1 << 1) 372 #define FATTR_GID (1 << 2) 373 #define FATTR_SIZE (1 << 3) 374 #define FATTR_ATIME (1 << 4) 375 #define FATTR_MTIME (1 << 5) 376 #define FATTR_FH (1 << 6) 377 #define FATTR_ATIME_NOW (1 << 7) 378 #define FATTR_MTIME_NOW (1 << 8) 379 #define FATTR_LOCKOWNER (1 << 9) 380 #define FATTR_CTIME (1 << 10) 381 #define FATTR_KILL_SUIDGID (1 << 11) 382 383 /** 384 * Flags returned by the OPEN request 385 * 386 * FOPEN_DIRECT_IO: bypass page cache for this open file 387 * FOPEN_KEEP_CACHE: don't invalidate the data cache on open 388 * FOPEN_NONSEEKABLE: the file is not seekable 389 * FOPEN_CACHE_DIR: allow caching this directory 390 * FOPEN_STREAM: the file is stream-like (no file position at all) 391 * FOPEN_NOFLUSH: don't flush data cache on close (unless FUSE_WRITEBACK_CACHE) 392 * FOPEN_PARALLEL_DIRECT_WRITES: Allow concurrent direct writes on the same inode 393 * FOPEN_PASSTHROUGH: passthrough read/write io for this open file 394 * FOPEN_IO_URING_ZERO_COPY: use io-uring zero-copy for reads/writes on this 395 * open file. Honored only when the serving io-uring 396 * queue was set up for zero-copy 397 * (FUSE_URING_ZERO_COPY) and the request carries page 398 * payload. Otherwise reads/writes fall back to 399 * copying. 400 */ 401 #define FOPEN_DIRECT_IO (1 << 0) 402 #define FOPEN_KEEP_CACHE (1 << 1) 403 #define FOPEN_NONSEEKABLE (1 << 2) 404 #define FOPEN_CACHE_DIR (1 << 3) 405 #define FOPEN_STREAM (1 << 4) 406 #define FOPEN_NOFLUSH (1 << 5) 407 #define FOPEN_PARALLEL_DIRECT_WRITES (1 << 6) 408 #define FOPEN_PASSTHROUGH (1 << 7) 409 #define FOPEN_IO_URING_ZERO_COPY (1 << 8) 410 411 /** 412 * INIT request/reply flags 413 * 414 * FUSE_ASYNC_READ: asynchronous read requests 415 * FUSE_POSIX_LOCKS: remote locking for POSIX file locks 416 * FUSE_FILE_OPS: kernel sends file handle for fstat, etc... (not yet supported) 417 * FUSE_ATOMIC_O_TRUNC: handles the O_TRUNC open flag in the filesystem 418 * FUSE_EXPORT_SUPPORT: filesystem handles lookups of "." and ".." 419 * FUSE_BIG_WRITES: filesystem can handle write size larger than 4kB 420 * FUSE_DONT_MASK: don't apply umask to file mode on create operations 421 * FUSE_SPLICE_WRITE: kernel supports splice write on the device 422 * FUSE_SPLICE_MOVE: kernel supports splice move on the device 423 * FUSE_SPLICE_READ: kernel supports splice read on the device 424 * FUSE_FLOCK_LOCKS: remote locking for BSD style file locks 425 * FUSE_HAS_IOCTL_DIR: kernel supports ioctl on directories 426 * FUSE_AUTO_INVAL_DATA: automatically invalidate cached pages 427 * FUSE_DO_READDIRPLUS: do READDIRPLUS (READDIR+LOOKUP in one) 428 * FUSE_READDIRPLUS_AUTO: adaptive readdirplus 429 * FUSE_ASYNC_DIO: asynchronous direct I/O submission 430 * FUSE_WRITEBACK_CACHE: use writeback cache for buffered writes 431 * FUSE_NO_OPEN_SUPPORT: kernel supports zero-message opens 432 * FUSE_PARALLEL_DIROPS: allow parallel lookups and readdir 433 * FUSE_HANDLE_KILLPRIV: fs handles killing suid/sgid/cap on write/chown/trunc 434 * FUSE_POSIX_ACL: filesystem supports posix acls 435 * FUSE_ABORT_ERROR: reading the device after abort returns ECONNABORTED 436 * FUSE_MAX_PAGES: init_out.max_pages contains the max number of req pages 437 * FUSE_CACHE_SYMLINKS: cache READLINK responses 438 * FUSE_NO_OPENDIR_SUPPORT: kernel supports zero-message opendir 439 * FUSE_EXPLICIT_INVAL_DATA: only invalidate cached pages on explicit request 440 * FUSE_MAP_ALIGNMENT: init_out.map_alignment contains log2(byte alignment) for 441 * foffset and moffset fields in struct 442 * fuse_setupmapping_out and fuse_removemapping_one. 443 * FUSE_SUBMOUNTS: kernel supports auto-mounting directory submounts 444 * FUSE_HANDLE_KILLPRIV_V2: fs kills suid/sgid/cap on write/chown/trunc. 445 * Upon write/truncate suid/sgid is only killed if caller 446 * does not have CAP_FSETID. Additionally upon 447 * write/truncate sgid is killed only if file has group 448 * execute permission. (Same as Linux VFS behavior). 449 * FUSE_SETXATTR_EXT: Server supports extended struct fuse_setxattr_in 450 * FUSE_INIT_EXT: extended fuse_init_in request 451 * FUSE_INIT_RESERVED: reserved, do not use 452 * FUSE_SECURITY_CTX: add security context to create, mkdir, symlink, and 453 * mknod 454 * FUSE_HAS_INODE_DAX: use per inode DAX 455 * FUSE_CREATE_SUPP_GROUP: add supplementary group info to create, mkdir, 456 * symlink and mknod (single group that matches parent) 457 * FUSE_HAS_EXPIRE_ONLY: kernel supports expiry-only entry invalidation 458 * FUSE_DIRECT_IO_ALLOW_MMAP: allow shared mmap in FOPEN_DIRECT_IO mode. 459 * FUSE_NO_EXPORT_SUPPORT: explicitly disable export support 460 * FUSE_HAS_RESEND: kernel supports resending pending requests, and the high bit 461 * of the request ID indicates resend requests 462 * FUSE_ALLOW_IDMAP: allow creation of idmapped mounts 463 * FUSE_OVER_IO_URING: Indicate that client supports io-uring 464 * FUSE_REQUEST_TIMEOUT: kernel supports timing out requests. 465 * init_out.request_timeout contains the timeout (in secs) 466 * FUSE_HAS_IO_URING_BUFPOOL: kernel supports io-uring buffer pools 467 */ 468 #define FUSE_ASYNC_READ (1 << 0) 469 #define FUSE_POSIX_LOCKS (1 << 1) 470 #define FUSE_FILE_OPS (1 << 2) 471 #define FUSE_ATOMIC_O_TRUNC (1 << 3) 472 #define FUSE_EXPORT_SUPPORT (1 << 4) 473 #define FUSE_BIG_WRITES (1 << 5) 474 #define FUSE_DONT_MASK (1 << 6) 475 #define FUSE_SPLICE_WRITE (1 << 7) 476 #define FUSE_SPLICE_MOVE (1 << 8) 477 #define FUSE_SPLICE_READ (1 << 9) 478 #define FUSE_FLOCK_LOCKS (1 << 10) 479 #define FUSE_HAS_IOCTL_DIR (1 << 11) 480 #define FUSE_AUTO_INVAL_DATA (1 << 12) 481 #define FUSE_DO_READDIRPLUS (1 << 13) 482 #define FUSE_READDIRPLUS_AUTO (1 << 14) 483 #define FUSE_ASYNC_DIO (1 << 15) 484 #define FUSE_WRITEBACK_CACHE (1 << 16) 485 #define FUSE_NO_OPEN_SUPPORT (1 << 17) 486 #define FUSE_PARALLEL_DIROPS (1 << 18) 487 #define FUSE_HANDLE_KILLPRIV (1 << 19) 488 #define FUSE_POSIX_ACL (1 << 20) 489 #define FUSE_ABORT_ERROR (1 << 21) 490 #define FUSE_MAX_PAGES (1 << 22) 491 #define FUSE_CACHE_SYMLINKS (1 << 23) 492 #define FUSE_NO_OPENDIR_SUPPORT (1 << 24) 493 #define FUSE_EXPLICIT_INVAL_DATA (1 << 25) 494 #define FUSE_MAP_ALIGNMENT (1 << 26) 495 #define FUSE_SUBMOUNTS (1 << 27) 496 #define FUSE_HANDLE_KILLPRIV_V2 (1 << 28) 497 #define FUSE_SETXATTR_EXT (1 << 29) 498 #define FUSE_INIT_EXT (1 << 30) 499 #define FUSE_INIT_RESERVED (1 << 31) 500 /* bits 32..63 get shifted down 32 bits into the flags2 field */ 501 #define FUSE_SECURITY_CTX (1ULL << 32) 502 #define FUSE_HAS_INODE_DAX (1ULL << 33) 503 #define FUSE_CREATE_SUPP_GROUP (1ULL << 34) 504 #define FUSE_HAS_EXPIRE_ONLY (1ULL << 35) 505 #define FUSE_DIRECT_IO_ALLOW_MMAP (1ULL << 36) 506 #define FUSE_PASSTHROUGH (1ULL << 37) 507 #define FUSE_NO_EXPORT_SUPPORT (1ULL << 38) 508 #define FUSE_HAS_RESEND (1ULL << 39) 509 /* Obsolete alias for FUSE_DIRECT_IO_ALLOW_MMAP */ 510 #define FUSE_DIRECT_IO_RELAX FUSE_DIRECT_IO_ALLOW_MMAP 511 #define FUSE_ALLOW_IDMAP (1ULL << 40) 512 #define FUSE_OVER_IO_URING (1ULL << 41) 513 #define FUSE_REQUEST_TIMEOUT (1ULL << 42) 514 #define FUSE_HAS_IO_URING_BUFPOOL (1ULL << 43) 515 516 /** 517 * CUSE INIT request/reply flags 518 * 519 * CUSE_UNRESTRICTED_IOCTL: use unrestricted ioctl 520 */ 521 #define CUSE_UNRESTRICTED_IOCTL (1 << 0) 522 523 /** 524 * Release flags 525 */ 526 #define FUSE_RELEASE_FLUSH (1 << 0) 527 #define FUSE_RELEASE_FLOCK_UNLOCK (1 << 1) 528 529 /** 530 * Getattr flags 531 */ 532 #define FUSE_GETATTR_FH (1 << 0) 533 534 /** 535 * Lock flags 536 */ 537 #define FUSE_LK_FLOCK (1 << 0) 538 539 /** 540 * WRITE flags 541 * 542 * FUSE_WRITE_CACHE: delayed write from page cache, file handle is guessed 543 * FUSE_WRITE_LOCKOWNER: lock_owner field is valid 544 * FUSE_WRITE_KILL_SUIDGID: kill suid and sgid bits 545 */ 546 #define FUSE_WRITE_CACHE (1 << 0) 547 #define FUSE_WRITE_LOCKOWNER (1 << 1) 548 #define FUSE_WRITE_KILL_SUIDGID (1 << 2) 549 550 /* Obsolete alias; this flag implies killing suid/sgid only. */ 551 #define FUSE_WRITE_KILL_PRIV FUSE_WRITE_KILL_SUIDGID 552 553 /** 554 * Read flags 555 */ 556 #define FUSE_READ_LOCKOWNER (1 << 1) 557 558 /** 559 * Ioctl flags 560 * 561 * FUSE_IOCTL_COMPAT: 32bit compat ioctl on 64bit machine 562 * FUSE_IOCTL_UNRESTRICTED: not restricted to well-formed ioctls, retry allowed 563 * FUSE_IOCTL_RETRY: retry with new iovecs 564 * FUSE_IOCTL_32BIT: 32bit ioctl 565 * FUSE_IOCTL_DIR: is a directory 566 * FUSE_IOCTL_COMPAT_X32: x32 compat ioctl on 64bit machine (64bit time_t) 567 * 568 * FUSE_IOCTL_MAX_IOV: maximum of in_iovecs + out_iovecs 569 */ 570 #define FUSE_IOCTL_COMPAT (1 << 0) 571 #define FUSE_IOCTL_UNRESTRICTED (1 << 1) 572 #define FUSE_IOCTL_RETRY (1 << 2) 573 #define FUSE_IOCTL_32BIT (1 << 3) 574 #define FUSE_IOCTL_DIR (1 << 4) 575 #define FUSE_IOCTL_COMPAT_X32 (1 << 5) 576 577 #define FUSE_IOCTL_MAX_IOV 256 578 579 /** 580 * Poll flags 581 * 582 * FUSE_POLL_SCHEDULE_NOTIFY: request poll notify 583 */ 584 #define FUSE_POLL_SCHEDULE_NOTIFY (1 << 0) 585 586 /** 587 * Fsync flags 588 * 589 * FUSE_FSYNC_FDATASYNC: Sync data only, not metadata 590 */ 591 #define FUSE_FSYNC_FDATASYNC (1 << 0) 592 593 /** 594 * fuse_attr flags 595 * 596 * FUSE_ATTR_SUBMOUNT: Object is a submount root 597 * FUSE_ATTR_DAX: Enable DAX for this file in per inode DAX mode 598 */ 599 #define FUSE_ATTR_SUBMOUNT (1 << 0) 600 #define FUSE_ATTR_DAX (1 << 1) 601 602 /** 603 * Open flags 604 * FUSE_OPEN_KILL_SUIDGID: Kill suid and sgid if executable 605 */ 606 #define FUSE_OPEN_KILL_SUIDGID (1 << 0) 607 608 /** 609 * setxattr flags 610 * FUSE_SETXATTR_ACL_KILL_SGID: Clear SGID when system.posix_acl_access is set 611 */ 612 #define FUSE_SETXATTR_ACL_KILL_SGID (1 << 0) 613 614 /** 615 * notify_inval_entry flags 616 * FUSE_EXPIRE_ONLY 617 */ 618 #define FUSE_EXPIRE_ONLY (1 << 0) 619 620 /** 621 * extension type 622 * FUSE_MAX_NR_SECCTX: maximum value of &fuse_secctx_header.nr_secctx 623 * FUSE_EXT_GROUPS: &fuse_supp_groups extension 624 */ 625 enum fuse_ext_type { 626 /* Types 0..31 are reserved for fuse_secctx_header */ 627 FUSE_MAX_NR_SECCTX = 31, 628 FUSE_EXT_GROUPS = 32, 629 }; 630 631 enum fuse_opcode { 632 FUSE_LOOKUP = 1, 633 FUSE_FORGET = 2, /* no reply */ 634 FUSE_GETATTR = 3, 635 FUSE_SETATTR = 4, 636 FUSE_READLINK = 5, 637 FUSE_SYMLINK = 6, 638 FUSE_MKNOD = 8, 639 FUSE_MKDIR = 9, 640 FUSE_UNLINK = 10, 641 FUSE_RMDIR = 11, 642 FUSE_RENAME = 12, 643 FUSE_LINK = 13, 644 FUSE_OPEN = 14, 645 FUSE_READ = 15, 646 FUSE_WRITE = 16, 647 FUSE_STATFS = 17, 648 FUSE_RELEASE = 18, 649 FUSE_FSYNC = 20, 650 FUSE_SETXATTR = 21, 651 FUSE_GETXATTR = 22, 652 FUSE_LISTXATTR = 23, 653 FUSE_REMOVEXATTR = 24, 654 FUSE_FLUSH = 25, 655 FUSE_INIT = 26, 656 FUSE_OPENDIR = 27, 657 FUSE_READDIR = 28, 658 FUSE_RELEASEDIR = 29, 659 FUSE_FSYNCDIR = 30, 660 FUSE_GETLK = 31, 661 FUSE_SETLK = 32, 662 FUSE_SETLKW = 33, 663 FUSE_ACCESS = 34, 664 FUSE_CREATE = 35, 665 FUSE_INTERRUPT = 36, 666 FUSE_BMAP = 37, 667 FUSE_DESTROY = 38, 668 FUSE_IOCTL = 39, 669 FUSE_POLL = 40, 670 FUSE_NOTIFY_REPLY = 41, 671 FUSE_BATCH_FORGET = 42, 672 FUSE_FALLOCATE = 43, 673 FUSE_READDIRPLUS = 44, 674 FUSE_RENAME2 = 45, 675 FUSE_LSEEK = 46, 676 FUSE_COPY_FILE_RANGE = 47, 677 FUSE_SETUPMAPPING = 48, 678 FUSE_REMOVEMAPPING = 49, 679 FUSE_SYNCFS = 50, 680 FUSE_TMPFILE = 51, 681 FUSE_STATX = 52, 682 FUSE_COPY_FILE_RANGE_64 = 53, 683 684 /* CUSE specific operations */ 685 CUSE_INIT = 4096, 686 687 /* Reserved opcodes: helpful to detect structure endian-ness */ 688 CUSE_INIT_BSWAP_RESERVED = 1048576, /* CUSE_INIT << 8 */ 689 FUSE_INIT_BSWAP_RESERVED = 436207616, /* FUSE_INIT << 24 */ 690 }; 691 692 enum fuse_notify_code { 693 FUSE_NOTIFY_POLL = 1, 694 FUSE_NOTIFY_INVAL_INODE = 2, 695 FUSE_NOTIFY_INVAL_ENTRY = 3, 696 FUSE_NOTIFY_STORE = 4, 697 FUSE_NOTIFY_RETRIEVE = 5, 698 FUSE_NOTIFY_DELETE = 6, 699 FUSE_NOTIFY_RESEND = 7, 700 FUSE_NOTIFY_INC_EPOCH = 8, 701 FUSE_NOTIFY_PRUNE = 9, 702 }; 703 704 /* The read buffer is required to be at least 8k, but may be much larger */ 705 #define FUSE_MIN_READ_BUFFER 8192 706 707 #define FUSE_COMPAT_ENTRY_OUT_SIZE 120 708 709 struct fuse_entry_out { 710 uint64_t nodeid; /* Inode ID */ 711 uint64_t generation; /* Inode generation: nodeid:gen must 712 be unique for the fs's lifetime */ 713 uint64_t entry_valid; /* Cache timeout for the name */ 714 uint64_t attr_valid; /* Cache timeout for the attributes */ 715 uint32_t entry_valid_nsec; 716 uint32_t attr_valid_nsec; 717 struct fuse_attr attr; 718 }; 719 720 struct fuse_forget_in { 721 uint64_t nlookup; 722 }; 723 724 struct fuse_forget_one { 725 uint64_t nodeid; 726 uint64_t nlookup; 727 }; 728 729 struct fuse_batch_forget_in { 730 uint32_t count; 731 uint32_t dummy; 732 }; 733 734 struct fuse_getattr_in { 735 uint32_t getattr_flags; 736 uint32_t dummy; 737 uint64_t fh; 738 }; 739 740 #define FUSE_COMPAT_ATTR_OUT_SIZE 96 741 742 struct fuse_attr_out { 743 uint64_t attr_valid; /* Cache timeout for the attributes */ 744 uint32_t attr_valid_nsec; 745 uint32_t dummy; 746 struct fuse_attr attr; 747 }; 748 749 struct fuse_statx_in { 750 uint32_t getattr_flags; 751 uint32_t reserved; 752 uint64_t fh; 753 uint32_t sx_flags; 754 uint32_t sx_mask; 755 }; 756 757 struct fuse_statx_out { 758 uint64_t attr_valid; /* Cache timeout for the attributes */ 759 uint32_t attr_valid_nsec; 760 uint32_t flags; 761 uint64_t spare[2]; 762 struct fuse_statx stat; 763 }; 764 765 #define FUSE_COMPAT_MKNOD_IN_SIZE 8 766 767 struct fuse_mknod_in { 768 uint32_t mode; 769 uint32_t rdev; 770 uint32_t umask; 771 uint32_t padding; 772 }; 773 774 struct fuse_mkdir_in { 775 uint32_t mode; 776 uint32_t umask; 777 }; 778 779 struct fuse_rename_in { 780 uint64_t newdir; 781 }; 782 783 struct fuse_rename2_in { 784 uint64_t newdir; 785 uint32_t flags; 786 uint32_t padding; 787 }; 788 789 struct fuse_link_in { 790 uint64_t oldnodeid; 791 }; 792 793 struct fuse_setattr_in { 794 uint32_t valid; 795 uint32_t padding; 796 uint64_t fh; 797 uint64_t size; 798 uint64_t lock_owner; 799 uint64_t atime; 800 uint64_t mtime; 801 uint64_t ctime; 802 uint32_t atimensec; 803 uint32_t mtimensec; 804 uint32_t ctimensec; 805 uint32_t mode; 806 uint32_t unused4; 807 uint32_t uid; 808 uint32_t gid; 809 uint32_t unused5; 810 }; 811 812 struct fuse_open_in { 813 uint32_t flags; 814 uint32_t open_flags; /* FUSE_OPEN_... */ 815 }; 816 817 struct fuse_create_in { 818 uint32_t flags; 819 uint32_t mode; 820 uint32_t umask; 821 uint32_t open_flags; /* FUSE_OPEN_... */ 822 }; 823 824 struct fuse_open_out { 825 uint64_t fh; 826 uint32_t open_flags; 827 int32_t backing_id; 828 }; 829 830 struct fuse_release_in { 831 uint64_t fh; 832 uint32_t flags; 833 uint32_t release_flags; 834 uint64_t lock_owner; 835 }; 836 837 struct fuse_flush_in { 838 uint64_t fh; 839 uint32_t unused; 840 uint32_t padding; 841 uint64_t lock_owner; 842 }; 843 844 struct fuse_read_in { 845 uint64_t fh; 846 uint64_t offset; 847 uint32_t size; 848 uint32_t read_flags; 849 uint64_t lock_owner; 850 uint32_t flags; 851 uint32_t padding; 852 }; 853 854 #define FUSE_COMPAT_WRITE_IN_SIZE 24 855 856 struct fuse_write_in { 857 uint64_t fh; 858 uint64_t offset; 859 uint32_t size; 860 uint32_t write_flags; 861 uint64_t lock_owner; 862 uint32_t flags; 863 uint32_t padding; 864 }; 865 866 struct fuse_write_out { 867 uint32_t size; 868 uint32_t padding; 869 }; 870 871 #define FUSE_COMPAT_STATFS_SIZE 48 872 873 struct fuse_statfs_out { 874 struct fuse_kstatfs st; 875 }; 876 877 struct fuse_fsync_in { 878 uint64_t fh; 879 uint32_t fsync_flags; 880 uint32_t padding; 881 }; 882 883 #define FUSE_COMPAT_SETXATTR_IN_SIZE 8 884 885 struct fuse_setxattr_in { 886 uint32_t size; 887 uint32_t flags; 888 uint32_t setxattr_flags; 889 uint32_t padding; 890 }; 891 892 struct fuse_getxattr_in { 893 uint32_t size; 894 uint32_t padding; 895 }; 896 897 struct fuse_getxattr_out { 898 uint32_t size; 899 uint32_t padding; 900 }; 901 902 struct fuse_lk_in { 903 uint64_t fh; 904 uint64_t owner; 905 struct fuse_file_lock lk; 906 uint32_t lk_flags; 907 uint32_t padding; 908 }; 909 910 struct fuse_lk_out { 911 struct fuse_file_lock lk; 912 }; 913 914 struct fuse_access_in { 915 uint32_t mask; 916 uint32_t padding; 917 }; 918 919 struct fuse_init_in { 920 uint32_t major; 921 uint32_t minor; 922 uint32_t max_readahead; 923 uint32_t flags; 924 uint32_t flags2; 925 uint32_t unused[11]; 926 }; 927 928 #define FUSE_COMPAT_INIT_OUT_SIZE 8 929 #define FUSE_COMPAT_22_INIT_OUT_SIZE 24 930 931 struct fuse_init_out { 932 uint32_t major; 933 uint32_t minor; 934 uint32_t max_readahead; 935 uint32_t flags; 936 uint16_t max_background; 937 uint16_t congestion_threshold; 938 uint32_t max_write; 939 uint32_t time_gran; 940 uint16_t max_pages; 941 uint16_t map_alignment; 942 uint32_t flags2; 943 uint32_t max_stack_depth; 944 uint16_t request_timeout; 945 uint16_t unused[11]; 946 }; 947 948 #define CUSE_INIT_INFO_MAX 4096 949 950 struct cuse_init_in { 951 uint32_t major; 952 uint32_t minor; 953 uint32_t unused; 954 uint32_t flags; 955 }; 956 957 struct cuse_init_out { 958 uint32_t major; 959 uint32_t minor; 960 uint32_t unused; 961 uint32_t flags; 962 uint32_t max_read; 963 uint32_t max_write; 964 uint32_t dev_major; /* chardev major */ 965 uint32_t dev_minor; /* chardev minor */ 966 uint32_t spare[10]; 967 }; 968 969 struct fuse_interrupt_in { 970 uint64_t unique; 971 }; 972 973 struct fuse_bmap_in { 974 uint64_t block; 975 uint32_t blocksize; 976 uint32_t padding; 977 }; 978 979 struct fuse_bmap_out { 980 uint64_t block; 981 }; 982 983 struct fuse_ioctl_in { 984 uint64_t fh; 985 uint32_t flags; 986 uint32_t cmd; 987 uint64_t arg; 988 uint32_t in_size; 989 uint32_t out_size; 990 }; 991 992 struct fuse_ioctl_iovec { 993 uint64_t base; 994 uint64_t len; 995 }; 996 997 struct fuse_ioctl_out { 998 int32_t result; 999 uint32_t flags; 1000 uint32_t in_iovs; 1001 uint32_t out_iovs; 1002 }; 1003 1004 struct fuse_poll_in { 1005 uint64_t fh; 1006 uint64_t kh; 1007 uint32_t flags; 1008 uint32_t events; 1009 }; 1010 1011 struct fuse_poll_out { 1012 uint32_t revents; 1013 uint32_t padding; 1014 }; 1015 1016 struct fuse_notify_poll_wakeup_out { 1017 uint64_t kh; 1018 }; 1019 1020 struct fuse_fallocate_in { 1021 uint64_t fh; 1022 uint64_t offset; 1023 uint64_t length; 1024 uint32_t mode; 1025 uint32_t padding; 1026 }; 1027 1028 /** 1029 * FUSE request unique ID flag 1030 * 1031 * Indicates whether this is a resend request. The receiver should handle this 1032 * request accordingly. 1033 */ 1034 #define FUSE_UNIQUE_RESEND (1ULL << 63) 1035 1036 /** 1037 * This value will be set by the kernel to 1038 * (struct fuse_in_header).{uid,gid} fields in 1039 * case when: 1040 * - fuse daemon enabled FUSE_ALLOW_IDMAP 1041 * - idmapping information is not available and uid/gid 1042 * can not be mapped in accordance with an idmapping. 1043 * 1044 * Note: an idmapping information always available 1045 * for inode creation operations like: 1046 * FUSE_MKNOD, FUSE_SYMLINK, FUSE_MKDIR, FUSE_TMPFILE, 1047 * FUSE_CREATE and FUSE_RENAME2 (with RENAME_WHITEOUT). 1048 */ 1049 #define FUSE_INVALID_UIDGID ((uint32_t)(-1)) 1050 1051 struct fuse_in_header { 1052 uint32_t len; 1053 uint32_t opcode; 1054 uint64_t unique; 1055 uint64_t nodeid; 1056 uint32_t uid; 1057 uint32_t gid; 1058 uint32_t pid; 1059 uint16_t total_extlen; /* length of extensions in 8byte units */ 1060 uint16_t padding; 1061 }; 1062 1063 struct fuse_out_header { 1064 uint32_t len; 1065 int32_t error; 1066 uint64_t unique; 1067 }; 1068 1069 struct fuse_dirent { 1070 uint64_t ino; 1071 uint64_t off; 1072 uint32_t namelen; 1073 uint32_t type; 1074 char name[]; 1075 }; 1076 1077 /* Align variable length records to 64bit boundary */ 1078 #define FUSE_REC_ALIGN(x) \ 1079 (((x) + sizeof(uint64_t) - 1) & ~(sizeof(uint64_t) - 1)) 1080 1081 #define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name) 1082 #define FUSE_DIRENT_ALIGN(x) FUSE_REC_ALIGN(x) 1083 #define FUSE_DIRENT_SIZE(d) \ 1084 FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen) 1085 1086 struct fuse_direntplus { 1087 struct fuse_entry_out entry_out; 1088 struct fuse_dirent dirent; 1089 }; 1090 1091 #define FUSE_NAME_OFFSET_DIRENTPLUS \ 1092 offsetof(struct fuse_direntplus, dirent.name) 1093 #define FUSE_DIRENTPLUS_SIZE(d) \ 1094 FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET_DIRENTPLUS + (d)->dirent.namelen) 1095 1096 struct fuse_notify_inval_inode_out { 1097 uint64_t ino; 1098 int64_t off; 1099 int64_t len; 1100 }; 1101 1102 struct fuse_notify_inval_entry_out { 1103 uint64_t parent; 1104 uint32_t namelen; 1105 uint32_t flags; 1106 }; 1107 1108 struct fuse_notify_delete_out { 1109 uint64_t parent; 1110 uint64_t child; 1111 uint32_t namelen; 1112 uint32_t padding; 1113 }; 1114 1115 struct fuse_notify_store_out { 1116 uint64_t nodeid; 1117 uint64_t offset; 1118 uint32_t size; 1119 uint32_t padding; 1120 }; 1121 1122 struct fuse_notify_retrieve_out { 1123 uint64_t notify_unique; 1124 uint64_t nodeid; 1125 uint64_t offset; 1126 uint32_t size; 1127 uint32_t padding; 1128 }; 1129 1130 /* Matches the size of fuse_write_in */ 1131 struct fuse_notify_retrieve_in { 1132 uint64_t dummy1; 1133 uint64_t offset; 1134 uint32_t size; 1135 uint32_t dummy2; 1136 uint64_t dummy3; 1137 uint64_t dummy4; 1138 }; 1139 1140 struct fuse_notify_prune_out { 1141 uint32_t count; 1142 uint32_t padding; 1143 uint64_t spare; 1144 }; 1145 1146 struct fuse_backing_map { 1147 int32_t fd; 1148 uint32_t flags; 1149 uint64_t padding; 1150 }; 1151 1152 /* Device ioctls: */ 1153 #define FUSE_DEV_IOC_MAGIC 229 1154 #define FUSE_DEV_IOC_CLONE _IOR(FUSE_DEV_IOC_MAGIC, 0, uint32_t) 1155 #define FUSE_DEV_IOC_BACKING_OPEN _IOW(FUSE_DEV_IOC_MAGIC, 1, \ 1156 struct fuse_backing_map) 1157 #define FUSE_DEV_IOC_BACKING_CLOSE _IOW(FUSE_DEV_IOC_MAGIC, 2, uint32_t) 1158 #define FUSE_DEV_IOC_SYNC_INIT _IO(FUSE_DEV_IOC_MAGIC, 3) 1159 1160 struct fuse_lseek_in { 1161 uint64_t fh; 1162 uint64_t offset; 1163 uint32_t whence; 1164 uint32_t padding; 1165 }; 1166 1167 struct fuse_lseek_out { 1168 uint64_t offset; 1169 }; 1170 1171 struct fuse_copy_file_range_in { 1172 uint64_t fh_in; 1173 uint64_t off_in; 1174 uint64_t nodeid_out; 1175 uint64_t fh_out; 1176 uint64_t off_out; 1177 uint64_t len; 1178 uint64_t flags; 1179 }; 1180 1181 /* For FUSE_COPY_FILE_RANGE_64 */ 1182 struct fuse_copy_file_range_out { 1183 uint64_t bytes_copied; 1184 }; 1185 1186 #define FUSE_SETUPMAPPING_FLAG_WRITE (1ull << 0) 1187 #define FUSE_SETUPMAPPING_FLAG_READ (1ull << 1) 1188 struct fuse_setupmapping_in { 1189 /* An already open handle */ 1190 uint64_t fh; 1191 /* Offset into the file to start the mapping */ 1192 uint64_t foffset; 1193 /* Length of mapping required */ 1194 uint64_t len; 1195 /* Flags, FUSE_SETUPMAPPING_FLAG_* */ 1196 uint64_t flags; 1197 /* Offset in Memory Window */ 1198 uint64_t moffset; 1199 }; 1200 1201 struct fuse_removemapping_in { 1202 /* number of fuse_removemapping_one follows */ 1203 uint32_t count; 1204 }; 1205 1206 struct fuse_removemapping_one { 1207 /* Offset into the dax window start the unmapping */ 1208 uint64_t moffset; 1209 /* Length of mapping required */ 1210 uint64_t len; 1211 }; 1212 1213 #define FUSE_REMOVEMAPPING_MAX_ENTRY \ 1214 (PAGE_SIZE / sizeof(struct fuse_removemapping_one)) 1215 1216 struct fuse_syncfs_in { 1217 uint64_t padding; 1218 }; 1219 1220 /* 1221 * For each security context, send fuse_secctx with size of security context 1222 * fuse_secctx will be followed by security context name and this in turn 1223 * will be followed by actual context label. 1224 * fuse_secctx, name, context 1225 */ 1226 struct fuse_secctx { 1227 uint32_t size; 1228 uint32_t padding; 1229 }; 1230 1231 /* 1232 * Contains the information about how many fuse_secctx structures are being 1233 * sent and what's the total size of all security contexts (including 1234 * size of fuse_secctx_header). 1235 * 1236 */ 1237 struct fuse_secctx_header { 1238 uint32_t size; 1239 uint32_t nr_secctx; 1240 }; 1241 1242 /** 1243 * struct fuse_ext_header - extension header 1244 * @size: total size of this extension including this header 1245 * @type: type of extension 1246 * 1247 * This is made compatible with fuse_secctx_header by using type values > 1248 * FUSE_MAX_NR_SECCTX 1249 */ 1250 struct fuse_ext_header { 1251 uint32_t size; 1252 uint32_t type; 1253 }; 1254 1255 /** 1256 * struct fuse_supp_groups - Supplementary group extension 1257 * @nr_groups: number of supplementary groups 1258 * @groups: flexible array of group IDs 1259 */ 1260 struct fuse_supp_groups { 1261 uint32_t nr_groups; 1262 uint32_t groups[]; 1263 }; 1264 1265 /** 1266 * Size of the ring buffer header 1267 */ 1268 #define FUSE_URING_IN_OUT_HEADER_SZ 128 1269 #define FUSE_URING_OP_IN_OUT_SZ 128 1270 1271 /** 1272 * fuse_uring_ent_in_out flags 1273 * 1274 * FUSE_URING_ENT_ZERO_COPY: Set if the ent's payload is zero-copied 1275 */ 1276 #define FUSE_URING_ENT_ZERO_COPY (1 << 0) 1277 1278 /* Used as part of the fuse_uring_req_header */ 1279 struct fuse_uring_ent_in_out { 1280 uint64_t flags; 1281 1282 /* 1283 * commit ID to be used in a reply to a ring request (see also 1284 * struct fuse_uring_cmd_req) 1285 */ 1286 uint64_t commit_id; 1287 1288 /* size of user payload buffer */ 1289 uint32_t payload_sz; 1290 1291 /* Offset into the bufpool, if bufpools are used */ 1292 uint32_t offset; 1293 1294 uint64_t reserved; 1295 }; 1296 1297 /** 1298 * Header for all fuse-io-uring requests 1299 */ 1300 struct fuse_uring_req_header { 1301 /* struct fuse_in_header / struct fuse_out_header */ 1302 char in_out[FUSE_URING_IN_OUT_HEADER_SZ]; 1303 1304 /* per op code header */ 1305 char op_in[FUSE_URING_OP_IN_OUT_SZ]; 1306 1307 struct fuse_uring_ent_in_out ring_ent_in_out; 1308 }; 1309 1310 /** 1311 * sqe commands to the kernel 1312 */ 1313 enum fuse_uring_cmd { 1314 FUSE_IO_URING_CMD_INVALID = 0, 1315 1316 /* register the request buffer and fetch a fuse request */ 1317 FUSE_IO_URING_CMD_REGISTER = 1, 1318 1319 /* commit fuse request result and fetch next request */ 1320 FUSE_IO_URING_CMD_COMMIT_AND_FETCH = 2, 1321 1322 /* add a queue */ 1323 FUSE_IO_URING_CMD_ADD_QUEUE = 3, 1324 1325 /* add a bufpool to a queue */ 1326 FUSE_IO_URING_CMD_ADD_BUFPOOL = 4, 1327 }; 1328 1329 /* 1330 * fuse_uring_cmd_req flags for FUSE_IO_URING_CMD_ADD_QUEUE 1331 * 1332 * FUSE_URING_ZERO_COPY is only supported for queues with bufpools on privileged 1333 * servers 1334 */ 1335 #define FUSE_URING_ZERO_COPY (1 << 0) 1336 1337 /** 1338 * In the 80B command area of the SQE. 1339 */ 1340 struct fuse_uring_cmd_req { 1341 uint64_t flags; 1342 1343 /* entry identifier for commits */ 1344 uint64_t commit_id; 1345 1346 /* queue the command is for (queue index) */ 1347 uint16_t qid; 1348 uint8_t padding[6]; 1349 1350 union { 1351 struct { 1352 /* base address of bufpool */ 1353 uint64_t uaddr; 1354 uint32_t len; 1355 uint32_t reserved; 1356 } bufpool; 1357 1358 /* 1359 * Index of this entry's slot in the server's io_uring 1360 * registered buffer table, where the kernel registers the 1361 * request's pages for zero-copy. Set for 1362 * FUSE_IO_URING_CMD_REGISTER cmds only, and only on queues 1363 * created with FUSE_URING_ZERO_COPY. On a non-zero-copy queue 1364 * this must be 0 1365 */ 1366 uint16_t ent_zero_copy_buf_index; 1367 }; 1368 }; 1369 1370 #endif /* _LINUX_FUSE_H */ 1371