libfuse
fuse_i.h
1/*
2 FUSE: Filesystem in Userspace
3 Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
4
5 This program can be distributed under the terms of the GNU LGPLv2.
6 See the file COPYING.LIB
7*/
8
9#include "fuse.h"
10#include "fuse_lowlevel.h"
11#include "util.h"
12
13#include <stdint.h>
14#include <stdbool.h>
15#include <errno.h>
16#include <stdatomic.h>
17
18#define MIN(a, b) \
19({ \
20 typeof(a) _a = (a); \
21 typeof(b) _b = (b); \
22 _a < _b ? _a : _b; \
23})
24
25struct mount_opts;
26
27struct fuse_req {
28 struct fuse_session *se;
29 uint64_t unique;
30 _Atomic int ref_cnt;
31 pthread_mutex_t lock;
32 struct fuse_ctx ctx;
33 struct fuse_chan *ch;
34 int interrupted;
35 unsigned int ioctl_64bit : 1;
36 union {
37 struct {
38 uint64_t unique;
39 } i;
40 struct {
42 void *data;
43 } ni;
44 } u;
45 struct fuse_req *next;
46 struct fuse_req *prev;
47};
48
49struct fuse_notify_req {
50 uint64_t unique;
51 void (*reply)(struct fuse_notify_req *, fuse_req_t, fuse_ino_t,
52 const void *, const struct fuse_buf *);
53 struct fuse_notify_req *next;
54 struct fuse_notify_req *prev;
55};
56
57struct fuse_session {
58 _Atomic(char *)mountpoint;
59 volatile int exited;
60 int fd;
61 struct fuse_custom_io *io;
62 struct mount_opts *mo;
63 int debug;
64 int deny_others;
65 struct fuse_lowlevel_ops op;
66 int got_init;
67 struct cuse_data *cuse_data;
68 void *userdata;
69 uid_t owner;
70 struct fuse_conn_info conn;
71 struct fuse_req list;
72 struct fuse_req interrupts;
73 pthread_mutex_t lock;
74 int got_destroy;
75 pthread_key_t pipe_key;
76 int broken_splice_nonblock;
77 uint64_t notify_ctr;
78 struct fuse_notify_req notify_list;
79 _Atomic size_t bufsize;
80 int error;
81
82 /* This is useful if any kind of ABI incompatibility is found at
83 * a later version, to 'fix' it at run time.
84 */
85 struct libfuse_version version;
86
87 /* true if reading requests from /dev/fuse are handled internally */
88 bool buf_reallocable;
89
90 /*
91 * conn->want and conn_want_ext options set by libfuse , needed
92 * to correctly convert want to want_ext
93 */
94 uint32_t conn_want;
95 uint64_t conn_want_ext;
96};
97
98struct fuse_chan {
99 pthread_mutex_t lock;
100 int ctr;
101 int fd;
102};
103
112 char *name;
113 fuse_module_factory_t factory;
114 struct fuse_module *next;
115 struct fusemod_so *so;
116 int ctr;
117};
118
127#if FUSE_USE_VERSION >= FUSE_MAKE_VERSION(3, 12)
128struct fuse_loop_config
129{
130 /* verififier that a correct struct was was passed. This is especially
131 * needed, as versions below (3, 12) were using a public struct
132 * (now called fuse_loop_config_v1), which was hard to extend with
133 * additional parameters, without risking that file system implementations
134 * would not have noticed and might either pass uninitialized members
135 * or even too small structs.
136 * fuse_loop_config_v1 has clone_fd at this offset, which should be either 0
137 * or 1. v2 or even higher version just need to set a value here
138 * which not conflicting and very unlikely as having been set by
139 * file system implementation.
140 */
141 int version_id;
142
147 int clone_fd;
160
166 unsigned int max_threads;
167};
168#endif
169
170/* ----------------------------------------------------------- *
171 * Channel interface (when using -o clone_fd) *
172 * ----------------------------------------------------------- */
173
180struct fuse_chan *fuse_chan_get(struct fuse_chan *ch);
181
187void fuse_chan_put(struct fuse_chan *ch);
188
189struct mount_opts *parse_mount_opts(struct fuse_args *args);
190void destroy_mount_opts(struct mount_opts *mo);
191void fuse_mount_version(void);
192unsigned get_max_read(struct mount_opts *o);
193void fuse_kern_unmount(const char *mountpoint, int fd);
194int fuse_kern_mount(const char *mountpoint, struct mount_opts *mo);
195
196int fuse_send_reply_iov_nofree(fuse_req_t req, int error, struct iovec *iov,
197 int count);
198void fuse_free_req(fuse_req_t req);
199
200void cuse_lowlevel_init(fuse_req_t req, fuse_ino_t nodeide, const void *inarg);
201
202int fuse_start_thread(pthread_t *thread_id, void *(*func)(void *), void *arg);
203
204void fuse_buf_free(struct fuse_buf *buf);
205
206int fuse_session_receive_buf_internal(struct fuse_session *se,
207 struct fuse_buf *buf,
208 struct fuse_chan *ch);
209void fuse_session_process_buf_internal(struct fuse_session *se,
210 const struct fuse_buf *buf,
211 struct fuse_chan *ch);
212
213struct fuse *fuse_new_31(struct fuse_args *args, const struct fuse_operations *op,
214 size_t op_size, void *private_data);
215int fuse_loop_mt_312(struct fuse *f, struct fuse_loop_config *config);
216int fuse_session_loop_mt_312(struct fuse_session *se, struct fuse_loop_config *config);
217
223int fuse_loop_cfg_verify(struct fuse_loop_config *config);
224
225
226/*
227 * This can be changed dynamically on recent kernels through the
228 * /proc/sys/fs/fuse/max_pages_limit interface.
229 *
230 * Older kernels will always use the default value.
231 */
232#define FUSE_DEFAULT_MAX_PAGES_LIMIT 256
233#define FUSE_DEFAULT_MAX_PAGES_PER_REQ 32
234
235/* room needed in buffer to accommodate header */
236#define FUSE_BUFFER_HEADER_SIZE 0x1000
237
struct fuse_fs *(* fuse_module_factory_t)(struct fuse_args *args, struct fuse_fs *fs[])
Definition fuse.h:1383
void(* fuse_interrupt_func_t)(fuse_req_t req, void *data)
struct fuse_req * fuse_req_t
uint64_t fuse_ino_t
unsigned int max_threads
Definition fuse_i.h:166
int max_idle_threads
Definition fuse_i.h:159