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
12#include <stdbool.h>
13
14#define MIN(a, b) \
15({ \
16 typeof(a) _a = (a); \
17 typeof(b) _b = (b); \
18 _a < _b ? _a : _b; \
19})
20
21 struct mount_opts;
22
23 struct fuse_req {
24 struct fuse_session *se;
25 uint64_t unique;
26 _Atomic int ref_cnt;
27 pthread_mutex_t lock;
28 struct fuse_ctx ctx;
29 struct fuse_chan *ch;
30 int interrupted;
31 unsigned int ioctl_64bit : 1;
32 union {
33 struct {
34 uint64_t unique;
35 } i;
36 struct {
37 fuse_interrupt_func_t func;
38 void *data;
39 } ni;
40 } u;
41 struct fuse_req *next;
42 struct fuse_req *prev;
43};
44
45 struct fuse_notify_req {
46 uint64_t unique;
47 void (*reply)(struct fuse_notify_req *, fuse_req_t, fuse_ino_t,
48 const void *, const struct fuse_buf *);
49 struct fuse_notify_req *next;
50 struct fuse_notify_req *prev;
51};
52
53 struct fuse_session {
54 char *mountpoint;
55 volatile int exited;
56 int fd;
57 struct fuse_custom_io *io;
58 struct mount_opts *mo;
59 int debug;
60 int deny_others;
61 struct fuse_lowlevel_ops op;
62 int got_init;
63 struct cuse_data *cuse_data;
64 void *userdata;
65 uid_t owner;
66 struct fuse_conn_info conn;
67 struct fuse_req list;
68 struct fuse_req interrupts;
69 pthread_mutex_t lock;
70 int got_destroy;
71 pthread_key_t pipe_key;
72 int broken_splice_nonblock;
73 uint64_t notify_ctr;
74 struct fuse_notify_req notify_list;
75 size_t bufsize;
76 int error;
77
78 /* This is useful if any kind of ABI incompatibility is found at
79 * a later version, to 'fix' it at run time.
80 */
81 struct libfuse_version version;
82 bool buf_reallocable;
83};
84
85 struct fuse_chan {
86 pthread_mutex_t lock;
87 int ctr;
88 int fd;
89};
90
98 struct fuse_module {
99 char *name;
100 fuse_module_factory_t factory;
101 struct fuse_module *next;
102 struct fusemod_so *so;
103 int ctr;
104};
105
114#if FUSE_USE_VERSION >= FUSE_MAKE_VERSION(3, 12)
115 struct fuse_loop_config
116{
117 /* verififier that a correct struct was was passed. This is especially
118 * needed, as versions below (3, 12) were using a public struct
119 * (now called fuse_loop_config_v1), which was hard to extend with
120 * additional parameters, without risking that file system implementations
121 * would not have noticed and might either pass uninitialized members
122 * or even too small structs.
123 * fuse_loop_config_v1 has clone_fd at this offset, which should be either 0
124 * or 1. v2 or even higher version just need to set a value here
125 * which not conflicting and very unlikely as having been set by
126 * file system implementation.
127 */
128 int version_id;
129
134 int clone_fd;
146 int max_idle_threads;
147
153 unsigned int max_threads;
154};
155#endif
156
157/* ----------------------------------------------------------- *
158 * Channel interface (when using -o clone_fd) *
159 * ----------------------------------------------------------- */
160
167 struct fuse_chan *fuse_chan_get(struct fuse_chan *ch);
168
174 void fuse_chan_put(struct fuse_chan *ch);
175
176 struct mount_opts *parse_mount_opts(struct fuse_args *args);
177 void destroy_mount_opts(struct mount_opts *mo);
178 void fuse_mount_version(void);
179 unsigned get_max_read(struct mount_opts *o);
180 void fuse_kern_unmount(const char *mountpoint, int fd);
181 int fuse_kern_mount(const char *mountpoint, struct mount_opts *mo);
182
183 int fuse_send_reply_iov_nofree(fuse_req_t req, int error, struct iovec *iov,
184 int count);
185 void fuse_free_req(fuse_req_t req);
186
187 void cuse_lowlevel_init(fuse_req_t req, fuse_ino_t nodeide, const void *inarg);
188
189 int fuse_start_thread(pthread_t *thread_id, void *(*func)(void *), void *arg);
190
191 void fuse_buf_free(struct fuse_buf *buf);
192
193 int fuse_session_receive_buf_internal(struct fuse_session *se,
194 struct fuse_buf *buf,
195 struct fuse_chan *ch);
196 void fuse_session_process_buf_internal(struct fuse_session *se,
197 const struct fuse_buf *buf,
198 struct fuse_chan *ch);
199
200 struct fuse *fuse_new_31(struct fuse_args *args, const struct fuse_operations *op,
201 size_t op_size, void *private_data);
202 int fuse_loop_mt_312(struct fuse *f, struct fuse_loop_config *config);
203 int fuse_session_loop_mt_312(struct fuse_session *se, struct fuse_loop_config *config);
204
210 int fuse_loop_cfg_verify(struct fuse_loop_config *config);
211
212
213/*
214 * This can be changed dynamically on recent kernels through the
215 * /proc/sys/fs/fuse/max_pages_limit interface.
216 *
217 * Older kernels will always use the default value.
218 */
219#define FUSE_DEFAULT_MAX_PAGES_LIMIT 256
220#define FUSE_DEFAULT_MAX_PAGES_PER_REQ 32
221
222/* room needed in buffer to accommodate header */
223#define FUSE_BUFFER_HEADER_SIZE 0x1000
224
fuse_module_factory_t
struct fuse_fs *(* fuse_module_factory_t)(struct fuse_args *args, struct fuse_fs *fs[])
Definition fuse.h:1403
fuse_interrupt_func_t
void(* fuse_interrupt_func_t)(fuse_req_t req, void *data)
Definition fuse_lowlevel.h:1946
fuse_req_t
struct fuse_req * fuse_req_t
Definition fuse_lowlevel.h:50
fuse_ino_t
uint64_t fuse_ino_t
Definition fuse_lowlevel.h:47
fuse_args
Definition fuse_opt.h:109
fuse_buf
Definition fuse_common.h:893
fuse_conn_info
Definition fuse_common.h:555
fuse_ctx
Definition fuse_lowlevel.h:112
fuse_loop_config
Definition fuse_common.h:149
fuse_loop_config::clone_fd
int clone_fd
Definition fuse_common.h:157
fuse_loop_config::max_threads
unsigned int max_threads
Definition fuse_i.h:153
fuse_loop_config::max_idle_threads
unsigned int max_idle_threads
Definition fuse_common.h:169
fuse_lowlevel_ops
Definition fuse_lowlevel.h:206
fuse_module
Definition fuse_i.h:98
fuse_operations
Definition fuse.h:349
libfuse_version
Definition fuse_common.h:969