xref: /linux-6.15/fs/fuse/fuse_dev_i.h (revision 38213365)
1 /* SPDX-License-Identifier: GPL-2.0
2  *
3  * FUSE: Filesystem in Userspace
4  * Copyright (C) 2001-2008  Miklos Szeredi <[email protected]>
5  */
6 #ifndef _FS_FUSE_DEV_I_H
7 #define _FS_FUSE_DEV_I_H
8 
9 #include <linux/types.h>
10 
11 /* Ordinary requests have even IDs, while interrupts IDs are odd */
12 #define FUSE_INT_REQ_BIT (1ULL << 0)
13 #define FUSE_REQ_ID_STEP (1ULL << 1)
14 
15 struct fuse_arg;
16 struct fuse_args;
17 struct fuse_pqueue;
18 struct fuse_req;
19 
20 struct fuse_copy_state {
21 	int write;
22 	struct fuse_req *req;
23 	struct iov_iter *iter;
24 	struct pipe_buffer *pipebufs;
25 	struct pipe_buffer *currbuf;
26 	struct pipe_inode_info *pipe;
27 	unsigned long nr_segs;
28 	struct page *pg;
29 	unsigned int len;
30 	unsigned int offset;
31 	unsigned int move_pages:1;
32 	unsigned int is_uring:1;
33 	struct {
34 		unsigned int copied_sz; /* copied size into the user buffer */
35 	} ring;
36 };
37 
38 static inline struct fuse_dev *fuse_get_dev(struct file *file)
39 {
40 	/*
41 	 * Lockless access is OK, because file->private data is set
42 	 * once during mount and is valid until the file is released.
43 	 */
44 	return READ_ONCE(file->private_data);
45 }
46 
47 unsigned int fuse_req_hash(u64 unique);
48 struct fuse_req *fuse_request_find(struct fuse_pqueue *fpq, u64 unique);
49 
50 void fuse_dev_end_requests(struct list_head *head);
51 
52 void fuse_copy_init(struct fuse_copy_state *cs, int write,
53 			   struct iov_iter *iter);
54 int fuse_copy_args(struct fuse_copy_state *cs, unsigned int numargs,
55 		   unsigned int argpages, struct fuse_arg *args,
56 		   int zeroing);
57 int fuse_copy_out_args(struct fuse_copy_state *cs, struct fuse_args *args,
58 		       unsigned int nbytes);
59 
60 #endif
61 
62