blob: 35accfdd747f9fde9c561c4fc081939efadd5497 [file] [log] [blame]
Miklos Szeredid8a5ba42005-09-09 13:10:26 -07001/*
2 FUSE: Filesystem in Userspace
Miklos Szeredid7133112006-04-10 22:54:55 -07003 Copyright (C) 2001-2006 Miklos Szeredi <miklos@szeredi.hu>
Miklos Szeredid8a5ba42005-09-09 13:10:26 -07004
5 This program can be distributed under the terms of the GNU GPL.
6 See the file COPYING.
7*/
8
Tejun Heo29d434b2008-10-16 16:08:57 +02009#ifndef _FS_FUSE_I_H
10#define _FS_FUSE_I_H
11
Miklos Szeredid8a5ba42005-09-09 13:10:26 -070012#include <linux/fuse.h>
13#include <linux/fs.h>
Miklos Szeredi51eb01e2006-06-25 05:48:50 -070014#include <linux/mount.h>
Miklos Szeredid8a5ba42005-09-09 13:10:26 -070015#include <linux/wait.h>
16#include <linux/list.h>
17#include <linux/spinlock.h>
18#include <linux/mm.h>
19#include <linux/backing-dev.h>
Miklos Szeredibafa9652006-06-25 05:48:51 -070020#include <linux/mutex.h>
Miklos Szeredi3be5a522008-04-30 00:54:41 -070021#include <linux/rwsem.h>
Miklos Szeredid8a5ba42005-09-09 13:10:26 -070022
Miklos Szeredi334f4852005-09-09 13:10:27 -070023/** Max number of pages that can be used in a single read request */
24#define FUSE_MAX_PAGES_PER_REQ 32
25
Miklos Szeredi08a53cd2006-04-10 22:54:59 -070026/** Maximum number of outstanding background requests */
Miklos Szeredif92b99b2007-10-16 23:30:59 -070027#define FUSE_MAX_BACKGROUND 12
28
29/** Congestion starts at 75% of maximum */
30#define FUSE_CONGESTION_THRESHOLD (FUSE_MAX_BACKGROUND * 75 / 100)
Miklos Szeredi08a53cd2006-04-10 22:54:59 -070031
Miklos Szeredi3be5a522008-04-30 00:54:41 -070032/** Bias for fi->writectr, meaning new writepages must not be sent */
33#define FUSE_NOWRITE INT_MIN
34
Miklos Szeredi1d3d7522006-01-06 00:19:40 -080035/** It could be as large as PATH_MAX, but would that have any uses? */
36#define FUSE_NAME_MAX 1024
37
Miklos Szeredibafa9652006-06-25 05:48:51 -070038/** Number of dentries for each connection in the control filesystem */
39#define FUSE_CTL_NUM_DENTRIES 3
40
Miklos Szeredi1e9a4ed2005-09-09 13:10:31 -070041/** If the FUSE_DEFAULT_PERMISSIONS flag is given, the filesystem
42 module will check permissions based on the file mode. Otherwise no
43 permission checking is done in the kernel */
44#define FUSE_DEFAULT_PERMISSIONS (1 << 0)
45
46/** If the FUSE_ALLOW_OTHER flag is given, then not only the user
47 doing the mount will be allowed to access the filesystem */
48#define FUSE_ALLOW_OTHER (1 << 1)
49
Miklos Szeredibafa9652006-06-25 05:48:51 -070050/** List of active connections */
51extern struct list_head fuse_conn_list;
52
53/** Global mutex protecting fuse_conn_list and the control filesystem */
54extern struct mutex fuse_mutex;
Miklos Szeredi413ef8c2005-09-09 13:10:35 -070055
Miklos Szeredid8a5ba42005-09-09 13:10:26 -070056/** FUSE inode */
57struct fuse_inode {
58 /** Inode data */
59 struct inode inode;
60
61 /** Unique ID, which identifies the inode between userspace
62 * and kernel */
63 u64 nodeid;
64
Miklos Szeredi9e6268d2005-09-09 13:10:29 -070065 /** Number of lookups on this inode */
66 u64 nlookup;
67
Miklos Szeredie5e55582005-09-09 13:10:28 -070068 /** The request used for sending the FORGET message */
69 struct fuse_req *forget_req;
70
Miklos Szeredid8a5ba42005-09-09 13:10:26 -070071 /** Time in jiffies until the file attributes are valid */
Miklos Szeredi0a0898c2006-07-30 03:04:10 -070072 u64 i_time;
Miklos Szerediebc14c42007-10-16 23:31:03 -070073
74 /** The sticky bit in inode->i_mode may have been removed, so
75 preserve the original mode */
76 mode_t orig_i_mode;
Miklos Szeredi1fb69e72007-10-18 03:06:58 -070077
78 /** Version of last attribute change */
79 u64 attr_version;
Miklos Szeredi93a8c3c2007-10-18 03:07:03 -070080
81 /** Files usable in writepage. Protected by fc->lock */
82 struct list_head write_files;
Miklos Szeredi3be5a522008-04-30 00:54:41 -070083
84 /** Writepages pending on truncate or fsync */
85 struct list_head queued_writes;
86
87 /** Number of sent writes, a negative bias (FUSE_NOWRITE)
88 * means more writes are blocked */
89 int writectr;
90
91 /** Waitq for writepage completion */
92 wait_queue_head_t page_waitq;
93
94 /** List of writepage requestst (pending or sent) */
95 struct list_head writepages;
Miklos Szeredid8a5ba42005-09-09 13:10:26 -070096};
97
Miklos Szeredib6aeade2005-09-09 13:10:30 -070098/** FUSE specific file data */
99struct fuse_file {
100 /** Request reserved for flush and release */
Miklos Szeredi33649c92006-06-25 05:48:52 -0700101 struct fuse_req *reserved_req;
Miklos Szeredib6aeade2005-09-09 13:10:30 -0700102
103 /** File handle used by userspace */
104 u64 fh;
Miklos Szeredic756e0a2007-10-16 23:31:00 -0700105
106 /** Refcount */
107 atomic_t count;
Miklos Szeredi93a8c3c2007-10-18 03:07:03 -0700108
109 /** Entry on inode's write_files list */
110 struct list_head write_entry;
Miklos Szeredib6aeade2005-09-09 13:10:30 -0700111};
112
Miklos Szeredi334f4852005-09-09 13:10:27 -0700113/** One input argument of a request */
114struct fuse_in_arg {
115 unsigned size;
116 const void *value;
117};
118
119/** The request input */
120struct fuse_in {
121 /** The request header */
122 struct fuse_in_header h;
123
124 /** True if the data for the last argument is in req->pages */
125 unsigned argpages:1;
126
127 /** Number of arguments */
128 unsigned numargs;
129
130 /** Array of arguments */
131 struct fuse_in_arg args[3];
132};
133
134/** One output argument of a request */
135struct fuse_arg {
136 unsigned size;
137 void *value;
138};
139
140/** The request output */
141struct fuse_out {
142 /** Header returned from userspace */
143 struct fuse_out_header h;
144
Miklos Szeredi095da6c2006-01-16 22:14:52 -0800145 /*
146 * The following bitfields are not changed during the request
147 * processing
148 */
149
Miklos Szeredi334f4852005-09-09 13:10:27 -0700150 /** Last argument is variable length (can be shorter than
151 arg->size) */
152 unsigned argvar:1;
153
154 /** Last argument is a list of pages to copy data to */
155 unsigned argpages:1;
156
157 /** Zero partially or not copied pages */
158 unsigned page_zeroing:1;
159
160 /** Number or arguments */
161 unsigned numargs;
162
163 /** Array of arguments */
164 struct fuse_arg args[3];
165};
166
Miklos Szeredi83cfd492006-01-16 22:14:31 -0800167/** The request state */
168enum fuse_req_state {
169 FUSE_REQ_INIT = 0,
170 FUSE_REQ_PENDING,
171 FUSE_REQ_READING,
172 FUSE_REQ_SENT,
Miklos Szeredia4d27e72006-06-25 05:48:54 -0700173 FUSE_REQ_WRITING,
Miklos Szeredi83cfd492006-01-16 22:14:31 -0800174 FUSE_REQ_FINISHED
175};
176
Miklos Szeredi64c6d8e2006-01-16 22:14:42 -0800177struct fuse_conn;
178
Miklos Szeredi334f4852005-09-09 13:10:27 -0700179/**
180 * A request to the client
181 */
182struct fuse_req {
Miklos Szeredice1d5a42006-04-10 22:54:58 -0700183 /** This can be on either pending processing or io lists in
184 fuse_conn */
Miklos Szeredi334f4852005-09-09 13:10:27 -0700185 struct list_head list;
186
Miklos Szeredia4d27e72006-06-25 05:48:54 -0700187 /** Entry on the interrupts list */
188 struct list_head intr_entry;
189
Miklos Szeredi334f4852005-09-09 13:10:27 -0700190 /** refcount */
191 atomic_t count;
192
Miklos Szeredia4d27e72006-06-25 05:48:54 -0700193 /** Unique ID for the interrupt request */
194 u64 intr_unique;
195
Miklos Szeredi095da6c2006-01-16 22:14:52 -0800196 /*
197 * The following bitfields are either set once before the
198 * request is queued or setting/clearing them is protected by
Miklos Szeredid7133112006-04-10 22:54:55 -0700199 * fuse_conn->lock
Miklos Szeredi095da6c2006-01-16 22:14:52 -0800200 */
201
Miklos Szeredi334f4852005-09-09 13:10:27 -0700202 /** True if the request has reply */
203 unsigned isreply:1;
204
Miklos Szeredi51eb01e2006-06-25 05:48:50 -0700205 /** Force sending of the request even if interrupted */
206 unsigned force:1;
207
Miklos Szeredif9a28422006-06-25 05:48:53 -0700208 /** The request was aborted */
209 unsigned aborted:1;
Miklos Szeredi334f4852005-09-09 13:10:27 -0700210
211 /** Request is sent in the background */
212 unsigned background:1;
213
Miklos Szeredia4d27e72006-06-25 05:48:54 -0700214 /** The request has been interrupted */
215 unsigned interrupted:1;
216
Miklos Szeredi334f4852005-09-09 13:10:27 -0700217 /** Data is being copied to/from the request */
218 unsigned locked:1;
219
Miklos Szeredi9bc5ddd2006-04-11 21:16:09 +0200220 /** Request is counted as "waiting" */
221 unsigned waiting:1;
222
Miklos Szeredi83cfd492006-01-16 22:14:31 -0800223 /** State of the request */
224 enum fuse_req_state state;
Miklos Szeredi334f4852005-09-09 13:10:27 -0700225
226 /** The request input */
227 struct fuse_in in;
228
229 /** The request output */
230 struct fuse_out out;
231
232 /** Used to wake up the task waiting for completion of request*/
233 wait_queue_head_t waitq;
234
235 /** Data for asynchronous requests */
236 union {
Miklos Szeredie5e55582005-09-09 13:10:28 -0700237 struct fuse_forget_in forget_in;
Miklos Szeredib57d4262008-02-06 01:38:39 -0800238 struct {
239 struct fuse_release_in in;
240 struct vfsmount *vfsmount;
241 struct dentry *dentry;
242 } release;
Miklos Szeredi3ec870d2006-01-06 00:19:41 -0800243 struct fuse_init_in init_in;
244 struct fuse_init_out init_out;
Miklos Szeredi5c5c5e52008-04-30 00:54:43 -0700245 struct {
246 struct fuse_read_in in;
247 u64 attr_ver;
248 } read;
Miklos Szeredib25e82e2007-10-18 03:07:03 -0700249 struct {
250 struct fuse_write_in in;
251 struct fuse_write_out out;
252 } write;
Miklos Szeredi71421252006-06-25 05:48:52 -0700253 struct fuse_lk_in lk_in;
Miklos Szeredi334f4852005-09-09 13:10:27 -0700254 } misc;
255
256 /** page vector */
257 struct page *pages[FUSE_MAX_PAGES_PER_REQ];
258
259 /** number of pages in vector */
260 unsigned num_pages;
261
262 /** offset of data on first page */
263 unsigned page_offset;
264
Miklos Szeredi334f4852005-09-09 13:10:27 -0700265 /** File used in the request (or NULL) */
Miklos Szeredic756e0a2007-10-16 23:31:00 -0700266 struct fuse_file *ff;
Miklos Szeredi64c6d8e2006-01-16 22:14:42 -0800267
Miklos Szeredi3be5a522008-04-30 00:54:41 -0700268 /** Inode used in the request or NULL */
269 struct inode *inode;
270
271 /** Link on fi->writepages */
272 struct list_head writepages_entry;
273
Miklos Szeredi64c6d8e2006-01-16 22:14:42 -0800274 /** Request completion callback */
275 void (*end)(struct fuse_conn *, struct fuse_req *);
Miklos Szeredi33649c92006-06-25 05:48:52 -0700276
277 /** Request is stolen from fuse_file->reserved_req */
278 struct file *stolen_file;
Miklos Szeredi334f4852005-09-09 13:10:27 -0700279};
280
Miklos Szeredid8a5ba42005-09-09 13:10:26 -0700281/**
282 * A Fuse connection.
283 *
284 * This structure is created, when the filesystem is mounted, and is
285 * destroyed, when the client device is closed and the filesystem is
286 * unmounted.
287 */
288struct fuse_conn {
Miklos Szeredid7133112006-04-10 22:54:55 -0700289 /** Lock protecting accessess to members of this structure */
290 spinlock_t lock;
291
Miklos Szeredid2a85162006-10-17 00:10:11 -0700292 /** Mutex protecting against directory alias creation */
293 struct mutex inst_mutex;
294
Miklos Szeredibafa9652006-06-25 05:48:51 -0700295 /** Refcount */
296 atomic_t count;
297
Miklos Szeredid8a5ba42005-09-09 13:10:26 -0700298 /** The user id for this mount */
299 uid_t user_id;
300
Miklos Szeredi87729a52005-09-09 13:10:34 -0700301 /** The group id for this mount */
302 gid_t group_id;
303
Miklos Szeredi1e9a4ed2005-09-09 13:10:31 -0700304 /** The fuse mount flags for this mount */
305 unsigned flags;
306
Miklos Szeredidb50b962005-09-09 13:10:33 -0700307 /** Maximum read size */
308 unsigned max_read;
309
Miklos Szeredi413ef8c2005-09-09 13:10:35 -0700310 /** Maximum write size */
311 unsigned max_write;
312
Miklos Szeredi334f4852005-09-09 13:10:27 -0700313 /** Readers of the connection are waiting on this */
314 wait_queue_head_t waitq;
315
316 /** The list of pending requests */
317 struct list_head pending;
318
319 /** The list of requests being processed */
320 struct list_head processing;
321
Miklos Szeredid77a1d52006-01-16 22:14:31 -0800322 /** The list of requests under I/O */
323 struct list_head io;
324
Miklos Szeredi08a53cd2006-04-10 22:54:59 -0700325 /** Number of requests currently in the background */
326 unsigned num_background;
327
Miklos Szeredid12def12008-02-06 01:38:39 -0800328 /** Number of background requests currently queued for userspace */
329 unsigned active_background;
330
331 /** The list of background requests set aside for later queuing */
332 struct list_head bg_queue;
333
Miklos Szeredia4d27e72006-06-25 05:48:54 -0700334 /** Pending interrupts */
335 struct list_head interrupts;
336
Miklos Szeredi08a53cd2006-04-10 22:54:59 -0700337 /** Flag indicating if connection is blocked. This will be
338 the case before the INIT reply is received, and if there
339 are too many outstading backgrounds requests */
340 int blocked;
341
342 /** waitq for blocked connection */
343 wait_queue_head_t blocked_waitq;
344
Miklos Szeredide5e3de2007-10-16 23:31:00 -0700345 /** waitq for reserved requests */
346 wait_queue_head_t reserved_req_waitq;
347
Miklos Szeredi334f4852005-09-09 13:10:27 -0700348 /** The next unique request id */
349 u64 reqctr;
350
Miklos Szeredi69a53bf2006-01-16 22:14:41 -0800351 /** Connection established, cleared on umount, connection
352 abort and device release */
Miklos Szeredi095da6c2006-01-16 22:14:52 -0800353 unsigned connected;
Miklos Szeredi1e9a4ed2005-09-09 13:10:31 -0700354
Miklos Szeredi095da6c2006-01-16 22:14:52 -0800355 /** Connection failed (version mismatch). Cannot race with
356 setting other bitfields since it is only set once in INIT
357 reply, before any other request, and never cleared */
Miklos Szeredi334f4852005-09-09 13:10:27 -0700358 unsigned conn_error : 1;
359
Miklos Szeredi0ec7ca42006-12-06 20:35:52 -0800360 /** Connection successful. Only set in INIT */
361 unsigned conn_init : 1;
362
Miklos Szeredi9cd68452006-02-01 03:04:40 -0800363 /** Do readpages asynchronously? Only set in INIT */
364 unsigned async_read : 1;
365
Miklos Szeredi6ff958e2007-10-18 03:07:02 -0700366 /** Do not send separate SETATTR request before open(O_TRUNC) */
367 unsigned atomic_o_trunc : 1;
368
Miklos Szeredi33670fa2008-07-25 01:49:02 -0700369 /** Filesystem supports NFS exporting. Only set in INIT */
370 unsigned export_support : 1;
371
Miklos Szeredi095da6c2006-01-16 22:14:52 -0800372 /*
373 * The following bitfields are only for optimization purposes
374 * and hence races in setting them will not cause malfunction
375 */
376
Miklos Szeredib6aeade2005-09-09 13:10:30 -0700377 /** Is fsync not implemented by fs? */
378 unsigned no_fsync : 1;
379
Miklos Szeredi82547982005-09-09 13:10:38 -0700380 /** Is fsyncdir not implemented by fs? */
381 unsigned no_fsyncdir : 1;
382
Miklos Szeredib6aeade2005-09-09 13:10:30 -0700383 /** Is flush not implemented by fs? */
384 unsigned no_flush : 1;
385
Miklos Szeredi92a87802005-09-09 13:10:31 -0700386 /** Is setxattr not implemented by fs? */
387 unsigned no_setxattr : 1;
388
389 /** Is getxattr not implemented by fs? */
390 unsigned no_getxattr : 1;
391
392 /** Is listxattr not implemented by fs? */
393 unsigned no_listxattr : 1;
394
395 /** Is removexattr not implemented by fs? */
396 unsigned no_removexattr : 1;
397
Miklos Szeredi71421252006-06-25 05:48:52 -0700398 /** Are file locking primitives not implemented by fs? */
399 unsigned no_lock : 1;
400
Miklos Szeredi31d40d72005-11-07 00:59:50 -0800401 /** Is access not implemented by fs? */
402 unsigned no_access : 1;
403
Miklos Szeredifd72faa2005-11-07 00:59:51 -0800404 /** Is create not implemented by fs? */
405 unsigned no_create : 1;
406
Miklos Szeredia4d27e72006-06-25 05:48:54 -0700407 /** Is interrupt not implemented by fs? */
408 unsigned no_interrupt : 1;
409
Miklos Szeredib2d22722006-12-06 20:35:51 -0800410 /** Is bmap not implemented by fs? */
411 unsigned no_bmap : 1;
412
Miklos Szeredi78bb6cb2008-05-12 14:02:32 -0700413 /** Do multi-page cached writes */
414 unsigned big_writes : 1;
415
Miklos Szeredi0cd5b882006-01-16 22:14:38 -0800416 /** The number of requests waiting for completion */
417 atomic_t num_waiting;
418
Miklos Szeredi45714d62006-01-06 00:19:36 -0800419 /** Negotiated minor version */
420 unsigned minor;
421
Miklos Szeredid8a5ba42005-09-09 13:10:26 -0700422 /** Backing dev info */
423 struct backing_dev_info bdi;
Miklos Szeredif543f252006-01-16 22:14:35 -0800424
Miklos Szeredibafa9652006-06-25 05:48:51 -0700425 /** Entry on the fuse_conn_list */
426 struct list_head entry;
427
Miklos Szeredib6f2fcb2008-04-30 00:54:34 -0700428 /** Device ID from super block */
429 dev_t dev;
Miklos Szeredibafa9652006-06-25 05:48:51 -0700430
431 /** Dentries in the control filesystem */
432 struct dentry *ctl_dentry[FUSE_CTL_NUM_DENTRIES];
433
434 /** number of dentries used in the above array */
435 int ctl_ndents;
Jeff Dike385a17b2006-04-10 22:54:52 -0700436
437 /** O_ASYNC requests */
438 struct fasync_struct *fasync;
Miklos Szeredi9c8ef562006-06-25 05:48:55 -0700439
440 /** Key for lock owner ID scrambling */
441 u32 scramble_key[4];
Miklos Szeredi0ec7ca42006-12-06 20:35:52 -0800442
443 /** Reserved request for the DESTROY message */
444 struct fuse_req *destroy_req;
Miklos Szeredi1fb69e72007-10-18 03:06:58 -0700445
446 /** Version counter for attribute changes */
447 u64 attr_version;
Miklos Szeredid8a5ba42005-09-09 13:10:26 -0700448};
449
Miklos Szeredid8a5ba42005-09-09 13:10:26 -0700450static inline struct fuse_conn *get_fuse_conn_super(struct super_block *sb)
451{
Miklos Szeredi6383bda2006-01-16 22:14:29 -0800452 return sb->s_fs_info;
Miklos Szeredid8a5ba42005-09-09 13:10:26 -0700453}
454
455static inline struct fuse_conn *get_fuse_conn(struct inode *inode)
456{
457 return get_fuse_conn_super(inode->i_sb);
458}
459
460static inline struct fuse_inode *get_fuse_inode(struct inode *inode)
461{
462 return container_of(inode, struct fuse_inode, inode);
463}
464
465static inline u64 get_node_id(struct inode *inode)
466{
467 return get_fuse_inode(inode)->nodeid;
468}
469
Miklos Szeredi334f4852005-09-09 13:10:27 -0700470/** Device operations */
Arjan van de Ven4b6f5d22006-03-28 01:56:42 -0800471extern const struct file_operations fuse_dev_operations;
Miklos Szeredi334f4852005-09-09 13:10:27 -0700472
Miklos Szeredidbd561d2008-07-25 01:49:00 -0700473extern struct dentry_operations fuse_dentry_operations;
474
Miklos Szeredid8a5ba42005-09-09 13:10:26 -0700475/**
Miklos Szeredie5e55582005-09-09 13:10:28 -0700476 * Get a filled in inode
477 */
Miklos Szeredib48badf2008-04-30 00:54:44 -0700478struct inode *fuse_iget(struct super_block *sb, u64 nodeid,
Miklos Szeredi1fb69e72007-10-18 03:06:58 -0700479 int generation, struct fuse_attr *attr,
480 u64 attr_valid, u64 attr_version);
Miklos Szeredie5e55582005-09-09 13:10:28 -0700481
Miklos Szeredi33670fa2008-07-25 01:49:02 -0700482int fuse_lookup_name(struct super_block *sb, u64 nodeid, struct qstr *name,
483 struct fuse_entry_out *outarg, struct inode **inode);
484
Miklos Szeredie5e55582005-09-09 13:10:28 -0700485/**
486 * Send FORGET command
487 */
488void fuse_send_forget(struct fuse_conn *fc, struct fuse_req *req,
Miklos Szeredib48badf2008-04-30 00:54:44 -0700489 u64 nodeid, u64 nlookup);
Miklos Szeredie5e55582005-09-09 13:10:28 -0700490
491/**
Miklos Szeredi361b1eb52006-01-16 22:14:45 -0800492 * Initialize READ or READDIR request
Miklos Szeredi04730fe2005-09-09 13:10:36 -0700493 */
Miklos Szeredia6643092007-11-28 16:22:00 -0800494void fuse_read_fill(struct fuse_req *req, struct file *file,
Miklos Szeredi361b1eb52006-01-16 22:14:45 -0800495 struct inode *inode, loff_t pos, size_t count, int opcode);
Miklos Szeredi04730fe2005-09-09 13:10:36 -0700496
497/**
498 * Send OPEN or OPENDIR request
499 */
500int fuse_open_common(struct inode *inode, struct file *file, int isdir);
501
Miklos Szeredifd72faa2005-11-07 00:59:51 -0800502struct fuse_file *fuse_file_alloc(void);
503void fuse_file_free(struct fuse_file *ff);
504void fuse_finish_open(struct inode *inode, struct file *file,
505 struct fuse_file *ff, struct fuse_open_out *outarg);
506
Miklos Szeredic756e0a2007-10-16 23:31:00 -0700507/** Fill in ff->reserved_req with a RELEASE request */
508void fuse_release_fill(struct fuse_file *ff, u64 nodeid, int flags, int opcode);
509
Miklos Szeredi04730fe2005-09-09 13:10:36 -0700510/**
511 * Send RELEASE or RELEASEDIR request
512 */
513int fuse_release_common(struct inode *inode, struct file *file, int isdir);
514
515/**
Miklos Szeredi82547982005-09-09 13:10:38 -0700516 * Send FSYNC or FSYNCDIR request
517 */
518int fuse_fsync_common(struct file *file, struct dentry *de, int datasync,
519 int isdir);
520
521/**
Miklos Szeredi17793812005-10-30 15:02:51 -0800522 * Initialize file operations on a regular file
Miklos Szeredib6aeade2005-09-09 13:10:30 -0700523 */
524void fuse_init_file_inode(struct inode *inode);
525
526/**
Miklos Szeredi17793812005-10-30 15:02:51 -0800527 * Initialize inode operations on regular files and special files
Miklos Szeredie5e55582005-09-09 13:10:28 -0700528 */
529void fuse_init_common(struct inode *inode);
530
531/**
Miklos Szeredi17793812005-10-30 15:02:51 -0800532 * Initialize inode and file operations on a directory
Miklos Szeredie5e55582005-09-09 13:10:28 -0700533 */
534void fuse_init_dir(struct inode *inode);
535
536/**
Miklos Szeredi17793812005-10-30 15:02:51 -0800537 * Initialize inode operations on a symlink
Miklos Szeredie5e55582005-09-09 13:10:28 -0700538 */
539void fuse_init_symlink(struct inode *inode);
540
541/**
542 * Change attributes of an inode
543 */
Miklos Szeredi1fb69e72007-10-18 03:06:58 -0700544void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr,
545 u64 attr_valid, u64 attr_version);
Miklos Szeredie5e55582005-09-09 13:10:28 -0700546
Miklos Szeredi3be5a522008-04-30 00:54:41 -0700547void fuse_change_attributes_common(struct inode *inode, struct fuse_attr *attr,
548 u64 attr_valid);
549
550void fuse_truncate(struct address_space *mapping, loff_t offset);
551
Miklos Szeredie5e55582005-09-09 13:10:28 -0700552/**
Miklos Szeredi334f4852005-09-09 13:10:27 -0700553 * Initialize the client device
554 */
555int fuse_dev_init(void);
556
557/**
558 * Cleanup the client device
559 */
560void fuse_dev_cleanup(void);
561
Miklos Szeredibafa9652006-06-25 05:48:51 -0700562int fuse_ctl_init(void);
563void fuse_ctl_cleanup(void);
564
Miklos Szeredi334f4852005-09-09 13:10:27 -0700565/**
566 * Allocate a request
567 */
568struct fuse_req *fuse_request_alloc(void);
569
Miklos Szeredi3be5a522008-04-30 00:54:41 -0700570struct fuse_req *fuse_request_alloc_nofs(void);
571
Miklos Szeredi334f4852005-09-09 13:10:27 -0700572/**
573 * Free a request
574 */
575void fuse_request_free(struct fuse_req *req);
576
577/**
Miklos Szeredi33649c92006-06-25 05:48:52 -0700578 * Get a request, may fail with -ENOMEM
Miklos Szeredi334f4852005-09-09 13:10:27 -0700579 */
Miklos Szeredice1d5a42006-04-10 22:54:58 -0700580struct fuse_req *fuse_get_req(struct fuse_conn *fc);
Miklos Szeredi334f4852005-09-09 13:10:27 -0700581
582/**
Miklos Szeredi33649c92006-06-25 05:48:52 -0700583 * Gets a requests for a file operation, always succeeds
584 */
585struct fuse_req *fuse_get_req_nofail(struct fuse_conn *fc, struct file *file);
586
587/**
Miklos Szeredice1d5a42006-04-10 22:54:58 -0700588 * Decrement reference count of a request. If count goes to zero free
589 * the request.
Miklos Szeredi334f4852005-09-09 13:10:27 -0700590 */
591void fuse_put_request(struct fuse_conn *fc, struct fuse_req *req);
592
593/**
Miklos Szeredi7c352bd2005-09-09 13:10:39 -0700594 * Send a request (synchronous)
Miklos Szeredi334f4852005-09-09 13:10:27 -0700595 */
596void request_send(struct fuse_conn *fc, struct fuse_req *req);
597
598/**
Miklos Szeredi334f4852005-09-09 13:10:27 -0700599 * Send a request with no reply
600 */
601void request_send_noreply(struct fuse_conn *fc, struct fuse_req *req);
602
603/**
604 * Send a request in the background
605 */
606void request_send_background(struct fuse_conn *fc, struct fuse_req *req);
607
Miklos Szeredi3be5a522008-04-30 00:54:41 -0700608void request_send_background_locked(struct fuse_conn *fc, struct fuse_req *req);
609
Miklos Szeredi5a5fb1e2006-04-26 10:48:55 +0200610/* Abort all requests */
Miklos Szeredi69a53bf2006-01-16 22:14:41 -0800611void fuse_abort_conn(struct fuse_conn *fc);
612
Miklos Szeredi1e9a4ed2005-09-09 13:10:31 -0700613/**
Miklos Szeredie5e55582005-09-09 13:10:28 -0700614 * Invalidate inode attributes
615 */
616void fuse_invalidate_attr(struct inode *inode);
Miklos Szeredibafa9652006-06-25 05:48:51 -0700617
Miklos Szeredidbd561d2008-07-25 01:49:00 -0700618void fuse_invalidate_entry_cache(struct dentry *entry);
619
Miklos Szeredibafa9652006-06-25 05:48:51 -0700620/**
621 * Acquire reference to fuse_conn
622 */
623struct fuse_conn *fuse_conn_get(struct fuse_conn *fc);
624
625/**
626 * Release reference to fuse_conn
627 */
628void fuse_conn_put(struct fuse_conn *fc);
629
630/**
631 * Add connection to control filesystem
632 */
633int fuse_ctl_add_conn(struct fuse_conn *fc);
634
635/**
636 * Remove connection from control filesystem
637 */
638void fuse_ctl_remove_conn(struct fuse_conn *fc);
Timo Savolaa5bfffac2007-04-08 16:04:00 -0700639
640/**
641 * Is file type valid?
642 */
643int fuse_valid_type(int m);
Miklos Szeredie57ac682007-10-18 03:06:58 -0700644
645/**
646 * Is task allowed to perform filesystem operation?
647 */
648int fuse_allow_task(struct fuse_conn *fc, struct task_struct *task);
Miklos Szeredif3332112007-10-18 03:07:04 -0700649
650u64 fuse_lock_owner_id(struct fuse_conn *fc, fl_owner_t id);
Miklos Szeredibcb4be82007-11-28 16:21:59 -0800651
652int fuse_update_attributes(struct inode *inode, struct kstat *stat,
653 struct file *file, bool *refreshed);
Miklos Szeredi3be5a522008-04-30 00:54:41 -0700654
655void fuse_flush_writepages(struct inode *inode);
656
657void fuse_set_nowrite(struct inode *inode);
658void fuse_release_nowrite(struct inode *inode);
Miklos Szeredi5c5c5e52008-04-30 00:54:43 -0700659
660u64 fuse_get_attr_version(struct fuse_conn *fc);
Tejun Heo29d434b2008-10-16 16:08:57 +0200661
662#endif /* _FS_FUSE_I_H */