blob: e8d96ec22533a78985b0a2ba242c168d35714c83 [file] [log] [blame]
Miklos Szeredid8a5ba42005-09-09 13:10:26 -07001/*
2 FUSE: Filesystem in Userspace
Miklos Szeredi1729a162008-11-26 12:03:54 +01003 Copyright (C) 2001-2008 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>
Tejun Heo95668a62008-11-26 12:03:55 +010022#include <linux/rbtree.h>
23#include <linux/poll.h>
Miklos Szeredi5a18ec12011-02-25 14:44:58 +010024#include <linux/workqueue.h>
Seth Forshee744742d2016-03-11 10:35:34 -060025#include <linux/kref.h>
Seth Forshee60bcc882016-08-29 08:46:37 -050026#include <linux/xattr.h>
Miklos Szeredid8a5ba42005-09-09 13:10:26 -070027
Miklos Szeredi334f4852005-09-09 13:10:27 -070028/** Max number of pages that can be used in a single read request */
29#define FUSE_MAX_PAGES_PER_REQ 32
30
Miklos Szeredi3be5a522008-04-30 00:54:41 -070031/** Bias for fi->writectr, meaning new writepages must not be sent */
32#define FUSE_NOWRITE INT_MIN
33
Miklos Szeredi1d3d7522006-01-06 00:19:40 -080034/** It could be as large as PATH_MAX, but would that have any uses? */
35#define FUSE_NAME_MAX 1024
36
Miklos Szeredibafa9652006-06-25 05:48:51 -070037/** Number of dentries for each connection in the control filesystem */
Csaba Henk79a9d992009-08-26 19:18:24 +020038#define FUSE_CTL_NUM_DENTRIES 5
Miklos Szeredibafa9652006-06-25 05:48:51 -070039
Miklos Szeredi1e9a4ed2005-09-09 13:10:31 -070040/** If the FUSE_DEFAULT_PERMISSIONS flag is given, the filesystem
41 module will check permissions based on the file mode. Otherwise no
42 permission checking is done in the kernel */
43#define FUSE_DEFAULT_PERMISSIONS (1 << 0)
44
45/** If the FUSE_ALLOW_OTHER flag is given, then not only the user
46 doing the mount will be allowed to access the filesystem */
47#define FUSE_ALLOW_OTHER (1 << 1)
48
Maxim Patlasov4250c062012-10-26 19:48:07 +040049/** Number of page pointers embedded in fuse_req */
50#define FUSE_REQ_INLINE_PAGES 1
51
Miklos Szeredibafa9652006-06-25 05:48:51 -070052/** List of active connections */
53extern struct list_head fuse_conn_list;
54
55/** Global mutex protecting fuse_conn_list and the control filesystem */
56extern struct mutex fuse_mutex;
Miklos Szeredi413ef8c2005-09-09 13:10:35 -070057
Csaba Henk79a9d992009-08-26 19:18:24 +020058/** Module parameters */
59extern unsigned max_user_bgreq;
60extern unsigned max_user_congthresh;
61
Miklos Szeredi07e77dc2010-12-07 20:16:56 +010062/* One forget request */
63struct fuse_forget_link {
Miklos Szeredi02c048b2010-12-07 20:16:56 +010064 struct fuse_forget_one forget_one;
Miklos Szeredi07e77dc2010-12-07 20:16:56 +010065 struct fuse_forget_link *next;
66};
67
Miklos Szeredid8a5ba42005-09-09 13:10:26 -070068/** FUSE inode */
69struct fuse_inode {
70 /** Inode data */
71 struct inode inode;
72
73 /** Unique ID, which identifies the inode between userspace
74 * and kernel */
75 u64 nodeid;
76
Miklos Szeredi9e6268d2005-09-09 13:10:29 -070077 /** Number of lookups on this inode */
78 u64 nlookup;
79
Miklos Szeredie5e55582005-09-09 13:10:28 -070080 /** The request used for sending the FORGET message */
Miklos Szeredi07e77dc2010-12-07 20:16:56 +010081 struct fuse_forget_link *forget;
Miklos Szeredie5e55582005-09-09 13:10:28 -070082
Miklos Szeredid8a5ba42005-09-09 13:10:26 -070083 /** Time in jiffies until the file attributes are valid */
Miklos Szeredi0a0898c2006-07-30 03:04:10 -070084 u64 i_time;
Miklos Szerediebc14c42007-10-16 23:31:03 -070085
86 /** The sticky bit in inode->i_mode may have been removed, so
87 preserve the original mode */
Al Viro541af6a2011-07-26 03:17:33 -040088 umode_t orig_i_mode;
Miklos Szeredi1fb69e72007-10-18 03:06:58 -070089
Pavel Shilovsky45c72cd2012-05-10 19:49:38 +040090 /** 64 bit inode number */
91 u64 orig_ino;
92
Miklos Szeredi1fb69e72007-10-18 03:06:58 -070093 /** Version of last attribute change */
94 u64 attr_version;
Miklos Szeredi93a8c3c2007-10-18 03:07:03 -070095
96 /** Files usable in writepage. Protected by fc->lock */
97 struct list_head write_files;
Miklos Szeredi3be5a522008-04-30 00:54:41 -070098
99 /** Writepages pending on truncate or fsync */
100 struct list_head queued_writes;
101
102 /** Number of sent writes, a negative bias (FUSE_NOWRITE)
103 * means more writes are blocked */
104 int writectr;
105
106 /** Waitq for writepage completion */
107 wait_queue_head_t page_waitq;
108
109 /** List of writepage requestst (pending or sent) */
110 struct list_head writepages;
Feng Shuo4582a4a2013-01-15 11:23:28 +0800111
112 /** Miscellaneous bits describing inode state */
113 unsigned long state;
Miklos Szeredi5c672ab2016-06-30 13:10:49 +0200114
115 /** Lock for serializing lookup and readdir for back compatibility*/
116 struct mutex mutex;
Feng Shuo4582a4a2013-01-15 11:23:28 +0800117};
118
119/** FUSE inode state bits */
120enum {
121 /** Advise readdirplus */
122 FUSE_I_ADVISE_RDPLUS,
Miklos Szeredi6314efe2013-10-01 16:41:22 +0200123 /** Initialized with readdirplus */
124 FUSE_I_INIT_RDPLUS,
Maxim Patlasov06a7c3c2013-08-30 17:06:04 +0400125 /** An operation changing file size is in progress */
126 FUSE_I_SIZE_UNSTABLE,
Miklos Szeredid8a5ba42005-09-09 13:10:26 -0700127};
128
Miklos Szeredida5e4712009-04-28 16:56:36 +0200129struct fuse_conn;
130
Miklos Szeredib6aeade2005-09-09 13:10:30 -0700131/** FUSE specific file data */
132struct fuse_file {
Miklos Szeredida5e4712009-04-28 16:56:36 +0200133 /** Fuse connection for this file */
134 struct fuse_conn *fc;
135
Miklos Szeredib6aeade2005-09-09 13:10:30 -0700136 /** Request reserved for flush and release */
Miklos Szeredi33649c92006-06-25 05:48:52 -0700137 struct fuse_req *reserved_req;
Miklos Szeredib6aeade2005-09-09 13:10:30 -0700138
Tejun Heoacf99432008-11-26 12:03:55 +0100139 /** Kernel file handle guaranteed to be unique */
140 u64 kh;
141
Miklos Szeredib6aeade2005-09-09 13:10:30 -0700142 /** File handle used by userspace */
143 u64 fh;
Miklos Szeredic756e0a2007-10-16 23:31:00 -0700144
Miklos Szeredida5e4712009-04-28 16:56:36 +0200145 /** Node id of this file */
146 u64 nodeid;
147
Miklos Szeredic756e0a2007-10-16 23:31:00 -0700148 /** Refcount */
149 atomic_t count;
Miklos Szeredi93a8c3c2007-10-18 03:07:03 -0700150
Miklos Szeredic7b71432009-04-28 16:56:37 +0200151 /** FOPEN_* flags returned by open */
152 u32 open_flags;
153
Miklos Szeredi93a8c3c2007-10-18 03:07:03 -0700154 /** Entry on inode's write_files list */
155 struct list_head write_entry;
Tejun Heo95668a62008-11-26 12:03:55 +0100156
157 /** RB node to be linked on fuse_conn->polled_files */
158 struct rb_node polled_node;
159
160 /** Wait queue head for poll */
161 wait_queue_head_t poll_wait;
Miklos Szeredi37fb3a32011-08-08 16:08:08 +0200162
163 /** Has flock been performed on this file? */
164 bool flock:1;
Miklos Szeredib6aeade2005-09-09 13:10:30 -0700165};
166
Miklos Szeredi334f4852005-09-09 13:10:27 -0700167/** One input argument of a request */
168struct fuse_in_arg {
169 unsigned size;
170 const void *value;
171};
172
173/** The request input */
174struct fuse_in {
175 /** The request header */
176 struct fuse_in_header h;
177
178 /** True if the data for the last argument is in req->pages */
179 unsigned argpages:1;
180
181 /** Number of arguments */
182 unsigned numargs;
183
184 /** Array of arguments */
185 struct fuse_in_arg args[3];
186};
187
188/** One output argument of a request */
189struct fuse_arg {
190 unsigned size;
191 void *value;
192};
193
194/** The request output */
195struct fuse_out {
196 /** Header returned from userspace */
197 struct fuse_out_header h;
198
Miklos Szeredi095da6c2006-01-16 22:14:52 -0800199 /*
200 * The following bitfields are not changed during the request
201 * processing
202 */
203
Miklos Szeredi334f4852005-09-09 13:10:27 -0700204 /** Last argument is variable length (can be shorter than
205 arg->size) */
206 unsigned argvar:1;
207
208 /** Last argument is a list of pages to copy data to */
209 unsigned argpages:1;
210
211 /** Zero partially or not copied pages */
212 unsigned page_zeroing:1;
213
Miklos Szeredice534fb2010-05-25 15:06:07 +0200214 /** Pages may be replaced with new ones */
215 unsigned page_replace:1;
216
Miklos Szeredi334f4852005-09-09 13:10:27 -0700217 /** Number or arguments */
218 unsigned numargs;
219
220 /** Array of arguments */
Miklos Szeredif704dcb2014-12-12 09:49:05 +0100221 struct fuse_arg args[2];
Miklos Szeredi334f4852005-09-09 13:10:27 -0700222};
223
Maxim Patlasovb2430d72012-10-26 19:49:24 +0400224/** FUSE page descriptor */
225struct fuse_page_desc {
226 unsigned int length;
227 unsigned int offset;
228};
229
Miklos Szeredi70781872014-12-12 09:49:05 +0100230struct fuse_args {
231 struct {
232 struct {
233 uint32_t opcode;
234 uint64_t nodeid;
235 } h;
236 unsigned numargs;
237 struct fuse_in_arg args[3];
238
239 } in;
240 struct {
241 unsigned argvar:1;
242 unsigned numargs;
243 struct fuse_arg args[2];
244 } out;
245};
246
247#define FUSE_ARGS(args) struct fuse_args args = {}
248
Maxim Patlasov01e9d112012-12-14 19:20:41 +0400249/** The request IO state (for asynchronous processing) */
250struct fuse_io_priv {
Seth Forshee744742d2016-03-11 10:35:34 -0600251 struct kref refcnt;
Maxim Patlasov01e9d112012-12-14 19:20:41 +0400252 int async;
253 spinlock_t lock;
254 unsigned reqs;
255 ssize_t bytes;
256 size_t size;
257 __u64 offset;
258 bool write;
259 int err;
260 struct kiocb *iocb;
261 struct file *file;
Christoph Hellwig9d5722b2015-02-02 14:59:43 +0100262 struct completion *done;
Ashish Sangwan7879c4e2016-04-07 17:18:11 +0530263 bool blocking;
Maxim Patlasov01e9d112012-12-14 19:20:41 +0400264};
265
Seth Forshee744742d2016-03-11 10:35:34 -0600266#define FUSE_IO_PRIV_SYNC(f) \
267{ \
268 .refcnt = { ATOMIC_INIT(1) }, \
269 .async = 0, \
270 .file = f, \
271}
272
Miklos Szeredi334f4852005-09-09 13:10:27 -0700273/**
Miklos Szeredi825d6d32015-07-01 16:25:58 +0200274 * Request flags
275 *
276 * FR_ISREPLY: set if the request has reply
277 * FR_FORCE: force sending of the request even if interrupted
278 * FR_BACKGROUND: request is sent in the background
279 * FR_WAITING: request is counted as "waiting"
280 * FR_ABORTED: the request was aborted
281 * FR_INTERRUPTED: the request has been interrupted
282 * FR_LOCKED: data is being copied to/from the request
Miklos Szeredi33e14b42015-07-01 16:26:01 +0200283 * FR_PENDING: request is not yet in userspace
284 * FR_SENT: request is in userspace, waiting for an answer
285 * FR_FINISHED: request is finished
Miklos Szeredi77cd9d42015-07-01 16:26:06 +0200286 * FR_PRIVATE: request is on private list
Miklos Szeredi825d6d32015-07-01 16:25:58 +0200287 */
288enum fuse_req_flag {
289 FR_ISREPLY,
290 FR_FORCE,
291 FR_BACKGROUND,
292 FR_WAITING,
293 FR_ABORTED,
294 FR_INTERRUPTED,
295 FR_LOCKED,
Miklos Szeredi33e14b42015-07-01 16:26:01 +0200296 FR_PENDING,
297 FR_SENT,
298 FR_FINISHED,
Miklos Szeredi77cd9d42015-07-01 16:26:06 +0200299 FR_PRIVATE,
Miklos Szeredi825d6d32015-07-01 16:25:58 +0200300};
301
302/**
Miklos Szeredi334f4852005-09-09 13:10:27 -0700303 * A request to the client
Miklos Szeredidc008092015-07-01 16:25:58 +0200304 *
305 * .waitq.lock protects the following fields:
306 * - FR_ABORTED
307 * - FR_LOCKED (may also be modified under fc->lock, tested under both)
Miklos Szeredi334f4852005-09-09 13:10:27 -0700308 */
309struct fuse_req {
Miklos Szeredice1d5a42006-04-10 22:54:58 -0700310 /** This can be on either pending processing or io lists in
311 fuse_conn */
Miklos Szeredi334f4852005-09-09 13:10:27 -0700312 struct list_head list;
313
Miklos Szeredia4d27e72006-06-25 05:48:54 -0700314 /** Entry on the interrupts list */
315 struct list_head intr_entry;
316
Miklos Szeredi334f4852005-09-09 13:10:27 -0700317 /** refcount */
318 atomic_t count;
319
Miklos Szeredia4d27e72006-06-25 05:48:54 -0700320 /** Unique ID for the interrupt request */
321 u64 intr_unique;
322
Miklos Szeredi825d6d32015-07-01 16:25:58 +0200323 /* Request flags, updated with test/set/clear_bit() */
324 unsigned long flags;
Miklos Szeredi9bc5ddd2006-04-11 21:16:09 +0200325
Miklos Szeredi334f4852005-09-09 13:10:27 -0700326 /** The request input */
327 struct fuse_in in;
328
329 /** The request output */
330 struct fuse_out out;
331
332 /** Used to wake up the task waiting for completion of request*/
333 wait_queue_head_t waitq;
334
335 /** Data for asynchronous requests */
336 union {
Miklos Szeredib57d4262008-02-06 01:38:39 -0800337 struct {
Miklos Szeredibaebccb2014-12-12 09:49:04 +0100338 struct fuse_release_in in;
339 struct inode *inode;
Miklos Szeredib57d4262008-02-06 01:38:39 -0800340 } release;
Miklos Szeredi3ec870d2006-01-06 00:19:41 -0800341 struct fuse_init_in init_in;
342 struct fuse_init_out init_out;
Tejun Heo08cbf542009-04-14 10:54:53 +0900343 struct cuse_init_in cuse_init_in;
Miklos Szeredi5c5c5e52008-04-30 00:54:43 -0700344 struct {
345 struct fuse_read_in in;
346 u64 attr_ver;
347 } read;
Miklos Szeredib25e82e2007-10-18 03:07:03 -0700348 struct {
349 struct fuse_write_in in;
350 struct fuse_write_out out;
Miklos Szeredi8b284dc2013-10-01 16:44:53 +0200351 struct fuse_req *next;
Miklos Szeredib25e82e2007-10-18 03:07:03 -0700352 } write;
Miklos Szeredi2d45ba32010-07-12 14:41:40 +0200353 struct fuse_notify_retrieve_in retrieve_in;
Miklos Szeredi334f4852005-09-09 13:10:27 -0700354 } misc;
355
356 /** page vector */
Maxim Patlasov4250c062012-10-26 19:48:07 +0400357 struct page **pages;
358
Maxim Patlasovb2430d72012-10-26 19:49:24 +0400359 /** page-descriptor vector */
360 struct fuse_page_desc *page_descs;
361
Maxim Patlasov4250c062012-10-26 19:48:07 +0400362 /** size of the 'pages' array */
363 unsigned max_pages;
364
365 /** inline page vector */
366 struct page *inline_pages[FUSE_REQ_INLINE_PAGES];
Miklos Szeredi334f4852005-09-09 13:10:27 -0700367
Maxim Patlasovb2430d72012-10-26 19:49:24 +0400368 /** inline page-descriptor vector */
369 struct fuse_page_desc inline_page_descs[FUSE_REQ_INLINE_PAGES];
370
Miklos Szeredi334f4852005-09-09 13:10:27 -0700371 /** number of pages in vector */
372 unsigned num_pages;
373
Miklos Szeredi334f4852005-09-09 13:10:27 -0700374 /** File used in the request (or NULL) */
Miklos Szeredic756e0a2007-10-16 23:31:00 -0700375 struct fuse_file *ff;
Miklos Szeredi64c6d8e2006-01-16 22:14:42 -0800376
Miklos Szeredi3be5a522008-04-30 00:54:41 -0700377 /** Inode used in the request or NULL */
378 struct inode *inode;
379
Maxim Patlasov01e9d112012-12-14 19:20:41 +0400380 /** AIO control block */
381 struct fuse_io_priv *io;
382
Miklos Szeredi3be5a522008-04-30 00:54:41 -0700383 /** Link on fi->writepages */
384 struct list_head writepages_entry;
385
Miklos Szeredi64c6d8e2006-01-16 22:14:42 -0800386 /** Request completion callback */
387 void (*end)(struct fuse_conn *, struct fuse_req *);
Miklos Szeredi33649c92006-06-25 05:48:52 -0700388
389 /** Request is stolen from fuse_file->reserved_req */
390 struct file *stolen_file;
Miklos Szeredi334f4852005-09-09 13:10:27 -0700391};
392
Miklos Szeredif88996a2015-07-01 16:26:01 +0200393struct fuse_iqueue {
Miklos Szeredie16714d2015-07-01 16:26:01 +0200394 /** Connection established */
395 unsigned connected;
396
Miklos Szeredif88996a2015-07-01 16:26:01 +0200397 /** Readers of the connection are waiting on this */
398 wait_queue_head_t waitq;
399
400 /** The next unique request id */
401 u64 reqctr;
402
403 /** The list of pending requests */
404 struct list_head pending;
405
406 /** Pending interrupts */
407 struct list_head interrupts;
408
409 /** Queue of pending forgets */
410 struct fuse_forget_link forget_list_head;
411 struct fuse_forget_link *forget_list_tail;
412
413 /** Batching of FORGET requests (positive indicates FORGET batch) */
414 int forget_batch;
415
416 /** O_ASYNC requests */
417 struct fasync_struct *fasync;
418};
419
Miklos Szeredi3a2b5b92015-07-01 16:26:04 +0200420struct fuse_pqueue {
Miklos Szeredie96edd92015-07-01 16:26:04 +0200421 /** Connection established */
422 unsigned connected;
423
Miklos Szeredi45a91cb2015-07-01 16:26:06 +0200424 /** Lock protecting accessess to members of this structure */
425 spinlock_t lock;
426
Miklos Szeredi3a2b5b92015-07-01 16:26:04 +0200427 /** The list of requests being processed */
428 struct list_head processing;
429
430 /** The list of requests under I/O */
431 struct list_head io;
432};
433
Miklos Szeredid8a5ba42005-09-09 13:10:26 -0700434/**
Miklos Szeredicc080e92015-07-01 16:26:08 +0200435 * Fuse device instance
436 */
437struct fuse_dev {
438 /** Fuse connection for this device */
439 struct fuse_conn *fc;
440
Miklos Szeredic36960462015-07-01 16:26:09 +0200441 /** Processing queue */
442 struct fuse_pqueue pq;
443
Miklos Szeredicc080e92015-07-01 16:26:08 +0200444 /** list entry on fc->devices */
445 struct list_head entry;
446};
447
448/**
Miklos Szeredid8a5ba42005-09-09 13:10:26 -0700449 * A Fuse connection.
450 *
451 * This structure is created, when the filesystem is mounted, and is
452 * destroyed, when the client device is closed and the filesystem is
453 * unmounted.
454 */
455struct fuse_conn {
Miklos Szeredid7133112006-04-10 22:54:55 -0700456 /** Lock protecting accessess to members of this structure */
457 spinlock_t lock;
458
Miklos Szeredibafa9652006-06-25 05:48:51 -0700459 /** Refcount */
460 atomic_t count;
461
Miklos Szeredic36960462015-07-01 16:26:09 +0200462 /** Number of fuse_dev's */
463 atomic_t dev_count;
464
Al Virodd3e2c52013-10-03 21:21:39 -0400465 struct rcu_head rcu;
466
Miklos Szeredid8a5ba42005-09-09 13:10:26 -0700467 /** The user id for this mount */
Eric W. Biederman499dcf22012-02-07 16:26:03 -0800468 kuid_t user_id;
Miklos Szeredid8a5ba42005-09-09 13:10:26 -0700469
Miklos Szeredi87729a52005-09-09 13:10:34 -0700470 /** The group id for this mount */
Eric W. Biederman499dcf22012-02-07 16:26:03 -0800471 kgid_t group_id;
Miklos Szeredi87729a52005-09-09 13:10:34 -0700472
Miklos Szeredi1e9a4ed2005-09-09 13:10:31 -0700473 /** The fuse mount flags for this mount */
474 unsigned flags;
475
Miklos Szeredidb50b962005-09-09 13:10:33 -0700476 /** Maximum read size */
477 unsigned max_read;
478
Miklos Szeredi413ef8c2005-09-09 13:10:35 -0700479 /** Maximum write size */
480 unsigned max_write;
481
Miklos Szeredif88996a2015-07-01 16:26:01 +0200482 /** Input queue */
483 struct fuse_iqueue iq;
Miklos Szeredi334f4852005-09-09 13:10:27 -0700484
Tejun Heoacf99432008-11-26 12:03:55 +0100485 /** The next unique kernel file handle */
486 u64 khctr;
487
Tejun Heo95668a62008-11-26 12:03:55 +0100488 /** rbtree of fuse_files waiting for poll events indexed by ph */
489 struct rb_root polled_files;
490
Csaba Henk7a6d3c82009-07-01 17:28:41 -0700491 /** Maximum number of outstanding background requests */
492 unsigned max_background;
493
494 /** Number of background requests at which congestion starts */
495 unsigned congestion_threshold;
496
Miklos Szeredi08a53cd2006-04-10 22:54:59 -0700497 /** Number of requests currently in the background */
498 unsigned num_background;
499
Miklos Szeredid12def12008-02-06 01:38:39 -0800500 /** Number of background requests currently queued for userspace */
501 unsigned active_background;
502
503 /** The list of background requests set aside for later queuing */
504 struct list_head bg_queue;
505
Maxim Patlasov796523fb2013-03-21 18:02:15 +0400506 /** Flag indicating that INIT reply has been received. Allocating
507 * any fuse request will be suspended until the flag is set */
508 int initialized;
509
Miklos Szeredi08a53cd2006-04-10 22:54:59 -0700510 /** Flag indicating if connection is blocked. This will be
511 the case before the INIT reply is received, and if there
512 are too many outstading backgrounds requests */
513 int blocked;
514
515 /** waitq for blocked connection */
516 wait_queue_head_t blocked_waitq;
517
Miklos Szeredide5e3de2007-10-16 23:31:00 -0700518 /** waitq for reserved requests */
519 wait_queue_head_t reserved_req_waitq;
520
Miklos Szeredi69a53bf2006-01-16 22:14:41 -0800521 /** Connection established, cleared on umount, connection
522 abort and device release */
Miklos Szeredi095da6c2006-01-16 22:14:52 -0800523 unsigned connected;
Miklos Szeredi1e9a4ed2005-09-09 13:10:31 -0700524
Miklos Szeredi095da6c2006-01-16 22:14:52 -0800525 /** Connection failed (version mismatch). Cannot race with
526 setting other bitfields since it is only set once in INIT
527 reply, before any other request, and never cleared */
Miklos Szeredi1729a162008-11-26 12:03:54 +0100528 unsigned conn_error:1;
Miklos Szeredi334f4852005-09-09 13:10:27 -0700529
Miklos Szeredi0ec7ca42006-12-06 20:35:52 -0800530 /** Connection successful. Only set in INIT */
Miklos Szeredi1729a162008-11-26 12:03:54 +0100531 unsigned conn_init:1;
Miklos Szeredi0ec7ca42006-12-06 20:35:52 -0800532
Miklos Szeredi9cd68452006-02-01 03:04:40 -0800533 /** Do readpages asynchronously? Only set in INIT */
Miklos Szeredi1729a162008-11-26 12:03:54 +0100534 unsigned async_read:1;
Miklos Szeredi9cd68452006-02-01 03:04:40 -0800535
Miklos Szeredi6ff958e2007-10-18 03:07:02 -0700536 /** Do not send separate SETATTR request before open(O_TRUNC) */
Miklos Szeredi1729a162008-11-26 12:03:54 +0100537 unsigned atomic_o_trunc:1;
Miklos Szeredi6ff958e2007-10-18 03:07:02 -0700538
Miklos Szeredi33670fa2008-07-25 01:49:02 -0700539 /** Filesystem supports NFS exporting. Only set in INIT */
Miklos Szeredi1729a162008-11-26 12:03:54 +0100540 unsigned export_support:1;
Miklos Szeredi33670fa2008-07-25 01:49:02 -0700541
Tejun Heoa325f9b2009-04-14 10:54:52 +0900542 /** Set if bdi is valid */
543 unsigned bdi_initialized:1;
544
Pavel Emelyanovd5cd66c2013-10-10 17:10:30 +0400545 /** write-back cache policy (default is write-through) */
546 unsigned writeback_cache:1;
547
Miklos Szeredi5c672ab2016-06-30 13:10:49 +0200548 /** allow parallel lookups and readdir (default is serialized) */
549 unsigned parallel_dirops:1;
550
Miklos Szeredi5e940c12016-10-01 07:32:32 +0200551 /** handle fs handles killing suid/sgid/cap on write/chown/trunc */
552 unsigned handle_killpriv:1;
553
Miklos Szeredi095da6c2006-01-16 22:14:52 -0800554 /*
555 * The following bitfields are only for optimization purposes
556 * and hence races in setting them will not cause malfunction
557 */
558
Andrew Gallagher7678ac52013-11-05 16:05:52 +0100559 /** Is open/release not implemented by fs? */
560 unsigned no_open:1;
561
Miklos Szeredib6aeade2005-09-09 13:10:30 -0700562 /** Is fsync not implemented by fs? */
Miklos Szeredi1729a162008-11-26 12:03:54 +0100563 unsigned no_fsync:1;
Miklos Szeredib6aeade2005-09-09 13:10:30 -0700564
Miklos Szeredi82547982005-09-09 13:10:38 -0700565 /** Is fsyncdir not implemented by fs? */
Miklos Szeredi1729a162008-11-26 12:03:54 +0100566 unsigned no_fsyncdir:1;
Miklos Szeredi82547982005-09-09 13:10:38 -0700567
Miklos Szeredib6aeade2005-09-09 13:10:30 -0700568 /** Is flush not implemented by fs? */
Miklos Szeredi1729a162008-11-26 12:03:54 +0100569 unsigned no_flush:1;
Miklos Szeredib6aeade2005-09-09 13:10:30 -0700570
Miklos Szeredi92a87802005-09-09 13:10:31 -0700571 /** Is setxattr not implemented by fs? */
Miklos Szeredi1729a162008-11-26 12:03:54 +0100572 unsigned no_setxattr:1;
Miklos Szeredi92a87802005-09-09 13:10:31 -0700573
574 /** Is getxattr not implemented by fs? */
Miklos Szeredi1729a162008-11-26 12:03:54 +0100575 unsigned no_getxattr:1;
Miklos Szeredi92a87802005-09-09 13:10:31 -0700576
577 /** Is listxattr not implemented by fs? */
Miklos Szeredi1729a162008-11-26 12:03:54 +0100578 unsigned no_listxattr:1;
Miklos Szeredi92a87802005-09-09 13:10:31 -0700579
580 /** Is removexattr not implemented by fs? */
Miklos Szeredi1729a162008-11-26 12:03:54 +0100581 unsigned no_removexattr:1;
Miklos Szeredi92a87802005-09-09 13:10:31 -0700582
Miklos Szeredi37fb3a32011-08-08 16:08:08 +0200583 /** Are posix file locking primitives not implemented by fs? */
Miklos Szeredi1729a162008-11-26 12:03:54 +0100584 unsigned no_lock:1;
Miklos Szeredi71421252006-06-25 05:48:52 -0700585
Miklos Szeredi31d40d72005-11-07 00:59:50 -0800586 /** Is access not implemented by fs? */
Miklos Szeredi1729a162008-11-26 12:03:54 +0100587 unsigned no_access:1;
Miklos Szeredi31d40d72005-11-07 00:59:50 -0800588
Miklos Szeredifd72faa2005-11-07 00:59:51 -0800589 /** Is create not implemented by fs? */
Miklos Szeredi1729a162008-11-26 12:03:54 +0100590 unsigned no_create:1;
Miklos Szeredifd72faa2005-11-07 00:59:51 -0800591
Miklos Szeredia4d27e72006-06-25 05:48:54 -0700592 /** Is interrupt not implemented by fs? */
Miklos Szeredi1729a162008-11-26 12:03:54 +0100593 unsigned no_interrupt:1;
Miklos Szeredia4d27e72006-06-25 05:48:54 -0700594
Miklos Szeredib2d22722006-12-06 20:35:51 -0800595 /** Is bmap not implemented by fs? */
Miklos Szeredi1729a162008-11-26 12:03:54 +0100596 unsigned no_bmap:1;
Miklos Szeredib2d22722006-12-06 20:35:51 -0800597
Tejun Heo95668a62008-11-26 12:03:55 +0100598 /** Is poll not implemented by fs? */
599 unsigned no_poll:1;
600
Miklos Szeredi78bb6cb2008-05-12 14:02:32 -0700601 /** Do multi-page cached writes */
Miklos Szeredi1729a162008-11-26 12:03:54 +0100602 unsigned big_writes:1;
Miklos Szeredi78bb6cb2008-05-12 14:02:32 -0700603
Miklos Szeredie0a43dd2009-06-30 20:12:23 +0200604 /** Don't apply umask to creation modes */
605 unsigned dont_mask:1;
606
Miklos Szeredi37fb3a32011-08-08 16:08:08 +0200607 /** Are BSD file locking primitives not implemented by fs? */
608 unsigned no_flock:1;
609
Miklos Szeredi519c6042012-04-26 10:56:36 +0200610 /** Is fallocate not implemented by fs? */
611 unsigned no_fallocate:1;
612
Miklos Szeredi1560c972014-04-28 16:43:44 +0200613 /** Is rename with flags implemented by fs? */
614 unsigned no_rename2:1;
615
Brian Foster72d0d242012-07-16 15:23:48 -0400616 /** Use enhanced/automatic page cache invalidation. */
617 unsigned auto_inval_data:1;
618
Eric Wong634734b2013-02-06 22:29:01 +0000619 /** Does the filesystem support readdirplus? */
Anand V. Avati0b05b182012-08-19 08:53:23 -0400620 unsigned do_readdirplus:1;
621
Eric Wong634734b2013-02-06 22:29:01 +0000622 /** Does the filesystem want adaptive readdirplus? */
623 unsigned readdirplus_auto:1;
624
Miklos Szeredi60b9df72013-05-01 14:37:21 +0200625 /** Does the filesystem support asynchronous direct-IO submission? */
626 unsigned async_dio:1;
627
Ravishankar N0b5da8d2015-06-30 23:40:22 +0530628 /** Is lseek not implemented by fs? */
629 unsigned no_lseek:1;
630
Seth Forshee60bcc882016-08-29 08:46:37 -0500631 /** Does the filesystem support posix acls? */
632 unsigned posix_acl:1;
633
Miklos Szeredi0cd5b882006-01-16 22:14:38 -0800634 /** The number of requests waiting for completion */
635 atomic_t num_waiting;
636
Miklos Szeredi45714d62006-01-06 00:19:36 -0800637 /** Negotiated minor version */
638 unsigned minor;
639
Miklos Szeredid8a5ba42005-09-09 13:10:26 -0700640 /** Backing dev info */
641 struct backing_dev_info bdi;
Miklos Szeredif543f252006-01-16 22:14:35 -0800642
Miklos Szeredibafa9652006-06-25 05:48:51 -0700643 /** Entry on the fuse_conn_list */
644 struct list_head entry;
645
Miklos Szeredib6f2fcb2008-04-30 00:54:34 -0700646 /** Device ID from super block */
647 dev_t dev;
Miklos Szeredibafa9652006-06-25 05:48:51 -0700648
649 /** Dentries in the control filesystem */
650 struct dentry *ctl_dentry[FUSE_CTL_NUM_DENTRIES];
651
652 /** number of dentries used in the above array */
653 int ctl_ndents;
Jeff Dike385a17b2006-04-10 22:54:52 -0700654
Miklos Szeredi9c8ef562006-06-25 05:48:55 -0700655 /** Key for lock owner ID scrambling */
656 u32 scramble_key[4];
Miklos Szeredi0ec7ca42006-12-06 20:35:52 -0800657
658 /** Reserved request for the DESTROY message */
659 struct fuse_req *destroy_req;
Miklos Szeredi1fb69e72007-10-18 03:06:58 -0700660
661 /** Version counter for attribute changes */
662 u64 attr_version;
Tejun Heo43901aa2008-11-26 12:03:56 +0100663
664 /** Called on final put */
665 void (*release)(struct fuse_conn *);
John Muir3b463ae2009-05-31 11:13:57 -0400666
667 /** Super block for this connection. */
668 struct super_block *sb;
669
670 /** Read/write semaphore to hold when accessing sb. */
671 struct rw_semaphore killsb;
Miklos Szeredicc080e92015-07-01 16:26:08 +0200672
673 /** List of device instances belonging to this connection */
674 struct list_head devices;
Miklos Szeredid8a5ba42005-09-09 13:10:26 -0700675};
676
Miklos Szeredid8a5ba42005-09-09 13:10:26 -0700677static inline struct fuse_conn *get_fuse_conn_super(struct super_block *sb)
678{
Miklos Szeredi6383bda2006-01-16 22:14:29 -0800679 return sb->s_fs_info;
Miklos Szeredid8a5ba42005-09-09 13:10:26 -0700680}
681
682static inline struct fuse_conn *get_fuse_conn(struct inode *inode)
683{
684 return get_fuse_conn_super(inode->i_sb);
685}
686
687static inline struct fuse_inode *get_fuse_inode(struct inode *inode)
688{
689 return container_of(inode, struct fuse_inode, inode);
690}
691
692static inline u64 get_node_id(struct inode *inode)
693{
694 return get_fuse_inode(inode)->nodeid;
695}
696
Miklos Szeredi334f4852005-09-09 13:10:27 -0700697/** Device operations */
Arjan van de Ven4b6f5d22006-03-28 01:56:42 -0800698extern const struct file_operations fuse_dev_operations;
Miklos Szeredi334f4852005-09-09 13:10:27 -0700699
Al Viro42695902009-02-20 05:59:13 +0000700extern const struct dentry_operations fuse_dentry_operations;
Miklos Szeredidbd561d2008-07-25 01:49:00 -0700701
Miklos Szeredid8a5ba42005-09-09 13:10:26 -0700702/**
John Muir3b463ae2009-05-31 11:13:57 -0400703 * Inode to nodeid comparison.
704 */
705int fuse_inode_eq(struct inode *inode, void *_nodeidp);
706
707/**
Miklos Szeredie5e55582005-09-09 13:10:28 -0700708 * Get a filled in inode
709 */
Miklos Szeredib48badf2008-04-30 00:54:44 -0700710struct inode *fuse_iget(struct super_block *sb, u64 nodeid,
Miklos Szeredi1fb69e72007-10-18 03:06:58 -0700711 int generation, struct fuse_attr *attr,
712 u64 attr_valid, u64 attr_version);
Miklos Szeredie5e55582005-09-09 13:10:28 -0700713
Al Viro13983d02016-07-20 22:34:44 -0400714int fuse_lookup_name(struct super_block *sb, u64 nodeid, const struct qstr *name,
Miklos Szeredi33670fa2008-07-25 01:49:02 -0700715 struct fuse_entry_out *outarg, struct inode **inode);
716
Miklos Szeredie5e55582005-09-09 13:10:28 -0700717/**
718 * Send FORGET command
719 */
Miklos Szeredi07e77dc2010-12-07 20:16:56 +0100720void fuse_queue_forget(struct fuse_conn *fc, struct fuse_forget_link *forget,
721 u64 nodeid, u64 nlookup);
722
723struct fuse_forget_link *fuse_alloc_forget(void);
Miklos Szeredie5e55582005-09-09 13:10:28 -0700724
Anand V. Avati0b05b182012-08-19 08:53:23 -0400725/* Used by READDIRPLUS */
726void fuse_force_forget(struct file *file, u64 nodeid);
727
Miklos Szeredie5e55582005-09-09 13:10:28 -0700728/**
Miklos Szeredi361b1eb52006-01-16 22:14:45 -0800729 * Initialize READ or READDIR request
Miklos Szeredi04730fe2005-09-09 13:10:36 -0700730 */
Miklos Szeredia6643092007-11-28 16:22:00 -0800731void fuse_read_fill(struct fuse_req *req, struct file *file,
Miklos Szeredi2106cb12009-04-28 16:56:37 +0200732 loff_t pos, size_t count, int opcode);
Miklos Szeredi04730fe2005-09-09 13:10:36 -0700733
734/**
735 * Send OPEN or OPENDIR request
736 */
Miklos Szeredi91fe96b2009-04-28 16:56:37 +0200737int fuse_open_common(struct inode *inode, struct file *file, bool isdir);
Miklos Szeredi04730fe2005-09-09 13:10:36 -0700738
Tejun Heoacf99432008-11-26 12:03:55 +0100739struct fuse_file *fuse_file_alloc(struct fuse_conn *fc);
Miklos Szeredic7b71432009-04-28 16:56:37 +0200740struct fuse_file *fuse_file_get(struct fuse_file *ff);
Miklos Szeredifd72faa2005-11-07 00:59:51 -0800741void fuse_file_free(struct fuse_file *ff);
Miklos Szeredic7b71432009-04-28 16:56:37 +0200742void fuse_finish_open(struct inode *inode, struct file *file);
Miklos Szeredifd72faa2005-11-07 00:59:51 -0800743
Miklos Szeredi8b0797a2009-04-28 16:56:39 +0200744void fuse_sync_release(struct fuse_file *ff, int flags);
Miklos Szeredic756e0a2007-10-16 23:31:00 -0700745
Miklos Szeredi04730fe2005-09-09 13:10:36 -0700746/**
747 * Send RELEASE or RELEASEDIR request
748 */
Miklos Szeredi8b0797a2009-04-28 16:56:39 +0200749void fuse_release_common(struct file *file, int opcode);
Miklos Szeredi04730fe2005-09-09 13:10:36 -0700750
751/**
Miklos Szeredi82547982005-09-09 13:10:38 -0700752 * Send FSYNC or FSYNCDIR request
753 */
Josef Bacik02c24a82011-07-16 20:44:56 -0400754int fuse_fsync_common(struct file *file, loff_t start, loff_t end,
755 int datasync, int isdir);
Miklos Szeredi82547982005-09-09 13:10:38 -0700756
757/**
Tejun Heo95668a62008-11-26 12:03:55 +0100758 * Notify poll wakeup
759 */
760int fuse_notify_poll_wakeup(struct fuse_conn *fc,
761 struct fuse_notify_poll_wakeup_out *outarg);
762
763/**
Miklos Szeredi17793812005-10-30 15:02:51 -0800764 * Initialize file operations on a regular file
Miklos Szeredib6aeade2005-09-09 13:10:30 -0700765 */
766void fuse_init_file_inode(struct inode *inode);
767
768/**
Miklos Szeredi17793812005-10-30 15:02:51 -0800769 * Initialize inode operations on regular files and special files
Miklos Szeredie5e55582005-09-09 13:10:28 -0700770 */
771void fuse_init_common(struct inode *inode);
772
773/**
Miklos Szeredi17793812005-10-30 15:02:51 -0800774 * Initialize inode and file operations on a directory
Miklos Szeredie5e55582005-09-09 13:10:28 -0700775 */
776void fuse_init_dir(struct inode *inode);
777
778/**
Miklos Szeredi17793812005-10-30 15:02:51 -0800779 * Initialize inode operations on a symlink
Miklos Szeredie5e55582005-09-09 13:10:28 -0700780 */
781void fuse_init_symlink(struct inode *inode);
782
783/**
784 * Change attributes of an inode
785 */
Miklos Szeredi1fb69e72007-10-18 03:06:58 -0700786void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr,
787 u64 attr_valid, u64 attr_version);
Miklos Szeredie5e55582005-09-09 13:10:28 -0700788
Miklos Szeredi3be5a522008-04-30 00:54:41 -0700789void fuse_change_attributes_common(struct inode *inode, struct fuse_attr *attr,
790 u64 attr_valid);
791
Miklos Szeredie5e55582005-09-09 13:10:28 -0700792/**
Miklos Szeredi334f4852005-09-09 13:10:27 -0700793 * Initialize the client device
794 */
795int fuse_dev_init(void);
796
797/**
798 * Cleanup the client device
799 */
800void fuse_dev_cleanup(void);
801
Miklos Szeredibafa9652006-06-25 05:48:51 -0700802int fuse_ctl_init(void);
Fabian Frederick7736e8c2014-04-23 18:14:42 +0200803void __exit fuse_ctl_cleanup(void);
Miklos Szeredibafa9652006-06-25 05:48:51 -0700804
Miklos Szeredi334f4852005-09-09 13:10:27 -0700805/**
806 * Allocate a request
807 */
Maxim Patlasov4250c062012-10-26 19:48:07 +0400808struct fuse_req *fuse_request_alloc(unsigned npages);
Miklos Szeredi334f4852005-09-09 13:10:27 -0700809
Maxim Patlasov4250c062012-10-26 19:48:07 +0400810struct fuse_req *fuse_request_alloc_nofs(unsigned npages);
Miklos Szeredi3be5a522008-04-30 00:54:41 -0700811
Miklos Szeredi334f4852005-09-09 13:10:27 -0700812/**
813 * Free a request
814 */
815void fuse_request_free(struct fuse_req *req);
816
817/**
Maxim Patlasovb111c8c2012-10-26 19:48:30 +0400818 * Get a request, may fail with -ENOMEM,
819 * caller should specify # elements in req->pages[] explicitly
Miklos Szeredi334f4852005-09-09 13:10:27 -0700820 */
Maxim Patlasovb111c8c2012-10-26 19:48:30 +0400821struct fuse_req *fuse_get_req(struct fuse_conn *fc, unsigned npages);
Maxim Patlasov8b41e672013-03-21 18:02:04 +0400822struct fuse_req *fuse_get_req_for_background(struct fuse_conn *fc,
823 unsigned npages);
Maxim Patlasovb111c8c2012-10-26 19:48:30 +0400824
Maxim Patlasov36cf66e2012-12-14 19:20:51 +0400825/*
826 * Increment reference count on request
827 */
828void __fuse_get_request(struct fuse_req *req);
829
Maxim Patlasovb111c8c2012-10-26 19:48:30 +0400830/**
Miklos Szeredi33649c92006-06-25 05:48:52 -0700831 * Gets a requests for a file operation, always succeeds
832 */
Maxim Patlasovb111c8c2012-10-26 19:48:30 +0400833struct fuse_req *fuse_get_req_nofail_nopages(struct fuse_conn *fc,
834 struct file *file);
Miklos Szeredi33649c92006-06-25 05:48:52 -0700835
836/**
Miklos Szeredice1d5a42006-04-10 22:54:58 -0700837 * Decrement reference count of a request. If count goes to zero free
838 * the request.
Miklos Szeredi334f4852005-09-09 13:10:27 -0700839 */
840void fuse_put_request(struct fuse_conn *fc, struct fuse_req *req);
841
842/**
Miklos Szeredi7c352bd2005-09-09 13:10:39 -0700843 * Send a request (synchronous)
Miklos Szeredi334f4852005-09-09 13:10:27 -0700844 */
Tejun Heob93f8582008-11-26 12:03:55 +0100845void fuse_request_send(struct fuse_conn *fc, struct fuse_req *req);
Miklos Szeredi334f4852005-09-09 13:10:27 -0700846
847/**
Miklos Szeredi70781872014-12-12 09:49:05 +0100848 * Simple request sending that does request allocation and freeing
849 */
850ssize_t fuse_simple_request(struct fuse_conn *fc, struct fuse_args *args);
851
852/**
Miklos Szeredi334f4852005-09-09 13:10:27 -0700853 * Send a request in the background
854 */
Tejun Heob93f8582008-11-26 12:03:55 +0100855void fuse_request_send_background(struct fuse_conn *fc, struct fuse_req *req);
Miklos Szeredi334f4852005-09-09 13:10:27 -0700856
Tejun Heob93f8582008-11-26 12:03:55 +0100857void fuse_request_send_background_locked(struct fuse_conn *fc,
858 struct fuse_req *req);
Miklos Szeredi3be5a522008-04-30 00:54:41 -0700859
Miklos Szeredi5a5fb1e2006-04-26 10:48:55 +0200860/* Abort all requests */
Miklos Szeredi69a53bf2006-01-16 22:14:41 -0800861void fuse_abort_conn(struct fuse_conn *fc);
862
Miklos Szeredi1e9a4ed2005-09-09 13:10:31 -0700863/**
Miklos Szeredie5e55582005-09-09 13:10:28 -0700864 * Invalidate inode attributes
865 */
866void fuse_invalidate_attr(struct inode *inode);
Miklos Szeredibafa9652006-06-25 05:48:51 -0700867
Miklos Szeredidbd561d2008-07-25 01:49:00 -0700868void fuse_invalidate_entry_cache(struct dentry *entry);
869
Andrew Gallagher451418f2013-11-05 03:55:43 -0800870void fuse_invalidate_atime(struct inode *inode);
871
Miklos Szeredibafa9652006-06-25 05:48:51 -0700872/**
873 * Acquire reference to fuse_conn
874 */
875struct fuse_conn *fuse_conn_get(struct fuse_conn *fc);
876
877/**
Tejun Heo0d179aa2008-11-26 12:03:55 +0100878 * Initialize fuse_conn
879 */
Tejun Heoa325f9b2009-04-14 10:54:52 +0900880void fuse_conn_init(struct fuse_conn *fc);
Tejun Heo0d179aa2008-11-26 12:03:55 +0100881
882/**
Miklos Szeredibafa9652006-06-25 05:48:51 -0700883 * Release reference to fuse_conn
884 */
885void fuse_conn_put(struct fuse_conn *fc);
886
Miklos Szeredicc080e92015-07-01 16:26:08 +0200887struct fuse_dev *fuse_dev_alloc(struct fuse_conn *fc);
888void fuse_dev_free(struct fuse_dev *fud);
889
Miklos Szeredibafa9652006-06-25 05:48:51 -0700890/**
891 * Add connection to control filesystem
892 */
893int fuse_ctl_add_conn(struct fuse_conn *fc);
894
895/**
896 * Remove connection from control filesystem
897 */
898void fuse_ctl_remove_conn(struct fuse_conn *fc);
Timo Savolaa5bfffac2007-04-08 16:04:00 -0700899
900/**
901 * Is file type valid?
902 */
903int fuse_valid_type(int m);
Miklos Szeredie57ac682007-10-18 03:06:58 -0700904
905/**
Anatol Pomozovc2132c12013-01-14 22:30:00 -0800906 * Is current process allowed to perform filesystem operation?
Miklos Szeredie57ac682007-10-18 03:06:58 -0700907 */
Anatol Pomozovc2132c12013-01-14 22:30:00 -0800908int fuse_allow_current_process(struct fuse_conn *fc);
Miklos Szeredif3332112007-10-18 03:07:04 -0700909
910u64 fuse_lock_owner_id(struct fuse_conn *fc, fl_owner_t id);
Miklos Szeredibcb4be82007-11-28 16:21:59 -0800911
Seth Forshee703c7362016-08-29 08:46:36 -0500912void fuse_update_ctime(struct inode *inode);
913
Miklos Szeredibcb4be82007-11-28 16:21:59 -0800914int fuse_update_attributes(struct inode *inode, struct kstat *stat,
915 struct file *file, bool *refreshed);
Miklos Szeredi3be5a522008-04-30 00:54:41 -0700916
917void fuse_flush_writepages(struct inode *inode);
918
919void fuse_set_nowrite(struct inode *inode);
920void fuse_release_nowrite(struct inode *inode);
Miklos Szeredi5c5c5e52008-04-30 00:54:43 -0700921
922u64 fuse_get_attr_version(struct fuse_conn *fc);
Tejun Heo29d434b2008-10-16 16:08:57 +0200923
John Muir3b463ae2009-05-31 11:13:57 -0400924/**
925 * File-system tells the kernel to invalidate cache for the given node id.
926 */
927int fuse_reverse_inval_inode(struct super_block *sb, u64 nodeid,
928 loff_t offset, loff_t len);
929
930/**
931 * File-system tells the kernel to invalidate parent attributes and
932 * the dentry matching parent/name.
John Muir451d0f52011-12-06 21:50:06 +0100933 *
934 * If the child_nodeid is non-zero and:
935 * - matches the inode number for the dentry matching parent/name,
936 * - is not a mount point
937 * - is a file or oan empty directory
938 * then the dentry is unhashed (d_delete()).
John Muir3b463ae2009-05-31 11:13:57 -0400939 */
940int fuse_reverse_inval_entry(struct super_block *sb, u64 parent_nodeid,
John Muir451d0f52011-12-06 21:50:06 +0100941 u64 child_nodeid, struct qstr *name);
John Muir3b463ae2009-05-31 11:13:57 -0400942
Tejun Heo08cbf542009-04-14 10:54:53 +0900943int fuse_do_open(struct fuse_conn *fc, u64 nodeid, struct file *file,
944 bool isdir);
Pavel Emelyanovea8cd332013-10-10 17:12:05 +0400945
946/**
947 * fuse_direct_io() flags
948 */
949
950/** If set, it is WRITE; otherwise - READ */
951#define FUSE_DIO_WRITE (1 << 0)
952
953/** CUSE pass fuse_direct_io() a file which f_mapping->host is not from FUSE */
954#define FUSE_DIO_CUSE (1 << 1)
955
Al Virod22a9432014-03-16 15:50:47 -0400956ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter,
957 loff_t *ppos, int flags);
Tejun Heo08cbf542009-04-14 10:54:53 +0900958long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg,
959 unsigned int flags);
Miklos Szeredib18da0c2011-12-13 11:58:49 +0100960long fuse_ioctl_common(struct file *file, unsigned int cmd,
961 unsigned long arg, unsigned int flags);
Tejun Heo08cbf542009-04-14 10:54:53 +0900962unsigned fuse_file_poll(struct file *file, poll_table *wait);
963int fuse_dev_release(struct inode *inode, struct file *file);
964
Maxim Patlasovb0aa7602013-12-26 19:51:11 +0400965bool fuse_write_update_size(struct inode *inode, loff_t pos);
966
Maxim Patlasovab9e13f2014-04-28 14:19:24 +0200967int fuse_flush_times(struct inode *inode, struct fuse_file *ff);
Miklos Szeredi1e18bda2014-04-28 14:19:23 +0200968int fuse_write_inode(struct inode *inode, struct writeback_control *wbc);
Miklos Szeredia1d75f22010-07-12 14:41:40 +0200969
Maxim Patlasovefb9fa92012-12-18 14:05:08 +0400970int fuse_do_setattr(struct inode *inode, struct iattr *attr,
971 struct file *file);
972
Miklos Szeredi9759bd512015-01-06 10:45:35 +0100973void fuse_set_initialized(struct fuse_conn *fc);
974
Miklos Szeredi5c672ab2016-06-30 13:10:49 +0200975void fuse_unlock_inode(struct inode *inode);
976void fuse_lock_inode(struct inode *inode);
977
Seth Forshee60bcc882016-08-29 08:46:37 -0500978int fuse_setxattr(struct inode *inode, const char *name, const void *value,
979 size_t size, int flags);
980ssize_t fuse_getxattr(struct inode *inode, const char *name, void *value,
981 size_t size);
Seth Forshee703c7362016-08-29 08:46:36 -0500982ssize_t fuse_listxattr(struct dentry *entry, char *list, size_t size);
Seth Forshee60bcc882016-08-29 08:46:37 -0500983int fuse_removexattr(struct inode *inode, const char *name);
Seth Forshee703c7362016-08-29 08:46:36 -0500984extern const struct xattr_handler *fuse_xattr_handlers[];
Seth Forshee60bcc882016-08-29 08:46:37 -0500985extern const struct xattr_handler *fuse_acl_xattr_handlers[];
986
987struct posix_acl;
988struct posix_acl *fuse_get_acl(struct inode *inode, int type);
989int fuse_set_acl(struct inode *inode, struct posix_acl *acl, int type);
Seth Forshee703c7362016-08-29 08:46:36 -0500990
Tejun Heo29d434b2008-10-16 16:08:57 +0200991#endif /* _FS_FUSE_I_H */