1 /* 2 FUSE: Filesystem in Userspace 3 Copyright (C) 2001-2008 Miklos Szeredi <miklos@szeredi.hu> 4 5 This program can be distributed under the terms of the GNU GPL. 6 See the file COPYING. 7 */ 8 9 #ifndef _FS_FUSE_I_H 10 #define _FS_FUSE_I_H 11 12 #ifndef pr_fmt 13 # define pr_fmt(fmt) "fuse: " fmt 14 #endif 15 16 #include <linux/fuse.h> 17 #include <linux/fs.h> 18 #include <linux/mount.h> 19 #include <linux/wait.h> 20 #include <linux/list.h> 21 #include <linux/spinlock.h> 22 #include <linux/mm.h> 23 #include <linux/backing-dev.h> 24 #include <linux/mutex.h> 25 #include <linux/rwsem.h> 26 #include <linux/rbtree.h> 27 #include <linux/poll.h> 28 #include <linux/workqueue.h> 29 #include <linux/kref.h> 30 #include <linux/xattr.h> 31 #include <linux/pid_namespace.h> 32 #include <linux/refcount.h> 33 #include <linux/user_namespace.h> 34 35 /** Default max number of pages that can be used in a single read request */ 36 #define FUSE_DEFAULT_MAX_PAGES_PER_REQ 32 37 38 /** Bias for fi->writectr, meaning new writepages must not be sent */ 39 #define FUSE_NOWRITE INT_MIN 40 41 /** It could be as large as PATH_MAX, but would that have any uses? */ 42 #define FUSE_NAME_MAX 1024 43 44 /** Number of dentries for each connection in the control filesystem */ 45 #define FUSE_CTL_NUM_DENTRIES 5 46 47 /** Maximum of max_pages received in init_out */ 48 extern unsigned int fuse_max_pages_limit; 49 50 /** List of active connections */ 51 extern struct list_head fuse_conn_list; 52 53 /** Global mutex protecting fuse_conn_list and the control filesystem */ 54 extern struct mutex fuse_mutex; 55 56 /** Module parameters */ 57 extern unsigned max_user_bgreq; 58 extern unsigned max_user_congthresh; 59 60 /* One forget request */ 61 struct fuse_forget_link { 62 struct fuse_forget_one forget_one; 63 struct fuse_forget_link *next; 64 }; 65 66 /* Submount lookup tracking */ 67 struct fuse_submount_lookup { 68 /** Refcount */ 69 refcount_t count; 70 71 /** Unique ID, which identifies the inode between userspace 72 * and kernel */ 73 u64 nodeid; 74 75 /** The request used for sending the FORGET message */ 76 struct fuse_forget_link *forget; 77 }; 78 79 /** Container for data related to mapping to backing file */ 80 struct fuse_backing { 81 struct file *file; 82 struct cred *cred; 83 84 /** refcount */ 85 refcount_t count; 86 struct rcu_head rcu; 87 }; 88 89 /** FUSE inode */ 90 struct fuse_inode { 91 /** Inode data */ 92 struct inode inode; 93 94 /** Unique ID, which identifies the inode between userspace 95 * and kernel */ 96 u64 nodeid; 97 98 /** Number of lookups on this inode */ 99 u64 nlookup; 100 101 /** The request used for sending the FORGET message */ 102 struct fuse_forget_link *forget; 103 104 /** Time in jiffies until the file attributes are valid */ 105 u64 i_time; 106 107 /* Which attributes are invalid */ 108 u32 inval_mask; 109 110 /** The sticky bit in inode->i_mode may have been removed, so 111 preserve the original mode */ 112 umode_t orig_i_mode; 113 114 /* Cache birthtime */ 115 struct timespec64 i_btime; 116 117 /** 64 bit inode number */ 118 u64 orig_ino; 119 120 /** Version of last attribute change */ 121 u64 attr_version; 122 123 union { 124 /* read/write io cache (regular file only) */ 125 struct { 126 /* Files usable in writepage. Protected by fi->lock */ 127 struct list_head write_files; 128 129 /* Writepages pending on truncate or fsync */ 130 struct list_head queued_writes; 131 132 /* Number of sent writes, a negative bias 133 * (FUSE_NOWRITE) means more writes are blocked */ 134 int writectr; 135 136 /** Number of files/maps using page cache */ 137 int iocachectr; 138 139 /* Waitq for writepage completion */ 140 wait_queue_head_t page_waitq; 141 142 /* waitq for direct-io completion */ 143 wait_queue_head_t direct_io_waitq; 144 145 /* List of writepage requestst (pending or sent) */ 146 struct rb_root writepages; 147 }; 148 149 /* readdir cache (directory only) */ 150 struct { 151 /* true if fully cached */ 152 bool cached; 153 154 /* size of cache */ 155 loff_t size; 156 157 /* position at end of cache (position of next entry) */ 158 loff_t pos; 159 160 /* version of the cache */ 161 u64 version; 162 163 /* modification time of directory when cache was 164 * started */ 165 struct timespec64 mtime; 166 167 /* iversion of directory when cache was started */ 168 u64 iversion; 169 170 /* protects above fields */ 171 spinlock_t lock; 172 } rdc; 173 }; 174 175 /** Miscellaneous bits describing inode state */ 176 unsigned long state; 177 178 /** Lock for serializing lookup and readdir for back compatibility*/ 179 struct mutex mutex; 180 181 /** Lock to protect write related fields */ 182 spinlock_t lock; 183 184 #ifdef CONFIG_FUSE_DAX 185 /* 186 * Dax specific inode data 187 */ 188 struct fuse_inode_dax *dax; 189 #endif 190 /** Submount specific lookup tracking */ 191 struct fuse_submount_lookup *submount_lookup; 192 #ifdef CONFIG_FUSE_PASSTHROUGH 193 /** Reference to backing file in passthrough mode */ 194 struct fuse_backing *fb; 195 #endif 196 }; 197 198 /** FUSE inode state bits */ 199 enum { 200 /** Advise readdirplus */ 201 FUSE_I_ADVISE_RDPLUS, 202 /** Initialized with readdirplus */ 203 FUSE_I_INIT_RDPLUS, 204 /** An operation changing file size is in progress */ 205 FUSE_I_SIZE_UNSTABLE, 206 /* Bad inode */ 207 FUSE_I_BAD, 208 /* Has btime */ 209 FUSE_I_BTIME, 210 /* Wants or already has page cache IO */ 211 FUSE_I_CACHE_IO_MODE, 212 }; 213 214 struct fuse_conn; 215 struct fuse_mount; 216 union fuse_file_args; 217 218 /** FUSE specific file data */ 219 struct fuse_file { 220 /** Fuse connection for this file */ 221 struct fuse_mount *fm; 222 223 /* Argument space reserved for open/release */ 224 union fuse_file_args *args; 225 226 /** Kernel file handle guaranteed to be unique */ 227 u64 kh; 228 229 /** File handle used by userspace */ 230 u64 fh; 231 232 /** Node id of this file */ 233 u64 nodeid; 234 235 /** Refcount */ 236 refcount_t count; 237 238 /** FOPEN_* flags returned by open */ 239 u32 open_flags; 240 241 /** Entry on inode's write_files list */ 242 struct list_head write_entry; 243 244 /* Readdir related */ 245 struct { 246 /* Dir stream position */ 247 loff_t pos; 248 249 /* Offset in cache */ 250 loff_t cache_off; 251 252 /* Version of cache we are reading */ 253 u64 version; 254 255 } readdir; 256 257 /** RB node to be linked on fuse_conn->polled_files */ 258 struct rb_node polled_node; 259 260 /** Wait queue head for poll */ 261 wait_queue_head_t poll_wait; 262 263 /** Does file hold a fi->iocachectr refcount? */ 264 enum { IOM_NONE, IOM_CACHED, IOM_UNCACHED } iomode; 265 266 #ifdef CONFIG_FUSE_PASSTHROUGH 267 /** Reference to backing file in passthrough mode */ 268 struct file *passthrough; 269 const struct cred *cred; 270 #endif 271 272 /** Has flock been performed on this file? */ 273 bool flock:1; 274 }; 275 276 /** One input argument of a request */ 277 struct fuse_in_arg { 278 unsigned size; 279 const void *value; 280 }; 281 282 /** One output argument of a request */ 283 struct fuse_arg { 284 unsigned size; 285 void *value; 286 }; 287 288 /** FUSE folio descriptor */ 289 struct fuse_folio_desc { 290 unsigned int length; 291 unsigned int offset; 292 }; 293 294 struct fuse_args { 295 uint64_t nodeid; 296 uint32_t opcode; 297 uint8_t in_numargs; 298 uint8_t out_numargs; 299 uint8_t ext_idx; 300 bool force:1; 301 bool noreply:1; 302 bool nocreds:1; 303 bool in_pages:1; 304 bool out_pages:1; 305 bool user_pages:1; 306 bool out_argvar:1; 307 bool page_zeroing:1; 308 bool page_replace:1; 309 bool may_block:1; 310 bool is_ext:1; 311 bool is_pinned:1; 312 bool invalidate_vmap:1; 313 struct fuse_in_arg in_args[4]; 314 struct fuse_arg out_args[2]; 315 void (*end)(struct fuse_mount *fm, struct fuse_args *args, int error); 316 /* Used for kvec iter backed by vmalloc address */ 317 void *vmap_base; 318 }; 319 320 struct fuse_args_pages { 321 struct fuse_args args; 322 struct folio **folios; 323 struct fuse_folio_desc *descs; 324 unsigned int num_folios; 325 }; 326 327 struct fuse_release_args { 328 struct fuse_args args; 329 struct fuse_release_in inarg; 330 struct inode *inode; 331 }; 332 333 union fuse_file_args { 334 /* Used during open() */ 335 struct fuse_open_out open_outarg; 336 /* Used during release() */ 337 struct fuse_release_args release_args; 338 }; 339 340 #define FUSE_ARGS(args) struct fuse_args args = {} 341 342 /** The request IO state (for asynchronous processing) */ 343 struct fuse_io_priv { 344 struct kref refcnt; 345 int async; 346 spinlock_t lock; 347 unsigned reqs; 348 ssize_t bytes; 349 size_t size; 350 __u64 offset; 351 bool write; 352 bool should_dirty; 353 int err; 354 struct kiocb *iocb; 355 struct completion *done; 356 bool blocking; 357 }; 358 359 #define FUSE_IO_PRIV_SYNC(i) \ 360 { \ 361 .refcnt = KREF_INIT(1), \ 362 .async = 0, \ 363 .iocb = i, \ 364 } 365 366 /** 367 * Request flags 368 * 369 * FR_ISREPLY: set if the request has reply 370 * FR_FORCE: force sending of the request even if interrupted 371 * FR_BACKGROUND: request is sent in the background 372 * FR_WAITING: request is counted as "waiting" 373 * FR_ABORTED: the request was aborted 374 * FR_INTERRUPTED: the request has been interrupted 375 * FR_LOCKED: data is being copied to/from the request 376 * FR_PENDING: request is not yet in userspace 377 * FR_SENT: request is in userspace, waiting for an answer 378 * FR_FINISHED: request is finished 379 * FR_PRIVATE: request is on private list 380 * FR_ASYNC: request is asynchronous 381 */ 382 enum fuse_req_flag { 383 FR_ISREPLY, 384 FR_FORCE, 385 FR_BACKGROUND, 386 FR_WAITING, 387 FR_ABORTED, 388 FR_INTERRUPTED, 389 FR_LOCKED, 390 FR_PENDING, 391 FR_SENT, 392 FR_FINISHED, 393 FR_PRIVATE, 394 FR_ASYNC, 395 }; 396 397 /** 398 * A request to the client 399 * 400 * .waitq.lock protects the following fields: 401 * - FR_ABORTED 402 * - FR_LOCKED (may also be modified under fc->lock, tested under both) 403 */ 404 struct fuse_req { 405 /** This can be on either pending processing or io lists in 406 fuse_conn */ 407 struct list_head list; 408 409 /** Entry on the interrupts list */ 410 struct list_head intr_entry; 411 412 /* Input/output arguments */ 413 struct fuse_args *args; 414 415 /** refcount */ 416 refcount_t count; 417 418 /* Request flags, updated with test/set/clear_bit() */ 419 unsigned long flags; 420 421 /* The request input header */ 422 struct { 423 struct fuse_in_header h; 424 } in; 425 426 /* The request output header */ 427 struct { 428 struct fuse_out_header h; 429 } out; 430 431 /** Used to wake up the task waiting for completion of request*/ 432 wait_queue_head_t waitq; 433 434 #if IS_ENABLED(CONFIG_VIRTIO_FS) 435 /** virtio-fs's physically contiguous buffer for in and out args */ 436 void *argbuf; 437 #endif 438 439 /** fuse_mount this request belongs to */ 440 struct fuse_mount *fm; 441 442 #ifdef CONFIG_FUSE_IO_URING 443 void *ring_entry; 444 #endif 445 }; 446 447 struct fuse_iqueue; 448 449 /** 450 * Input queue callbacks 451 * 452 * Input queue signalling is device-specific. For example, the /dev/fuse file 453 * uses fiq->waitq and fasync to wake processes that are waiting on queue 454 * readiness. These callbacks allow other device types to respond to input 455 * queue activity. 456 */ 457 struct fuse_iqueue_ops { 458 /** 459 * Send one forget 460 */ 461 void (*send_forget)(struct fuse_iqueue *fiq, struct fuse_forget_link *link); 462 463 /** 464 * Send interrupt for request 465 */ 466 void (*send_interrupt)(struct fuse_iqueue *fiq, struct fuse_req *req); 467 468 /** 469 * Send one request 470 */ 471 void (*send_req)(struct fuse_iqueue *fiq, struct fuse_req *req); 472 473 /** 474 * Clean up when fuse_iqueue is destroyed 475 */ 476 void (*release)(struct fuse_iqueue *fiq); 477 }; 478 479 /** /dev/fuse input queue operations */ 480 extern const struct fuse_iqueue_ops fuse_dev_fiq_ops; 481 482 struct fuse_iqueue { 483 /** Connection established */ 484 unsigned connected; 485 486 /** Lock protecting accesses to members of this structure */ 487 spinlock_t lock; 488 489 /** Readers of the connection are waiting on this */ 490 wait_queue_head_t waitq; 491 492 /** The next unique request id */ 493 u64 reqctr; 494 495 /** The list of pending requests */ 496 struct list_head pending; 497 498 /** Pending interrupts */ 499 struct list_head interrupts; 500 501 /** Queue of pending forgets */ 502 struct fuse_forget_link forget_list_head; 503 struct fuse_forget_link *forget_list_tail; 504 505 /** Batching of FORGET requests (positive indicates FORGET batch) */ 506 int forget_batch; 507 508 /** O_ASYNC requests */ 509 struct fasync_struct *fasync; 510 511 /** Device-specific callbacks */ 512 const struct fuse_iqueue_ops *ops; 513 514 /** Device-specific state */ 515 void *priv; 516 }; 517 518 #define FUSE_PQ_HASH_BITS 8 519 #define FUSE_PQ_HASH_SIZE (1 << FUSE_PQ_HASH_BITS) 520 521 struct fuse_pqueue { 522 /** Connection established */ 523 unsigned connected; 524 525 /** Lock protecting accessess to members of this structure */ 526 spinlock_t lock; 527 528 /** Hash table of requests being processed */ 529 struct list_head *processing; 530 531 /** The list of requests under I/O */ 532 struct list_head io; 533 }; 534 535 /** 536 * Fuse device instance 537 */ 538 struct fuse_dev { 539 /** Fuse connection for this device */ 540 struct fuse_conn *fc; 541 542 /** Processing queue */ 543 struct fuse_pqueue pq; 544 545 /** list entry on fc->devices */ 546 struct list_head entry; 547 }; 548 549 enum fuse_dax_mode { 550 FUSE_DAX_INODE_DEFAULT, /* default */ 551 FUSE_DAX_ALWAYS, /* "-o dax=always" */ 552 FUSE_DAX_NEVER, /* "-o dax=never" */ 553 FUSE_DAX_INODE_USER, /* "-o dax=inode" */ 554 }; 555 556 static inline bool fuse_is_inode_dax_mode(enum fuse_dax_mode mode) 557 { 558 return mode == FUSE_DAX_INODE_DEFAULT || mode == FUSE_DAX_INODE_USER; 559 } 560 561 struct fuse_fs_context { 562 int fd; 563 struct file *file; 564 unsigned int rootmode; 565 kuid_t user_id; 566 kgid_t group_id; 567 bool is_bdev:1; 568 bool fd_present:1; 569 bool rootmode_present:1; 570 bool user_id_present:1; 571 bool group_id_present:1; 572 bool default_permissions:1; 573 bool allow_other:1; 574 bool destroy:1; 575 bool no_control:1; 576 bool no_force_umount:1; 577 bool legacy_opts_show:1; 578 enum fuse_dax_mode dax_mode; 579 unsigned int max_read; 580 unsigned int blksize; 581 const char *subtype; 582 583 /* DAX device, may be NULL */ 584 struct dax_device *dax_dev; 585 586 /* fuse_dev pointer to fill in, should contain NULL on entry */ 587 void **fudptr; 588 }; 589 590 struct fuse_sync_bucket { 591 /* count is a possible scalability bottleneck */ 592 atomic_t count; 593 wait_queue_head_t waitq; 594 struct rcu_head rcu; 595 }; 596 597 /** 598 * A Fuse connection. 599 * 600 * This structure is created, when the root filesystem is mounted, and 601 * is destroyed, when the client device is closed and the last 602 * fuse_mount is destroyed. 603 */ 604 struct fuse_conn { 605 /** Lock protecting accessess to members of this structure */ 606 spinlock_t lock; 607 608 /** Refcount */ 609 refcount_t count; 610 611 /** Number of fuse_dev's */ 612 atomic_t dev_count; 613 614 struct rcu_head rcu; 615 616 /** The user id for this mount */ 617 kuid_t user_id; 618 619 /** The group id for this mount */ 620 kgid_t group_id; 621 622 /** The pid namespace for this mount */ 623 struct pid_namespace *pid_ns; 624 625 /** The user namespace for this mount */ 626 struct user_namespace *user_ns; 627 628 /** Maximum read size */ 629 unsigned max_read; 630 631 /** Maximum write size */ 632 unsigned max_write; 633 634 /** Maximum number of pages that can be used in a single request */ 635 unsigned int max_pages; 636 637 /** Constrain ->max_pages to this value during feature negotiation */ 638 unsigned int max_pages_limit; 639 640 /** Input queue */ 641 struct fuse_iqueue iq; 642 643 /** The next unique kernel file handle */ 644 atomic64_t khctr; 645 646 /** rbtree of fuse_files waiting for poll events indexed by ph */ 647 struct rb_root polled_files; 648 649 /** Maximum number of outstanding background requests */ 650 unsigned max_background; 651 652 /** Number of background requests at which congestion starts */ 653 unsigned congestion_threshold; 654 655 /** Number of requests currently in the background */ 656 unsigned num_background; 657 658 /** Number of background requests currently queued for userspace */ 659 unsigned active_background; 660 661 /** The list of background requests set aside for later queuing */ 662 struct list_head bg_queue; 663 664 /** Protects: max_background, congestion_threshold, num_background, 665 * active_background, bg_queue, blocked */ 666 spinlock_t bg_lock; 667 668 /** Flag indicating that INIT reply has been received. Allocating 669 * any fuse request will be suspended until the flag is set */ 670 int initialized; 671 672 /** Flag indicating if connection is blocked. This will be 673 the case before the INIT reply is received, and if there 674 are too many outstading backgrounds requests */ 675 int blocked; 676 677 /** waitq for blocked connection */ 678 wait_queue_head_t blocked_waitq; 679 680 /** Connection established, cleared on umount, connection 681 abort and device release */ 682 unsigned connected; 683 684 /** Connection aborted via sysfs */ 685 bool aborted; 686 687 /** Connection failed (version mismatch). Cannot race with 688 setting other bitfields since it is only set once in INIT 689 reply, before any other request, and never cleared */ 690 unsigned conn_error:1; 691 692 /** Connection successful. Only set in INIT */ 693 unsigned conn_init:1; 694 695 /** Do readahead asynchronously? Only set in INIT */ 696 unsigned async_read:1; 697 698 /** Return an unique read error after abort. Only set in INIT */ 699 unsigned abort_err:1; 700 701 /** Do not send separate SETATTR request before open(O_TRUNC) */ 702 unsigned atomic_o_trunc:1; 703 704 /** Filesystem supports NFS exporting. Only set in INIT */ 705 unsigned export_support:1; 706 707 /** write-back cache policy (default is write-through) */ 708 unsigned writeback_cache:1; 709 710 /** allow parallel lookups and readdir (default is serialized) */ 711 unsigned parallel_dirops:1; 712 713 /** handle fs handles killing suid/sgid/cap on write/chown/trunc */ 714 unsigned handle_killpriv:1; 715 716 /** cache READLINK responses in page cache */ 717 unsigned cache_symlinks:1; 718 719 /* show legacy mount options */ 720 unsigned int legacy_opts_show:1; 721 722 /* 723 * fs kills suid/sgid/cap on write/chown/trunc. suid is killed on 724 * write/trunc only if caller did not have CAP_FSETID. sgid is killed 725 * on write/truncate only if caller did not have CAP_FSETID as well as 726 * file has group execute permission. 727 */ 728 unsigned handle_killpriv_v2:1; 729 730 /* 731 * The following bitfields are only for optimization purposes 732 * and hence races in setting them will not cause malfunction 733 */ 734 735 /** Is open/release not implemented by fs? */ 736 unsigned no_open:1; 737 738 /** Is opendir/releasedir not implemented by fs? */ 739 unsigned no_opendir:1; 740 741 /** Is fsync not implemented by fs? */ 742 unsigned no_fsync:1; 743 744 /** Is fsyncdir not implemented by fs? */ 745 unsigned no_fsyncdir:1; 746 747 /** Is flush not implemented by fs? */ 748 unsigned no_flush:1; 749 750 /** Is setxattr not implemented by fs? */ 751 unsigned no_setxattr:1; 752 753 /** Does file server support extended setxattr */ 754 unsigned setxattr_ext:1; 755 756 /** Is getxattr not implemented by fs? */ 757 unsigned no_getxattr:1; 758 759 /** Is listxattr not implemented by fs? */ 760 unsigned no_listxattr:1; 761 762 /** Is removexattr not implemented by fs? */ 763 unsigned no_removexattr:1; 764 765 /** Are posix file locking primitives not implemented by fs? */ 766 unsigned no_lock:1; 767 768 /** Is access not implemented by fs? */ 769 unsigned no_access:1; 770 771 /** Is create not implemented by fs? */ 772 unsigned no_create:1; 773 774 /** Is interrupt not implemented by fs? */ 775 unsigned no_interrupt:1; 776 777 /** Is bmap not implemented by fs? */ 778 unsigned no_bmap:1; 779 780 /** Is poll not implemented by fs? */ 781 unsigned no_poll:1; 782 783 /** Do multi-page cached writes */ 784 unsigned big_writes:1; 785 786 /** Don't apply umask to creation modes */ 787 unsigned dont_mask:1; 788 789 /** Are BSD file locking primitives not implemented by fs? */ 790 unsigned no_flock:1; 791 792 /** Is fallocate not implemented by fs? */ 793 unsigned no_fallocate:1; 794 795 /** Is rename with flags implemented by fs? */ 796 unsigned no_rename2:1; 797 798 /** Use enhanced/automatic page cache invalidation. */ 799 unsigned auto_inval_data:1; 800 801 /** Filesystem is fully responsible for page cache invalidation. */ 802 unsigned explicit_inval_data:1; 803 804 /** Does the filesystem support readdirplus? */ 805 unsigned do_readdirplus:1; 806 807 /** Does the filesystem want adaptive readdirplus? */ 808 unsigned readdirplus_auto:1; 809 810 /** Does the filesystem support asynchronous direct-IO submission? */ 811 unsigned async_dio:1; 812 813 /** Is lseek not implemented by fs? */ 814 unsigned no_lseek:1; 815 816 /** Does the filesystem support posix acls? */ 817 unsigned posix_acl:1; 818 819 /** Check permissions based on the file mode or not? */ 820 unsigned default_permissions:1; 821 822 /** Allow other than the mounter user to access the filesystem ? */ 823 unsigned allow_other:1; 824 825 /** Does the filesystem support copy_file_range? */ 826 unsigned no_copy_file_range:1; 827 828 /* Send DESTROY request */ 829 unsigned int destroy:1; 830 831 /* Delete dentries that have gone stale */ 832 unsigned int delete_stale:1; 833 834 /** Do not create entry in fusectl fs */ 835 unsigned int no_control:1; 836 837 /** Do not allow MNT_FORCE umount */ 838 unsigned int no_force_umount:1; 839 840 /* Auto-mount submounts announced by the server */ 841 unsigned int auto_submounts:1; 842 843 /* Propagate syncfs() to server */ 844 unsigned int sync_fs:1; 845 846 /* Initialize security xattrs when creating a new inode */ 847 unsigned int init_security:1; 848 849 /* Add supplementary group info when creating a new inode */ 850 unsigned int create_supp_group:1; 851 852 /* Does the filesystem support per inode DAX? */ 853 unsigned int inode_dax:1; 854 855 /* Is tmpfile not implemented by fs? */ 856 unsigned int no_tmpfile:1; 857 858 /* Relax restrictions to allow shared mmap in FOPEN_DIRECT_IO mode */ 859 unsigned int direct_io_allow_mmap:1; 860 861 /* Is statx not implemented by fs? */ 862 unsigned int no_statx:1; 863 864 /** Passthrough support for read/write IO */ 865 unsigned int passthrough:1; 866 867 /* Use pages instead of pointer for kernel I/O */ 868 unsigned int use_pages_for_kvec_io:1; 869 870 /* Use io_uring for communication */ 871 unsigned int io_uring; 872 873 /** Maximum stack depth for passthrough backing files */ 874 int max_stack_depth; 875 876 /** The number of requests waiting for completion */ 877 atomic_t num_waiting; 878 879 /** Negotiated minor version */ 880 unsigned minor; 881 882 /** Entry on the fuse_conn_list */ 883 struct list_head entry; 884 885 /** Device ID from the root super block */ 886 dev_t dev; 887 888 /** Dentries in the control filesystem */ 889 struct dentry *ctl_dentry[FUSE_CTL_NUM_DENTRIES]; 890 891 /** number of dentries used in the above array */ 892 int ctl_ndents; 893 894 /** Key for lock owner ID scrambling */ 895 u32 scramble_key[4]; 896 897 /** Version counter for attribute changes */ 898 atomic64_t attr_version; 899 900 /** Version counter for evict inode */ 901 atomic64_t evict_ctr; 902 903 /** Called on final put */ 904 void (*release)(struct fuse_conn *); 905 906 /** 907 * Read/write semaphore to hold when accessing the sb of any 908 * fuse_mount belonging to this connection 909 */ 910 struct rw_semaphore killsb; 911 912 /** List of device instances belonging to this connection */ 913 struct list_head devices; 914 915 #ifdef CONFIG_FUSE_DAX 916 /* Dax mode */ 917 enum fuse_dax_mode dax_mode; 918 919 /* Dax specific conn data, non-NULL if DAX is enabled */ 920 struct fuse_conn_dax *dax; 921 #endif 922 923 /** List of filesystems using this connection */ 924 struct list_head mounts; 925 926 /* New writepages go into this bucket */ 927 struct fuse_sync_bucket __rcu *curr_bucket; 928 929 #ifdef CONFIG_FUSE_PASSTHROUGH 930 /** IDR for backing files ids */ 931 struct idr backing_files_map; 932 #endif 933 934 #ifdef CONFIG_FUSE_IO_URING 935 /** uring connection information*/ 936 struct fuse_ring *ring; 937 #endif 938 }; 939 940 /* 941 * Represents a mounted filesystem, potentially a submount. 942 * 943 * This object allows sharing a fuse_conn between separate mounts to 944 * allow submounts with dedicated superblocks and thus separate device 945 * IDs. 946 */ 947 struct fuse_mount { 948 /* Underlying (potentially shared) connection to the FUSE server */ 949 struct fuse_conn *fc; 950 951 /* 952 * Super block for this connection (fc->killsb must be held when 953 * accessing this). 954 */ 955 struct super_block *sb; 956 957 /* Entry on fc->mounts */ 958 struct list_head fc_entry; 959 struct rcu_head rcu; 960 }; 961 962 /* 963 * Empty header for FUSE opcodes without specific header needs. 964 * Used as a placeholder in args->in_args[0] for consistency 965 * across all FUSE operations, simplifying request handling. 966 */ 967 struct fuse_zero_header {}; 968 969 static inline void fuse_set_zero_arg0(struct fuse_args *args) 970 { 971 args->in_args[0].size = sizeof(struct fuse_zero_header); 972 args->in_args[0].value = NULL; 973 } 974 975 static inline struct fuse_mount *get_fuse_mount_super(struct super_block *sb) 976 { 977 return sb->s_fs_info; 978 } 979 980 static inline struct fuse_conn *get_fuse_conn_super(struct super_block *sb) 981 { 982 return get_fuse_mount_super(sb)->fc; 983 } 984 985 static inline struct fuse_mount *get_fuse_mount(struct inode *inode) 986 { 987 return get_fuse_mount_super(inode->i_sb); 988 } 989 990 static inline struct fuse_conn *get_fuse_conn(struct inode *inode) 991 { 992 return get_fuse_mount_super(inode->i_sb)->fc; 993 } 994 995 static inline struct fuse_inode *get_fuse_inode(struct inode *inode) 996 { 997 return container_of(inode, struct fuse_inode, inode); 998 } 999 1000 static inline u64 get_node_id(struct inode *inode) 1001 { 1002 return get_fuse_inode(inode)->nodeid; 1003 } 1004 1005 static inline int invalid_nodeid(u64 nodeid) 1006 { 1007 return !nodeid || nodeid == FUSE_ROOT_ID; 1008 } 1009 1010 static inline u64 fuse_get_attr_version(struct fuse_conn *fc) 1011 { 1012 return atomic64_read(&fc->attr_version); 1013 } 1014 1015 static inline u64 fuse_get_evict_ctr(struct fuse_conn *fc) 1016 { 1017 return atomic64_read(&fc->evict_ctr); 1018 } 1019 1020 static inline bool fuse_stale_inode(const struct inode *inode, int generation, 1021 struct fuse_attr *attr) 1022 { 1023 return inode->i_generation != generation || 1024 inode_wrong_type(inode, attr->mode); 1025 } 1026 1027 static inline void fuse_make_bad(struct inode *inode) 1028 { 1029 set_bit(FUSE_I_BAD, &get_fuse_inode(inode)->state); 1030 } 1031 1032 static inline bool fuse_is_bad(struct inode *inode) 1033 { 1034 return unlikely(test_bit(FUSE_I_BAD, &get_fuse_inode(inode)->state)); 1035 } 1036 1037 static inline struct folio **fuse_folios_alloc(unsigned int nfolios, gfp_t flags, 1038 struct fuse_folio_desc **desc) 1039 { 1040 struct folio **folios; 1041 1042 folios = kzalloc(nfolios * (sizeof(struct folio *) + 1043 sizeof(struct fuse_folio_desc)), flags); 1044 *desc = (void *) (folios + nfolios); 1045 1046 return folios; 1047 } 1048 1049 static inline void fuse_folio_descs_length_init(struct fuse_folio_desc *descs, 1050 unsigned int index, 1051 unsigned int nr_folios) 1052 { 1053 int i; 1054 1055 for (i = index; i < index + nr_folios; i++) 1056 descs[i].length = PAGE_SIZE - descs[i].offset; 1057 } 1058 1059 static inline void fuse_sync_bucket_dec(struct fuse_sync_bucket *bucket) 1060 { 1061 /* Need RCU protection to prevent use after free after the decrement */ 1062 rcu_read_lock(); 1063 if (atomic_dec_and_test(&bucket->count)) 1064 wake_up(&bucket->waitq); 1065 rcu_read_unlock(); 1066 } 1067 1068 /** Device operations */ 1069 extern const struct file_operations fuse_dev_operations; 1070 1071 extern const struct dentry_operations fuse_dentry_operations; 1072 extern const struct dentry_operations fuse_root_dentry_operations; 1073 1074 /** 1075 * Get a filled in inode 1076 */ 1077 struct inode *fuse_iget(struct super_block *sb, u64 nodeid, 1078 int generation, struct fuse_attr *attr, 1079 u64 attr_valid, u64 attr_version, 1080 u64 evict_ctr); 1081 1082 int fuse_lookup_name(struct super_block *sb, u64 nodeid, const struct qstr *name, 1083 struct fuse_entry_out *outarg, struct inode **inode); 1084 1085 /** 1086 * Send FORGET command 1087 */ 1088 void fuse_queue_forget(struct fuse_conn *fc, struct fuse_forget_link *forget, 1089 u64 nodeid, u64 nlookup); 1090 1091 struct fuse_forget_link *fuse_alloc_forget(void); 1092 1093 /* 1094 * Initialize READ or READDIR request 1095 */ 1096 struct fuse_io_args { 1097 union { 1098 struct { 1099 struct fuse_read_in in; 1100 u64 attr_ver; 1101 } read; 1102 struct { 1103 struct fuse_write_in in; 1104 struct fuse_write_out out; 1105 bool folio_locked; 1106 } write; 1107 }; 1108 struct fuse_args_pages ap; 1109 struct fuse_io_priv *io; 1110 struct fuse_file *ff; 1111 }; 1112 1113 void fuse_read_args_fill(struct fuse_io_args *ia, struct file *file, loff_t pos, 1114 size_t count, int opcode); 1115 1116 1117 struct fuse_file *fuse_file_alloc(struct fuse_mount *fm, bool release); 1118 void fuse_file_free(struct fuse_file *ff); 1119 int fuse_finish_open(struct inode *inode, struct file *file); 1120 1121 void fuse_sync_release(struct fuse_inode *fi, struct fuse_file *ff, 1122 unsigned int flags); 1123 1124 /** 1125 * Send RELEASE or RELEASEDIR request 1126 */ 1127 void fuse_release_common(struct file *file, bool isdir); 1128 1129 /** 1130 * Send FSYNC or FSYNCDIR request 1131 */ 1132 int fuse_fsync_common(struct file *file, loff_t start, loff_t end, 1133 int datasync, int opcode); 1134 1135 /** 1136 * Notify poll wakeup 1137 */ 1138 int fuse_notify_poll_wakeup(struct fuse_conn *fc, 1139 struct fuse_notify_poll_wakeup_out *outarg); 1140 1141 /** 1142 * Initialize file operations on a regular file 1143 */ 1144 void fuse_init_file_inode(struct inode *inode, unsigned int flags); 1145 1146 /** 1147 * Initialize inode operations on regular files and special files 1148 */ 1149 void fuse_init_common(struct inode *inode); 1150 1151 /** 1152 * Initialize inode and file operations on a directory 1153 */ 1154 void fuse_init_dir(struct inode *inode); 1155 1156 /** 1157 * Initialize inode operations on a symlink 1158 */ 1159 void fuse_init_symlink(struct inode *inode); 1160 1161 /** 1162 * Change attributes of an inode 1163 */ 1164 void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr, 1165 struct fuse_statx *sx, 1166 u64 attr_valid, u64 attr_version); 1167 1168 void fuse_change_attributes_common(struct inode *inode, struct fuse_attr *attr, 1169 struct fuse_statx *sx, 1170 u64 attr_valid, u32 cache_mask, 1171 u64 evict_ctr); 1172 1173 u32 fuse_get_cache_mask(struct inode *inode); 1174 1175 /** 1176 * Initialize the client device 1177 */ 1178 int fuse_dev_init(void); 1179 1180 /** 1181 * Cleanup the client device 1182 */ 1183 void fuse_dev_cleanup(void); 1184 1185 int fuse_ctl_init(void); 1186 void __exit fuse_ctl_cleanup(void); 1187 1188 /** 1189 * Simple request sending that does request allocation and freeing 1190 */ 1191 ssize_t __fuse_simple_request(struct mnt_idmap *idmap, 1192 struct fuse_mount *fm, 1193 struct fuse_args *args); 1194 1195 static inline ssize_t fuse_simple_request(struct fuse_mount *fm, struct fuse_args *args) 1196 { 1197 return __fuse_simple_request(&invalid_mnt_idmap, fm, args); 1198 } 1199 1200 static inline ssize_t fuse_simple_idmap_request(struct mnt_idmap *idmap, 1201 struct fuse_mount *fm, 1202 struct fuse_args *args) 1203 { 1204 return __fuse_simple_request(idmap, fm, args); 1205 } 1206 1207 int fuse_simple_background(struct fuse_mount *fm, struct fuse_args *args, 1208 gfp_t gfp_flags); 1209 1210 /** 1211 * End a finished request 1212 */ 1213 void fuse_request_end(struct fuse_req *req); 1214 1215 /* Abort all requests */ 1216 void fuse_abort_conn(struct fuse_conn *fc); 1217 void fuse_wait_aborted(struct fuse_conn *fc); 1218 1219 /** 1220 * Invalidate inode attributes 1221 */ 1222 1223 /* Attributes possibly changed on data modification */ 1224 #define FUSE_STATX_MODIFY (STATX_MTIME | STATX_CTIME | STATX_BLOCKS) 1225 1226 /* Attributes possibly changed on data and/or size modification */ 1227 #define FUSE_STATX_MODSIZE (FUSE_STATX_MODIFY | STATX_SIZE) 1228 1229 void fuse_invalidate_attr(struct inode *inode); 1230 void fuse_invalidate_attr_mask(struct inode *inode, u32 mask); 1231 1232 void fuse_invalidate_entry_cache(struct dentry *entry); 1233 1234 void fuse_invalidate_atime(struct inode *inode); 1235 1236 u64 fuse_time_to_jiffies(u64 sec, u32 nsec); 1237 #define ATTR_TIMEOUT(o) \ 1238 fuse_time_to_jiffies((o)->attr_valid, (o)->attr_valid_nsec) 1239 1240 void fuse_change_entry_timeout(struct dentry *entry, struct fuse_entry_out *o); 1241 1242 /** 1243 * Acquire reference to fuse_conn 1244 */ 1245 struct fuse_conn *fuse_conn_get(struct fuse_conn *fc); 1246 1247 /** 1248 * Initialize the fuse processing queue 1249 */ 1250 void fuse_pqueue_init(struct fuse_pqueue *fpq); 1251 1252 /** 1253 * Initialize fuse_conn 1254 */ 1255 void fuse_conn_init(struct fuse_conn *fc, struct fuse_mount *fm, 1256 struct user_namespace *user_ns, 1257 const struct fuse_iqueue_ops *fiq_ops, void *fiq_priv); 1258 1259 /** 1260 * Release reference to fuse_conn 1261 */ 1262 void fuse_conn_put(struct fuse_conn *fc); 1263 1264 struct fuse_dev *fuse_dev_alloc_install(struct fuse_conn *fc); 1265 struct fuse_dev *fuse_dev_alloc(void); 1266 void fuse_dev_install(struct fuse_dev *fud, struct fuse_conn *fc); 1267 void fuse_dev_free(struct fuse_dev *fud); 1268 void fuse_send_init(struct fuse_mount *fm); 1269 1270 /** 1271 * Fill in superblock and initialize fuse connection 1272 * @sb: partially-initialized superblock to fill in 1273 * @ctx: mount context 1274 */ 1275 int fuse_fill_super_common(struct super_block *sb, struct fuse_fs_context *ctx); 1276 1277 /* 1278 * Remove the mount from the connection 1279 * 1280 * Returns whether this was the last mount 1281 */ 1282 bool fuse_mount_remove(struct fuse_mount *fm); 1283 1284 /* 1285 * Setup context ops for submounts 1286 */ 1287 int fuse_init_fs_context_submount(struct fs_context *fsc); 1288 1289 /* 1290 * Shut down the connection (possibly sending DESTROY request). 1291 */ 1292 void fuse_conn_destroy(struct fuse_mount *fm); 1293 1294 /* Drop the connection and free the fuse mount */ 1295 void fuse_mount_destroy(struct fuse_mount *fm); 1296 1297 /** 1298 * Add connection to control filesystem 1299 */ 1300 int fuse_ctl_add_conn(struct fuse_conn *fc); 1301 1302 /** 1303 * Remove connection from control filesystem 1304 */ 1305 void fuse_ctl_remove_conn(struct fuse_conn *fc); 1306 1307 /** 1308 * Is file type valid? 1309 */ 1310 int fuse_valid_type(int m); 1311 1312 bool fuse_invalid_attr(struct fuse_attr *attr); 1313 1314 /** 1315 * Is current process allowed to perform filesystem operation? 1316 */ 1317 bool fuse_allow_current_process(struct fuse_conn *fc); 1318 1319 u64 fuse_lock_owner_id(struct fuse_conn *fc, fl_owner_t id); 1320 1321 void fuse_flush_time_update(struct inode *inode); 1322 void fuse_update_ctime(struct inode *inode); 1323 1324 int fuse_update_attributes(struct inode *inode, struct file *file, u32 mask); 1325 1326 void fuse_flush_writepages(struct inode *inode); 1327 1328 void fuse_set_nowrite(struct inode *inode); 1329 void fuse_release_nowrite(struct inode *inode); 1330 1331 /** 1332 * Scan all fuse_mounts belonging to fc to find the first where 1333 * ilookup5() returns a result. Return that result and the 1334 * respective fuse_mount in *fm (unless fm is NULL). 1335 * 1336 * The caller must hold fc->killsb. 1337 */ 1338 struct inode *fuse_ilookup(struct fuse_conn *fc, u64 nodeid, 1339 struct fuse_mount **fm); 1340 1341 /** 1342 * File-system tells the kernel to invalidate cache for the given node id. 1343 */ 1344 int fuse_reverse_inval_inode(struct fuse_conn *fc, u64 nodeid, 1345 loff_t offset, loff_t len); 1346 1347 /** 1348 * File-system tells the kernel to invalidate parent attributes and 1349 * the dentry matching parent/name. 1350 * 1351 * If the child_nodeid is non-zero and: 1352 * - matches the inode number for the dentry matching parent/name, 1353 * - is not a mount point 1354 * - is a file or oan empty directory 1355 * then the dentry is unhashed (d_delete()). 1356 */ 1357 int fuse_reverse_inval_entry(struct fuse_conn *fc, u64 parent_nodeid, 1358 u64 child_nodeid, struct qstr *name, u32 flags); 1359 1360 int fuse_do_open(struct fuse_mount *fm, u64 nodeid, struct file *file, 1361 bool isdir); 1362 1363 /** 1364 * fuse_direct_io() flags 1365 */ 1366 1367 /** If set, it is WRITE; otherwise - READ */ 1368 #define FUSE_DIO_WRITE (1 << 0) 1369 1370 /** CUSE pass fuse_direct_io() a file which f_mapping->host is not from FUSE */ 1371 #define FUSE_DIO_CUSE (1 << 1) 1372 1373 ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter, 1374 loff_t *ppos, int flags); 1375 long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg, 1376 unsigned int flags); 1377 long fuse_ioctl_common(struct file *file, unsigned int cmd, 1378 unsigned long arg, unsigned int flags); 1379 __poll_t fuse_file_poll(struct file *file, poll_table *wait); 1380 int fuse_dev_release(struct inode *inode, struct file *file); 1381 1382 bool fuse_write_update_attr(struct inode *inode, loff_t pos, ssize_t written); 1383 1384 int fuse_flush_times(struct inode *inode, struct fuse_file *ff); 1385 int fuse_write_inode(struct inode *inode, struct writeback_control *wbc); 1386 1387 int fuse_do_setattr(struct mnt_idmap *idmap, struct dentry *dentry, 1388 struct iattr *attr, struct file *file); 1389 1390 void fuse_set_initialized(struct fuse_conn *fc); 1391 1392 void fuse_unlock_inode(struct inode *inode, bool locked); 1393 bool fuse_lock_inode(struct inode *inode); 1394 1395 int fuse_setxattr(struct inode *inode, const char *name, const void *value, 1396 size_t size, int flags, unsigned int extra_flags); 1397 ssize_t fuse_getxattr(struct inode *inode, const char *name, void *value, 1398 size_t size); 1399 ssize_t fuse_listxattr(struct dentry *entry, char *list, size_t size); 1400 int fuse_removexattr(struct inode *inode, const char *name); 1401 extern const struct xattr_handler * const fuse_xattr_handlers[]; 1402 1403 struct posix_acl; 1404 struct posix_acl *fuse_get_inode_acl(struct inode *inode, int type, bool rcu); 1405 struct posix_acl *fuse_get_acl(struct mnt_idmap *idmap, 1406 struct dentry *dentry, int type); 1407 int fuse_set_acl(struct mnt_idmap *, struct dentry *dentry, 1408 struct posix_acl *acl, int type); 1409 1410 /* readdir.c */ 1411 int fuse_readdir(struct file *file, struct dir_context *ctx); 1412 1413 /** 1414 * Return the number of bytes in an arguments list 1415 */ 1416 unsigned int fuse_len_args(unsigned int numargs, struct fuse_arg *args); 1417 1418 /** 1419 * Get the next unique ID for a request 1420 */ 1421 u64 fuse_get_unique(struct fuse_iqueue *fiq); 1422 void fuse_free_conn(struct fuse_conn *fc); 1423 1424 /* dax.c */ 1425 1426 #define FUSE_IS_DAX(inode) (IS_ENABLED(CONFIG_FUSE_DAX) && IS_DAX(inode)) 1427 1428 ssize_t fuse_dax_read_iter(struct kiocb *iocb, struct iov_iter *to); 1429 ssize_t fuse_dax_write_iter(struct kiocb *iocb, struct iov_iter *from); 1430 int fuse_dax_mmap(struct file *file, struct vm_area_struct *vma); 1431 int fuse_dax_break_layouts(struct inode *inode, u64 dmap_start, u64 dmap_end); 1432 int fuse_dax_conn_alloc(struct fuse_conn *fc, enum fuse_dax_mode mode, 1433 struct dax_device *dax_dev); 1434 void fuse_dax_conn_free(struct fuse_conn *fc); 1435 bool fuse_dax_inode_alloc(struct super_block *sb, struct fuse_inode *fi); 1436 void fuse_dax_inode_init(struct inode *inode, unsigned int flags); 1437 void fuse_dax_inode_cleanup(struct inode *inode); 1438 void fuse_dax_dontcache(struct inode *inode, unsigned int flags); 1439 bool fuse_dax_check_alignment(struct fuse_conn *fc, unsigned int map_alignment); 1440 void fuse_dax_cancel_work(struct fuse_conn *fc); 1441 1442 /* ioctl.c */ 1443 long fuse_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg); 1444 long fuse_file_compat_ioctl(struct file *file, unsigned int cmd, 1445 unsigned long arg); 1446 int fuse_fileattr_get(struct dentry *dentry, struct fileattr *fa); 1447 int fuse_fileattr_set(struct mnt_idmap *idmap, 1448 struct dentry *dentry, struct fileattr *fa); 1449 1450 /* iomode.c */ 1451 int fuse_file_cached_io_open(struct inode *inode, struct fuse_file *ff); 1452 int fuse_inode_uncached_io_start(struct fuse_inode *fi, 1453 struct fuse_backing *fb); 1454 void fuse_inode_uncached_io_end(struct fuse_inode *fi); 1455 1456 int fuse_file_io_open(struct file *file, struct inode *inode); 1457 void fuse_file_io_release(struct fuse_file *ff, struct inode *inode); 1458 1459 /* file.c */ 1460 struct fuse_file *fuse_file_open(struct fuse_mount *fm, u64 nodeid, 1461 unsigned int open_flags, bool isdir); 1462 void fuse_file_release(struct inode *inode, struct fuse_file *ff, 1463 unsigned int open_flags, fl_owner_t id, bool isdir); 1464 1465 /* passthrough.c */ 1466 static inline struct fuse_backing *fuse_inode_backing(struct fuse_inode *fi) 1467 { 1468 #ifdef CONFIG_FUSE_PASSTHROUGH 1469 return READ_ONCE(fi->fb); 1470 #else 1471 return NULL; 1472 #endif 1473 } 1474 1475 static inline struct fuse_backing *fuse_inode_backing_set(struct fuse_inode *fi, 1476 struct fuse_backing *fb) 1477 { 1478 #ifdef CONFIG_FUSE_PASSTHROUGH 1479 return xchg(&fi->fb, fb); 1480 #else 1481 return NULL; 1482 #endif 1483 } 1484 1485 #ifdef CONFIG_FUSE_PASSTHROUGH 1486 struct fuse_backing *fuse_backing_get(struct fuse_backing *fb); 1487 void fuse_backing_put(struct fuse_backing *fb); 1488 #else 1489 1490 static inline struct fuse_backing *fuse_backing_get(struct fuse_backing *fb) 1491 { 1492 return NULL; 1493 } 1494 1495 static inline void fuse_backing_put(struct fuse_backing *fb) 1496 { 1497 } 1498 #endif 1499 1500 void fuse_backing_files_init(struct fuse_conn *fc); 1501 void fuse_backing_files_free(struct fuse_conn *fc); 1502 int fuse_backing_open(struct fuse_conn *fc, struct fuse_backing_map *map); 1503 int fuse_backing_close(struct fuse_conn *fc, int backing_id); 1504 1505 struct fuse_backing *fuse_passthrough_open(struct file *file, 1506 struct inode *inode, 1507 int backing_id); 1508 void fuse_passthrough_release(struct fuse_file *ff, struct fuse_backing *fb); 1509 1510 static inline struct file *fuse_file_passthrough(struct fuse_file *ff) 1511 { 1512 #ifdef CONFIG_FUSE_PASSTHROUGH 1513 return ff->passthrough; 1514 #else 1515 return NULL; 1516 #endif 1517 } 1518 1519 ssize_t fuse_passthrough_read_iter(struct kiocb *iocb, struct iov_iter *iter); 1520 ssize_t fuse_passthrough_write_iter(struct kiocb *iocb, struct iov_iter *iter); 1521 ssize_t fuse_passthrough_splice_read(struct file *in, loff_t *ppos, 1522 struct pipe_inode_info *pipe, 1523 size_t len, unsigned int flags); 1524 ssize_t fuse_passthrough_splice_write(struct pipe_inode_info *pipe, 1525 struct file *out, loff_t *ppos, 1526 size_t len, unsigned int flags); 1527 ssize_t fuse_passthrough_mmap(struct file *file, struct vm_area_struct *vma); 1528 1529 #ifdef CONFIG_SYSCTL 1530 extern int fuse_sysctl_register(void); 1531 extern void fuse_sysctl_unregister(void); 1532 #else 1533 #define fuse_sysctl_register() (0) 1534 #define fuse_sysctl_unregister() do { } while (0) 1535 #endif /* CONFIG_SYSCTL */ 1536 1537 #endif /* _FS_FUSE_I_H */ 1538