libfuse: refcount fuse_chan objects
[fuse.git] / lib / fuse_i.h
blob16adc69aa7cd6ac238f370bdf3684c673a2506f3
1 /*
2 FUSE: Filesystem in Userspace
3 Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
5 This program can be distributed under the terms of the GNU LGPLv2.
6 See the file COPYING.LIB
7 */
9 #include "fuse.h"
10 #include "fuse_lowlevel.h"
12 struct fuse_chan;
13 struct fuse_ll;
15 struct fuse_session {
16 struct fuse_ll *f;
18 volatile int exited;
20 struct fuse_chan *ch;
23 struct fuse_chan {
24 struct fuse_session *se;
26 pthread_mutex_t lock;
27 int ctr;
28 int fd;
32 struct fuse_req {
33 struct fuse_ll *f;
34 uint64_t unique;
35 int ctr;
36 pthread_mutex_t lock;
37 struct fuse_ctx ctx;
38 struct fuse_chan *ch;
39 int interrupted;
40 unsigned int ioctl_64bit : 1;
41 union {
42 struct {
43 uint64_t unique;
44 } i;
45 struct {
46 fuse_interrupt_func_t func;
47 void *data;
48 } ni;
49 } u;
50 struct fuse_req *next;
51 struct fuse_req *prev;
54 struct fuse_notify_req {
55 uint64_t unique;
56 void (*reply)(struct fuse_notify_req *, fuse_req_t, fuse_ino_t,
57 const void *, const struct fuse_buf *);
58 struct fuse_notify_req *next;
59 struct fuse_notify_req *prev;
62 struct fuse_ll {
63 int debug;
64 int allow_root;
65 int atomic_o_trunc;
66 int no_remote_posix_lock;
67 int no_remote_flock;
68 int big_writes;
69 int splice_write;
70 int splice_move;
71 int splice_read;
72 int no_splice_write;
73 int no_splice_move;
74 int no_splice_read;
75 int auto_inval_data;
76 int no_auto_inval_data;
77 int no_readdirplus;
78 int no_readdirplus_auto;
79 int async_dio;
80 int no_async_dio;
81 int writeback_cache;
82 int no_writeback_cache;
83 struct fuse_lowlevel_ops op;
84 int got_init;
85 struct cuse_data *cuse_data;
86 void *userdata;
87 uid_t owner;
88 struct fuse_conn_info conn;
89 struct fuse_req list;
90 struct fuse_req interrupts;
91 pthread_mutex_t lock;
92 int got_destroy;
93 pthread_key_t pipe_key;
94 int broken_splice_nonblock;
95 uint64_t notify_ctr;
96 struct fuse_notify_req notify_list;
97 size_t bufsize;
101 * Filesystem module
103 * Filesystem modules are registered with the FUSE_REGISTER_MODULE()
104 * macro.
107 struct fuse_module {
108 char *name;
109 fuse_module_factory_t factory;
110 struct fuse_module *next;
111 struct fusemod_so *so;
112 int ctr;
115 int fuse_chan_clearfd(struct fuse_chan *ch);
116 void fuse_chan_close(struct fuse_chan *ch);
119 * Create a new session
121 * @return new session object, or NULL on failure
123 struct fuse_session *fuse_session_new(void);
126 * Create a new channel
128 * @param op channel operations
129 * @param fd file descriptor of the channel
130 * @return the new channel object, or NULL on failure
132 struct fuse_chan *fuse_chan_new(int fd);
135 * Query the session to which this channel is assigned
137 * @param ch the channel
138 * @return the session, or NULL if the channel is not assigned
140 struct fuse_session *fuse_chan_session(struct fuse_chan *ch);
142 void fuse_kern_unmount(const char *mountpoint, int fd);
143 int fuse_kern_mount(const char *mountpoint, struct fuse_args *args);
145 int fuse_send_reply_iov_nofree(fuse_req_t req, int error, struct iovec *iov,
146 int count);
147 void fuse_free_req(fuse_req_t req);
149 void cuse_lowlevel_init(fuse_req_t req, fuse_ino_t nodeide, const void *inarg);
151 int fuse_start_thread(pthread_t *thread_id, void *(*func)(void *), void *arg);