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 struct fuse_iqueue;
20 struct fuse_forget_link;
21 
22 struct fuse_copy_state {
23 	int write;
24 	struct fuse_req *req;
25 	struct iov_iter *iter;
26 	struct pipe_buffer *pipebufs;
27 	struct pipe_buffer *currbuf;
28 	struct pipe_inode_info *pipe;
29 	unsigned long nr_segs;
30 	struct page *pg;
31 	unsigned int len;
32 	unsigned int offset;
33 	unsigned int move_pages:1;
34 	unsigned int is_uring:1;
35 	struct {
36 		unsigned int copied_sz; /* copied size into the user buffer */
37 	} ring;
38 };
39 
fuse_get_dev(struct file * file)40 static inline struct fuse_dev *fuse_get_dev(struct file *file)
41 {
42 	/*
43 	 * Lockless access is OK, because file->private data is set
44 	 * once during mount and is valid until the file is released.
45 	 */
46 	return READ_ONCE(file->private_data);
47 }
48 
49 unsigned int fuse_req_hash(u64 unique);
50 struct fuse_req *fuse_request_find(struct fuse_pqueue *fpq, u64 unique);
51 
52 void fuse_dev_end_requests(struct list_head *head);
53 
54 void fuse_copy_init(struct fuse_copy_state *cs, int write,
55 			   struct iov_iter *iter);
56 int fuse_copy_args(struct fuse_copy_state *cs, unsigned int numargs,
57 		   unsigned int argpages, struct fuse_arg *args,
58 		   int zeroing);
59 int fuse_copy_out_args(struct fuse_copy_state *cs, struct fuse_args *args,
60 		       unsigned int nbytes);
61 void fuse_dev_queue_forget(struct fuse_iqueue *fiq,
62 			   struct fuse_forget_link *forget);
63 void fuse_dev_queue_interrupt(struct fuse_iqueue *fiq, struct fuse_req *req);
64 bool fuse_remove_pending_req(struct fuse_req *req, spinlock_t *lock);
65 
66 #endif
67 
68