Blame view
fs/fuse/fuse_i.h
22.3 KB
d8a5ba454
|
1 2 |
/* FUSE: Filesystem in Userspace |
1729a16c2
|
3 |
Copyright (C) 2001-2008 Miklos Szeredi <miklos@szeredi.hu> |
d8a5ba454
|
4 5 6 7 |
This program can be distributed under the terms of the GNU GPL. See the file COPYING. */ |
29d434b39
|
8 9 |
#ifndef _FS_FUSE_I_H #define _FS_FUSE_I_H |
d8a5ba454
|
10 11 |
#include <linux/fuse.h> #include <linux/fs.h> |
51eb01e73
|
12 |
#include <linux/mount.h> |
d8a5ba454
|
13 14 15 16 17 |
#include <linux/wait.h> #include <linux/list.h> #include <linux/spinlock.h> #include <linux/mm.h> #include <linux/backing-dev.h> |
bafa96541
|
18 |
#include <linux/mutex.h> |
3be5a52b3
|
19 |
#include <linux/rwsem.h> |
95668a69a
|
20 21 |
#include <linux/rbtree.h> #include <linux/poll.h> |
5a18ec176
|
22 |
#include <linux/workqueue.h> |
744742d69
|
23 |
#include <linux/kref.h> |
d8a5ba454
|
24 |
|
334f485df
|
25 26 |
/** Max number of pages that can be used in a single read request */ #define FUSE_MAX_PAGES_PER_REQ 32 |
3be5a52b3
|
27 28 |
/** Bias for fi->writectr, meaning new writepages must not be sent */ #define FUSE_NOWRITE INT_MIN |
1d3d752b4
|
29 30 |
/** It could be as large as PATH_MAX, but would that have any uses? */ #define FUSE_NAME_MAX 1024 |
bafa96541
|
31 |
/** Number of dentries for each connection in the control filesystem */ |
79a9d9943
|
32 |
#define FUSE_CTL_NUM_DENTRIES 5 |
bafa96541
|
33 |
|
1e9a4ed93
|
34 35 36 37 38 39 40 41 |
/** If the FUSE_DEFAULT_PERMISSIONS flag is given, the filesystem module will check permissions based on the file mode. Otherwise no permission checking is done in the kernel */ #define FUSE_DEFAULT_PERMISSIONS (1 << 0) /** If the FUSE_ALLOW_OTHER flag is given, then not only the user doing the mount will be allowed to access the filesystem */ #define FUSE_ALLOW_OTHER (1 << 1) |
4250c0668
|
42 43 |
/** Number of page pointers embedded in fuse_req */ #define FUSE_REQ_INLINE_PAGES 1 |
bafa96541
|
44 45 46 47 48 |
/** List of active connections */ extern struct list_head fuse_conn_list; /** Global mutex protecting fuse_conn_list and the control filesystem */ extern struct mutex fuse_mutex; |
413ef8cb3
|
49 |
|
79a9d9943
|
50 51 52 |
/** Module parameters */ extern unsigned max_user_bgreq; extern unsigned max_user_congthresh; |
07e77dca8
|
53 54 |
/* One forget request */ struct fuse_forget_link { |
02c048b91
|
55 |
struct fuse_forget_one forget_one; |
07e77dca8
|
56 57 |
struct fuse_forget_link *next; }; |
d8a5ba454
|
58 59 60 61 62 63 64 65 |
/** FUSE inode */ struct fuse_inode { /** Inode data */ struct inode inode; /** Unique ID, which identifies the inode between userspace * and kernel */ u64 nodeid; |
9e6268db4
|
66 67 |
/** Number of lookups on this inode */ u64 nlookup; |
e5e5558e9
|
68 |
/** The request used for sending the FORGET message */ |
07e77dca8
|
69 |
struct fuse_forget_link *forget; |
e5e5558e9
|
70 |
|
d8a5ba454
|
71 |
/** Time in jiffies until the file attributes are valid */ |
0a0898cf4
|
72 |
u64 i_time; |
ebc14c4db
|
73 74 75 |
/** The sticky bit in inode->i_mode may have been removed, so preserve the original mode */ |
541af6a07
|
76 |
umode_t orig_i_mode; |
1fb69e781
|
77 |
|
45c72cd73
|
78 79 |
/** 64 bit inode number */ u64 orig_ino; |
1fb69e781
|
80 81 |
/** Version of last attribute change */ u64 attr_version; |
93a8c3cd9
|
82 83 84 |
/** Files usable in writepage. Protected by fc->lock */ struct list_head write_files; |
3be5a52b3
|
85 86 87 88 89 90 91 92 93 94 95 96 97 |
/** Writepages pending on truncate or fsync */ struct list_head queued_writes; /** Number of sent writes, a negative bias (FUSE_NOWRITE) * means more writes are blocked */ int writectr; /** Waitq for writepage completion */ wait_queue_head_t page_waitq; /** List of writepage requestst (pending or sent) */ struct list_head writepages; |
4582a4ab2
|
98 99 100 101 102 103 104 105 106 |
/** Miscellaneous bits describing inode state */ unsigned long state; }; /** FUSE inode state bits */ enum { /** Advise readdirplus */ FUSE_I_ADVISE_RDPLUS, |
6314efee3
|
107 108 |
/** Initialized with readdirplus */ FUSE_I_INIT_RDPLUS, |
06a7c3c27
|
109 110 |
/** An operation changing file size is in progress */ FUSE_I_SIZE_UNSTABLE, |
d8a5ba454
|
111 |
}; |
da5e47145
|
112 |
struct fuse_conn; |
b6aeadeda
|
113 114 |
/** FUSE specific file data */ struct fuse_file { |
da5e47145
|
115 116 |
/** Fuse connection for this file */ struct fuse_conn *fc; |
b6aeadeda
|
117 |
/** Request reserved for flush and release */ |
33649c91a
|
118 |
struct fuse_req *reserved_req; |
b6aeadeda
|
119 |
|
acf99433d
|
120 121 |
/** Kernel file handle guaranteed to be unique */ u64 kh; |
b6aeadeda
|
122 123 |
/** File handle used by userspace */ u64 fh; |
c756e0a4d
|
124 |
|
da5e47145
|
125 126 |
/** Node id of this file */ u64 nodeid; |
c756e0a4d
|
127 128 |
/** Refcount */ atomic_t count; |
93a8c3cd9
|
129 |
|
c7b7143c6
|
130 131 |
/** FOPEN_* flags returned by open */ u32 open_flags; |
93a8c3cd9
|
132 133 |
/** Entry on inode's write_files list */ struct list_head write_entry; |
95668a69a
|
134 135 136 137 138 139 |
/** RB node to be linked on fuse_conn->polled_files */ struct rb_node polled_node; /** Wait queue head for poll */ wait_queue_head_t poll_wait; |
37fb3a30b
|
140 141 142 |
/** Has flock been performed on this file? */ bool flock:1; |
b6aeadeda
|
143 |
}; |
334f485df
|
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
/** One input argument of a request */ struct fuse_in_arg { unsigned size; const void *value; }; /** The request input */ struct fuse_in { /** The request header */ struct fuse_in_header h; /** True if the data for the last argument is in req->pages */ unsigned argpages:1; /** Number of arguments */ unsigned numargs; /** Array of arguments */ struct fuse_in_arg args[3]; }; /** One output argument of a request */ struct fuse_arg { unsigned size; void *value; }; /** The request output */ struct fuse_out { /** Header returned from userspace */ struct fuse_out_header h; |
095da6cbb
|
175 176 177 178 |
/* * The following bitfields are not changed during the request * processing */ |
334f485df
|
179 180 181 182 183 184 185 186 187 |
/** Last argument is variable length (can be shorter than arg->size) */ unsigned argvar:1; /** Last argument is a list of pages to copy data to */ unsigned argpages:1; /** Zero partially or not copied pages */ unsigned page_zeroing:1; |
ce534fb05
|
188 189 |
/** Pages may be replaced with new ones */ unsigned page_replace:1; |
334f485df
|
190 191 192 193 |
/** Number or arguments */ unsigned numargs; /** Array of arguments */ |
f704dcb53
|
194 |
struct fuse_arg args[2]; |
334f485df
|
195 |
}; |
b2430d756
|
196 197 198 199 200 |
/** FUSE page descriptor */ struct fuse_page_desc { unsigned int length; unsigned int offset; }; |
7078187a7
|
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
struct fuse_args { struct { struct { uint32_t opcode; uint64_t nodeid; } h; unsigned numargs; struct fuse_in_arg args[3]; } in; struct { unsigned argvar:1; unsigned numargs; struct fuse_arg args[2]; } out; }; #define FUSE_ARGS(args) struct fuse_args args = {} |
01e9d11a3
|
219 220 |
/** The request IO state (for asynchronous processing) */ struct fuse_io_priv { |
744742d69
|
221 |
struct kref refcnt; |
01e9d11a3
|
222 223 224 225 226 227 228 229 230 231 |
int async; spinlock_t lock; unsigned reqs; ssize_t bytes; size_t size; __u64 offset; bool write; int err; struct kiocb *iocb; struct file *file; |
9d5722b77
|
232 |
struct completion *done; |
01e9d11a3
|
233 |
}; |
744742d69
|
234 235 236 237 238 239 |
#define FUSE_IO_PRIV_SYNC(f) \ { \ .refcnt = { ATOMIC_INIT(1) }, \ .async = 0, \ .file = f, \ } |
334f485df
|
240 |
/** |
825d6d339
|
241 242 243 244 245 246 247 248 249 |
* Request flags * * FR_ISREPLY: set if the request has reply * FR_FORCE: force sending of the request even if interrupted * FR_BACKGROUND: request is sent in the background * FR_WAITING: request is counted as "waiting" * FR_ABORTED: the request was aborted * FR_INTERRUPTED: the request has been interrupted * FR_LOCKED: data is being copied to/from the request |
33e14b4df
|
250 251 252 |
* FR_PENDING: request is not yet in userspace * FR_SENT: request is in userspace, waiting for an answer * FR_FINISHED: request is finished |
77cd9d488
|
253 |
* FR_PRIVATE: request is on private list |
825d6d339
|
254 255 256 257 258 259 260 261 262 |
*/ enum fuse_req_flag { FR_ISREPLY, FR_FORCE, FR_BACKGROUND, FR_WAITING, FR_ABORTED, FR_INTERRUPTED, FR_LOCKED, |
33e14b4df
|
263 264 265 |
FR_PENDING, FR_SENT, FR_FINISHED, |
77cd9d488
|
266 |
FR_PRIVATE, |
825d6d339
|
267 268 269 |
}; /** |
334f485df
|
270 |
* A request to the client |
dc00809a5
|
271 272 273 274 |
* * .waitq.lock protects the following fields: * - FR_ABORTED * - FR_LOCKED (may also be modified under fc->lock, tested under both) |
334f485df
|
275 276 |
*/ struct fuse_req { |
ce1d5a491
|
277 278 |
/** This can be on either pending processing or io lists in fuse_conn */ |
334f485df
|
279 |
struct list_head list; |
a4d27e75f
|
280 281 |
/** Entry on the interrupts list */ struct list_head intr_entry; |
334f485df
|
282 283 |
/** refcount */ atomic_t count; |
a4d27e75f
|
284 285 |
/** Unique ID for the interrupt request */ u64 intr_unique; |
825d6d339
|
286 287 |
/* Request flags, updated with test/set/clear_bit() */ unsigned long flags; |
9bc5dddad
|
288 |
|
334f485df
|
289 290 291 292 293 294 295 296 297 298 299 |
/** The request input */ struct fuse_in in; /** The request output */ struct fuse_out out; /** Used to wake up the task waiting for completion of request*/ wait_queue_head_t waitq; /** Data for asynchronous requests */ union { |
b57d42644
|
300 |
struct { |
baebccbe9
|
301 302 |
struct fuse_release_in in; struct inode *inode; |
b57d42644
|
303 |
} release; |
3ec870d52
|
304 305 |
struct fuse_init_in init_in; struct fuse_init_out init_out; |
08cbf542b
|
306 |
struct cuse_init_in cuse_init_in; |
5c5c5e51b
|
307 308 309 310 |
struct { struct fuse_read_in in; u64 attr_ver; } read; |
b25e82e56
|
311 312 313 |
struct { struct fuse_write_in in; struct fuse_write_out out; |
8b284dc47
|
314 |
struct fuse_req *next; |
b25e82e56
|
315 |
} write; |
2d45ba381
|
316 |
struct fuse_notify_retrieve_in retrieve_in; |
334f485df
|
317 318 319 |
} misc; /** page vector */ |
4250c0668
|
320 |
struct page **pages; |
b2430d756
|
321 322 |
/** page-descriptor vector */ struct fuse_page_desc *page_descs; |
4250c0668
|
323 324 325 326 327 |
/** size of the 'pages' array */ unsigned max_pages; /** inline page vector */ struct page *inline_pages[FUSE_REQ_INLINE_PAGES]; |
334f485df
|
328 |
|
b2430d756
|
329 330 |
/** inline page-descriptor vector */ struct fuse_page_desc inline_page_descs[FUSE_REQ_INLINE_PAGES]; |
334f485df
|
331 332 |
/** number of pages in vector */ unsigned num_pages; |
334f485df
|
333 |
/** File used in the request (or NULL) */ |
c756e0a4d
|
334 |
struct fuse_file *ff; |
64c6d8ed4
|
335 |
|
3be5a52b3
|
336 337 |
/** Inode used in the request or NULL */ struct inode *inode; |
01e9d11a3
|
338 339 |
/** AIO control block */ struct fuse_io_priv *io; |
3be5a52b3
|
340 341 |
/** Link on fi->writepages */ struct list_head writepages_entry; |
64c6d8ed4
|
342 343 |
/** Request completion callback */ void (*end)(struct fuse_conn *, struct fuse_req *); |
33649c91a
|
344 345 346 |
/** Request is stolen from fuse_file->reserved_req */ struct file *stolen_file; |
334f485df
|
347 |
}; |
f88996a93
|
348 |
struct fuse_iqueue { |
e16714d87
|
349 350 |
/** Connection established */ unsigned connected; |
f88996a93
|
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 |
/** Readers of the connection are waiting on this */ wait_queue_head_t waitq; /** The next unique request id */ u64 reqctr; /** The list of pending requests */ struct list_head pending; /** Pending interrupts */ struct list_head interrupts; /** Queue of pending forgets */ struct fuse_forget_link forget_list_head; struct fuse_forget_link *forget_list_tail; /** Batching of FORGET requests (positive indicates FORGET batch) */ int forget_batch; /** O_ASYNC requests */ struct fasync_struct *fasync; }; |
3a2b5b9cd
|
373 |
struct fuse_pqueue { |
e96edd94d
|
374 375 |
/** Connection established */ unsigned connected; |
45a91cb1a
|
376 377 |
/** Lock protecting accessess to members of this structure */ spinlock_t lock; |
3a2b5b9cd
|
378 379 380 381 382 383 |
/** The list of requests being processed */ struct list_head processing; /** The list of requests under I/O */ struct list_head io; }; |
d8a5ba454
|
384 |
/** |
cc080e9e9
|
385 386 387 388 389 |
* Fuse device instance */ struct fuse_dev { /** Fuse connection for this device */ struct fuse_conn *fc; |
c3696046b
|
390 391 |
/** Processing queue */ struct fuse_pqueue pq; |
cc080e9e9
|
392 393 394 395 396 |
/** list entry on fc->devices */ struct list_head entry; }; /** |
d8a5ba454
|
397 398 399 400 401 402 403 |
* A Fuse connection. * * This structure is created, when the filesystem is mounted, and is * destroyed, when the client device is closed and the filesystem is * unmounted. */ struct fuse_conn { |
d71331146
|
404 405 |
/** Lock protecting accessess to members of this structure */ spinlock_t lock; |
bafa96541
|
406 407 |
/** Refcount */ atomic_t count; |
c3696046b
|
408 409 |
/** Number of fuse_dev's */ atomic_t dev_count; |
dd3e2c55a
|
410 |
struct rcu_head rcu; |
d8a5ba454
|
411 |
/** The user id for this mount */ |
499dcf202
|
412 |
kuid_t user_id; |
d8a5ba454
|
413 |
|
87729a551
|
414 |
/** The group id for this mount */ |
499dcf202
|
415 |
kgid_t group_id; |
87729a551
|
416 |
|
1e9a4ed93
|
417 418 |
/** The fuse mount flags for this mount */ unsigned flags; |
db50b96c0
|
419 420 |
/** Maximum read size */ unsigned max_read; |
413ef8cb3
|
421 422 |
/** Maximum write size */ unsigned max_write; |
f88996a93
|
423 424 |
/** Input queue */ struct fuse_iqueue iq; |
334f485df
|
425 |
|
acf99433d
|
426 427 |
/** The next unique kernel file handle */ u64 khctr; |
95668a69a
|
428 429 |
/** rbtree of fuse_files waiting for poll events indexed by ph */ struct rb_root polled_files; |
7a6d3c8b3
|
430 431 432 433 434 |
/** Maximum number of outstanding background requests */ unsigned max_background; /** Number of background requests at which congestion starts */ unsigned congestion_threshold; |
08a53cdce
|
435 436 |
/** Number of requests currently in the background */ unsigned num_background; |
d12def1bc
|
437 438 439 440 441 |
/** Number of background requests currently queued for userspace */ unsigned active_background; /** The list of background requests set aside for later queuing */ struct list_head bg_queue; |
796523fb2
|
442 443 444 |
/** Flag indicating that INIT reply has been received. Allocating * any fuse request will be suspended until the flag is set */ int initialized; |
08a53cdce
|
445 446 447 448 449 450 451 |
/** Flag indicating if connection is blocked. This will be the case before the INIT reply is received, and if there are too many outstading backgrounds requests */ int blocked; /** waitq for blocked connection */ wait_queue_head_t blocked_waitq; |
de5e3dec4
|
452 453 454 |
/** waitq for reserved requests */ wait_queue_head_t reserved_req_waitq; |
08a53cdce
|
455 |
|
69a53bf26
|
456 457 |
/** Connection established, cleared on umount, connection abort and device release */ |
095da6cbb
|
458 |
unsigned connected; |
1e9a4ed93
|
459 |
|
095da6cbb
|
460 461 462 |
/** Connection failed (version mismatch). Cannot race with setting other bitfields since it is only set once in INIT reply, before any other request, and never cleared */ |
1729a16c2
|
463 |
unsigned conn_error:1; |
334f485df
|
464 |
|
0ec7ca41f
|
465 |
/** Connection successful. Only set in INIT */ |
1729a16c2
|
466 |
unsigned conn_init:1; |
0ec7ca41f
|
467 |
|
9cd684551
|
468 |
/** Do readpages asynchronously? Only set in INIT */ |
1729a16c2
|
469 |
unsigned async_read:1; |
9cd684551
|
470 |
|
6ff958edb
|
471 |
/** Do not send separate SETATTR request before open(O_TRUNC) */ |
1729a16c2
|
472 |
unsigned atomic_o_trunc:1; |
6ff958edb
|
473 |
|
33670fa29
|
474 |
/** Filesystem supports NFS exporting. Only set in INIT */ |
1729a16c2
|
475 |
unsigned export_support:1; |
33670fa29
|
476 |
|
a325f9b92
|
477 478 |
/** Set if bdi is valid */ unsigned bdi_initialized:1; |
d5cd66c58
|
479 480 |
/** write-back cache policy (default is write-through) */ unsigned writeback_cache:1; |
095da6cbb
|
481 482 483 484 |
/* * The following bitfields are only for optimization purposes * and hence races in setting them will not cause malfunction */ |
7678ac506
|
485 486 |
/** Is open/release not implemented by fs? */ unsigned no_open:1; |
b6aeadeda
|
487 |
/** Is fsync not implemented by fs? */ |
1729a16c2
|
488 |
unsigned no_fsync:1; |
b6aeadeda
|
489 |
|
825479819
|
490 |
/** Is fsyncdir not implemented by fs? */ |
1729a16c2
|
491 |
unsigned no_fsyncdir:1; |
825479819
|
492 |
|
b6aeadeda
|
493 |
/** Is flush not implemented by fs? */ |
1729a16c2
|
494 |
unsigned no_flush:1; |
b6aeadeda
|
495 |
|
92a8780e1
|
496 |
/** Is setxattr not implemented by fs? */ |
1729a16c2
|
497 |
unsigned no_setxattr:1; |
92a8780e1
|
498 499 |
/** Is getxattr not implemented by fs? */ |
1729a16c2
|
500 |
unsigned no_getxattr:1; |
92a8780e1
|
501 502 |
/** Is listxattr not implemented by fs? */ |
1729a16c2
|
503 |
unsigned no_listxattr:1; |
92a8780e1
|
504 505 |
/** Is removexattr not implemented by fs? */ |
1729a16c2
|
506 |
unsigned no_removexattr:1; |
92a8780e1
|
507 |
|
37fb3a30b
|
508 |
/** Are posix file locking primitives not implemented by fs? */ |
1729a16c2
|
509 |
unsigned no_lock:1; |
714212593
|
510 |
|
31d40d74b
|
511 |
/** Is access not implemented by fs? */ |
1729a16c2
|
512 |
unsigned no_access:1; |
31d40d74b
|
513 |
|
fd72faac9
|
514 |
/** Is create not implemented by fs? */ |
1729a16c2
|
515 |
unsigned no_create:1; |
fd72faac9
|
516 |
|
a4d27e75f
|
517 |
/** Is interrupt not implemented by fs? */ |
1729a16c2
|
518 |
unsigned no_interrupt:1; |
a4d27e75f
|
519 |
|
b2d2272fa
|
520 |
/** Is bmap not implemented by fs? */ |
1729a16c2
|
521 |
unsigned no_bmap:1; |
b2d2272fa
|
522 |
|
95668a69a
|
523 524 |
/** Is poll not implemented by fs? */ unsigned no_poll:1; |
78bb6cb9a
|
525 |
/** Do multi-page cached writes */ |
1729a16c2
|
526 |
unsigned big_writes:1; |
78bb6cb9a
|
527 |
|
e0a43ddcc
|
528 529 |
/** Don't apply umask to creation modes */ unsigned dont_mask:1; |
37fb3a30b
|
530 531 |
/** Are BSD file locking primitives not implemented by fs? */ unsigned no_flock:1; |
519c6040c
|
532 533 |
/** Is fallocate not implemented by fs? */ unsigned no_fallocate:1; |
1560c974d
|
534 535 |
/** Is rename with flags implemented by fs? */ unsigned no_rename2:1; |
72d0d248c
|
536 537 |
/** Use enhanced/automatic page cache invalidation. */ unsigned auto_inval_data:1; |
634734b63
|
538 |
/** Does the filesystem support readdirplus? */ |
0b05b1838
|
539 |
unsigned do_readdirplus:1; |
634734b63
|
540 541 |
/** Does the filesystem want adaptive readdirplus? */ unsigned readdirplus_auto:1; |
60b9df7a5
|
542 543 |
/** Does the filesystem support asynchronous direct-IO submission? */ unsigned async_dio:1; |
0b5da8db1
|
544 545 |
/** Is lseek not implemented by fs? */ unsigned no_lseek:1; |
0cd5b8855
|
546 547 |
/** The number of requests waiting for completion */ atomic_t num_waiting; |
45714d656
|
548 549 |
/** Negotiated minor version */ unsigned minor; |
d8a5ba454
|
550 551 |
/** Backing dev info */ struct backing_dev_info bdi; |
f543f253f
|
552 |
|
bafa96541
|
553 554 |
/** Entry on the fuse_conn_list */ struct list_head entry; |
b6f2fcbcf
|
555 556 |
/** Device ID from super block */ dev_t dev; |
bafa96541
|
557 558 559 560 561 562 |
/** Dentries in the control filesystem */ struct dentry *ctl_dentry[FUSE_CTL_NUM_DENTRIES]; /** number of dentries used in the above array */ int ctl_ndents; |
385a17bfc
|
563 |
|
9c8ef5614
|
564 565 |
/** Key for lock owner ID scrambling */ u32 scramble_key[4]; |
0ec7ca41f
|
566 567 568 |
/** Reserved request for the DESTROY message */ struct fuse_req *destroy_req; |
1fb69e781
|
569 570 571 |
/** Version counter for attribute changes */ u64 attr_version; |
43901aabd
|
572 573 574 |
/** Called on final put */ void (*release)(struct fuse_conn *); |
3b463ae0c
|
575 576 577 578 579 580 |
/** Super block for this connection. */ struct super_block *sb; /** Read/write semaphore to hold when accessing sb. */ struct rw_semaphore killsb; |
cc080e9e9
|
581 582 583 |
/** List of device instances belonging to this connection */ struct list_head devices; |
d8a5ba454
|
584 |
}; |
d8a5ba454
|
585 586 |
static inline struct fuse_conn *get_fuse_conn_super(struct super_block *sb) { |
6383bdaa2
|
587 |
return sb->s_fs_info; |
d8a5ba454
|
588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 |
} static inline struct fuse_conn *get_fuse_conn(struct inode *inode) { return get_fuse_conn_super(inode->i_sb); } static inline struct fuse_inode *get_fuse_inode(struct inode *inode) { return container_of(inode, struct fuse_inode, inode); } static inline u64 get_node_id(struct inode *inode) { return get_fuse_inode(inode)->nodeid; } |
334f485df
|
604 |
/** Device operations */ |
4b6f5d20b
|
605 |
extern const struct file_operations fuse_dev_operations; |
334f485df
|
606 |
|
4269590a7
|
607 |
extern const struct dentry_operations fuse_dentry_operations; |
dbd561d23
|
608 |
|
d8a5ba454
|
609 |
/** |
3b463ae0c
|
610 611 612 613 614 |
* Inode to nodeid comparison. */ int fuse_inode_eq(struct inode *inode, void *_nodeidp); /** |
e5e5558e9
|
615 616 |
* Get a filled in inode */ |
b48badf01
|
617 |
struct inode *fuse_iget(struct super_block *sb, u64 nodeid, |
1fb69e781
|
618 619 |
int generation, struct fuse_attr *attr, u64 attr_valid, u64 attr_version); |
e5e5558e9
|
620 |
|
33670fa29
|
621 622 |
int fuse_lookup_name(struct super_block *sb, u64 nodeid, struct qstr *name, struct fuse_entry_out *outarg, struct inode **inode); |
e5e5558e9
|
623 624 625 |
/** * Send FORGET command */ |
07e77dca8
|
626 627 628 629 |
void fuse_queue_forget(struct fuse_conn *fc, struct fuse_forget_link *forget, u64 nodeid, u64 nlookup); struct fuse_forget_link *fuse_alloc_forget(void); |
e5e5558e9
|
630 |
|
0b05b1838
|
631 632 |
/* Used by READDIRPLUS */ void fuse_force_forget(struct file *file, u64 nodeid); |
e5e5558e9
|
633 |
/** |
361b1eb55
|
634 |
* Initialize READ or READDIR request |
04730fef1
|
635 |
*/ |
a6643094e
|
636 |
void fuse_read_fill(struct fuse_req *req, struct file *file, |
2106cb189
|
637 |
loff_t pos, size_t count, int opcode); |
04730fef1
|
638 639 640 641 |
/** * Send OPEN or OPENDIR request */ |
91fe96b40
|
642 |
int fuse_open_common(struct inode *inode, struct file *file, bool isdir); |
04730fef1
|
643 |
|
acf99433d
|
644 |
struct fuse_file *fuse_file_alloc(struct fuse_conn *fc); |
c7b7143c6
|
645 |
struct fuse_file *fuse_file_get(struct fuse_file *ff); |
fd72faac9
|
646 |
void fuse_file_free(struct fuse_file *ff); |
c7b7143c6
|
647 |
void fuse_finish_open(struct inode *inode, struct file *file); |
fd72faac9
|
648 |
|
8b0797a49
|
649 |
void fuse_sync_release(struct fuse_file *ff, int flags); |
c756e0a4d
|
650 |
|
04730fef1
|
651 652 653 |
/** * Send RELEASE or RELEASEDIR request */ |
8b0797a49
|
654 |
void fuse_release_common(struct file *file, int opcode); |
04730fef1
|
655 656 |
/** |
825479819
|
657 658 |
* Send FSYNC or FSYNCDIR request */ |
02c24a821
|
659 660 |
int fuse_fsync_common(struct file *file, loff_t start, loff_t end, int datasync, int isdir); |
825479819
|
661 662 |
/** |
95668a69a
|
663 664 665 666 667 668 |
* Notify poll wakeup */ int fuse_notify_poll_wakeup(struct fuse_conn *fc, struct fuse_notify_poll_wakeup_out *outarg); /** |
1779381de
|
669 |
* Initialize file operations on a regular file |
b6aeadeda
|
670 671 672 673 |
*/ void fuse_init_file_inode(struct inode *inode); /** |
1779381de
|
674 |
* Initialize inode operations on regular files and special files |
e5e5558e9
|
675 676 677 678 |
*/ void fuse_init_common(struct inode *inode); /** |
1779381de
|
679 |
* Initialize inode and file operations on a directory |
e5e5558e9
|
680 681 682 683 |
*/ void fuse_init_dir(struct inode *inode); /** |
1779381de
|
684 |
* Initialize inode operations on a symlink |
e5e5558e9
|
685 686 687 688 689 690 |
*/ void fuse_init_symlink(struct inode *inode); /** * Change attributes of an inode */ |
1fb69e781
|
691 692 |
void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr, u64 attr_valid, u64 attr_version); |
e5e5558e9
|
693 |
|
3be5a52b3
|
694 695 |
void fuse_change_attributes_common(struct inode *inode, struct fuse_attr *attr, u64 attr_valid); |
e5e5558e9
|
696 |
/** |
334f485df
|
697 698 699 700 701 702 703 704 |
* Initialize the client device */ int fuse_dev_init(void); /** * Cleanup the client device */ void fuse_dev_cleanup(void); |
bafa96541
|
705 |
int fuse_ctl_init(void); |
7736e8cc5
|
706 |
void __exit fuse_ctl_cleanup(void); |
bafa96541
|
707 |
|
334f485df
|
708 709 710 |
/** * Allocate a request */ |
4250c0668
|
711 |
struct fuse_req *fuse_request_alloc(unsigned npages); |
334f485df
|
712 |
|
4250c0668
|
713 |
struct fuse_req *fuse_request_alloc_nofs(unsigned npages); |
3be5a52b3
|
714 |
|
334f485df
|
715 716 717 718 719 720 |
/** * Free a request */ void fuse_request_free(struct fuse_req *req); /** |
b111c8c0e
|
721 722 |
* Get a request, may fail with -ENOMEM, * caller should specify # elements in req->pages[] explicitly |
334f485df
|
723 |
*/ |
b111c8c0e
|
724 |
struct fuse_req *fuse_get_req(struct fuse_conn *fc, unsigned npages); |
8b41e6715
|
725 726 |
struct fuse_req *fuse_get_req_for_background(struct fuse_conn *fc, unsigned npages); |
b111c8c0e
|
727 |
|
36cf66ed9
|
728 729 730 731 |
/* * Increment reference count on request */ void __fuse_get_request(struct fuse_req *req); |
b111c8c0e
|
732 |
/** |
33649c91a
|
733 734 |
* Gets a requests for a file operation, always succeeds */ |
b111c8c0e
|
735 736 |
struct fuse_req *fuse_get_req_nofail_nopages(struct fuse_conn *fc, struct file *file); |
33649c91a
|
737 738 |
/** |
ce1d5a491
|
739 740 |
* Decrement reference count of a request. If count goes to zero free * the request. |
334f485df
|
741 742 743 744 |
*/ void fuse_put_request(struct fuse_conn *fc, struct fuse_req *req); /** |
7c352bdf0
|
745 |
* Send a request (synchronous) |
334f485df
|
746 |
*/ |
b93f858ab
|
747 |
void fuse_request_send(struct fuse_conn *fc, struct fuse_req *req); |
334f485df
|
748 749 |
/** |
7078187a7
|
750 751 752 753 754 |
* Simple request sending that does request allocation and freeing */ ssize_t fuse_simple_request(struct fuse_conn *fc, struct fuse_args *args); /** |
334f485df
|
755 756 |
* Send a request in the background */ |
b93f858ab
|
757 |
void fuse_request_send_background(struct fuse_conn *fc, struct fuse_req *req); |
334f485df
|
758 |
|
b93f858ab
|
759 760 |
void fuse_request_send_background_locked(struct fuse_conn *fc, struct fuse_req *req); |
3be5a52b3
|
761 |
|
5a5fb1ea7
|
762 |
/* Abort all requests */ |
69a53bf26
|
763 |
void fuse_abort_conn(struct fuse_conn *fc); |
1e9a4ed93
|
764 |
/** |
e5e5558e9
|
765 766 767 |
* Invalidate inode attributes */ void fuse_invalidate_attr(struct inode *inode); |
bafa96541
|
768 |
|
dbd561d23
|
769 |
void fuse_invalidate_entry_cache(struct dentry *entry); |
451418fc9
|
770 |
void fuse_invalidate_atime(struct inode *inode); |
bafa96541
|
771 772 773 774 775 776 |
/** * Acquire reference to fuse_conn */ struct fuse_conn *fuse_conn_get(struct fuse_conn *fc); /** |
0d179aa59
|
777 778 |
* Initialize fuse_conn */ |
a325f9b92
|
779 |
void fuse_conn_init(struct fuse_conn *fc); |
0d179aa59
|
780 781 |
/** |
bafa96541
|
782 783 784 |
* Release reference to fuse_conn */ void fuse_conn_put(struct fuse_conn *fc); |
cc080e9e9
|
785 786 |
struct fuse_dev *fuse_dev_alloc(struct fuse_conn *fc); void fuse_dev_free(struct fuse_dev *fud); |
bafa96541
|
787 788 789 790 791 792 793 794 795 |
/** * Add connection to control filesystem */ int fuse_ctl_add_conn(struct fuse_conn *fc); /** * Remove connection from control filesystem */ void fuse_ctl_remove_conn(struct fuse_conn *fc); |
a5bfffac6
|
796 797 798 799 800 |
/** * Is file type valid? */ int fuse_valid_type(int m); |
e57ac6837
|
801 802 |
/** |
c2132c1bc
|
803 |
* Is current process allowed to perform filesystem operation? |
e57ac6837
|
804 |
*/ |
c2132c1bc
|
805 |
int fuse_allow_current_process(struct fuse_conn *fc); |
f33321141
|
806 807 |
u64 fuse_lock_owner_id(struct fuse_conn *fc, fl_owner_t id); |
bcb4be809
|
808 809 810 |
int fuse_update_attributes(struct inode *inode, struct kstat *stat, struct file *file, bool *refreshed); |
3be5a52b3
|
811 812 813 814 815 |
void fuse_flush_writepages(struct inode *inode); void fuse_set_nowrite(struct inode *inode); void fuse_release_nowrite(struct inode *inode); |
5c5c5e51b
|
816 817 |
u64 fuse_get_attr_version(struct fuse_conn *fc); |
29d434b39
|
818 |
|
3b463ae0c
|
819 820 821 822 823 824 825 826 827 |
/** * File-system tells the kernel to invalidate cache for the given node id. */ int fuse_reverse_inval_inode(struct super_block *sb, u64 nodeid, loff_t offset, loff_t len); /** * File-system tells the kernel to invalidate parent attributes and * the dentry matching parent/name. |
451d0f599
|
828 829 830 831 832 833 |
* * If the child_nodeid is non-zero and: * - matches the inode number for the dentry matching parent/name, * - is not a mount point * - is a file or oan empty directory * then the dentry is unhashed (d_delete()). |
3b463ae0c
|
834 835 |
*/ int fuse_reverse_inval_entry(struct super_block *sb, u64 parent_nodeid, |
451d0f599
|
836 |
u64 child_nodeid, struct qstr *name); |
3b463ae0c
|
837 |
|
08cbf542b
|
838 839 |
int fuse_do_open(struct fuse_conn *fc, u64 nodeid, struct file *file, bool isdir); |
ea8cd3339
|
840 841 842 843 844 845 846 847 848 849 |
/** * fuse_direct_io() flags */ /** If set, it is WRITE; otherwise - READ */ #define FUSE_DIO_WRITE (1 << 0) /** CUSE pass fuse_direct_io() a file which f_mapping->host is not from FUSE */ #define FUSE_DIO_CUSE (1 << 1) |
d22a943f4
|
850 851 |
ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter, loff_t *ppos, int flags); |
08cbf542b
|
852 853 |
long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg, unsigned int flags); |
b18da0c56
|
854 855 |
long fuse_ioctl_common(struct file *file, unsigned int cmd, unsigned long arg, unsigned int flags); |
08cbf542b
|
856 857 |
unsigned fuse_file_poll(struct file *file, poll_table *wait); int fuse_dev_release(struct inode *inode, struct file *file); |
b0aa76065
|
858 |
bool fuse_write_update_size(struct inode *inode, loff_t pos); |
ab9e13f7c
|
859 |
int fuse_flush_times(struct inode *inode, struct fuse_file *ff); |
1e18bda86
|
860 |
int fuse_write_inode(struct inode *inode, struct writeback_control *wbc); |
a1d75f258
|
861 |
|
efb9fa9e9
|
862 863 |
int fuse_do_setattr(struct inode *inode, struct iattr *attr, struct file *file); |
9759bd518
|
864 |
void fuse_set_initialized(struct fuse_conn *fc); |
29d434b39
|
865 |
#endif /* _FS_FUSE_I_H */ |