]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - fs/fuse/fuse_i.h
fuse: Add posix ACL support
[mirror_ubuntu-zesty-kernel.git] / fs / fuse / fuse_i.h
1 /*
2 FUSE: Filesystem in Userspace
3 Copyright (C) 2001-2008 Miklos Szeredi <miklos@szeredi.hu>
4
5 This program can be distributed under the terms of the GNU GPL.
6 See the file COPYING.
7 */
8
9 #ifndef _FS_FUSE_I_H
10 #define _FS_FUSE_I_H
11
12 #include <linux/fuse.h>
13 #include <linux/fs.h>
14 #include <linux/mount.h>
15 #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>
20 #include <linux/mutex.h>
21 #include <linux/rwsem.h>
22 #include <linux/rbtree.h>
23 #include <linux/poll.h>
24 #include <linux/workqueue.h>
25 #include <linux/kref.h>
26 #include <linux/xattr.h>
27
28 /** Max number of pages that can be used in a single read request */
29 #define FUSE_MAX_PAGES_PER_REQ 32
30
31 /** Bias for fi->writectr, meaning new writepages must not be sent */
32 #define FUSE_NOWRITE INT_MIN
33
34 /** It could be as large as PATH_MAX, but would that have any uses? */
35 #define FUSE_NAME_MAX 1024
36
37 /** Number of dentries for each connection in the control filesystem */
38 #define FUSE_CTL_NUM_DENTRIES 5
39
40 /** 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
49 /** Number of page pointers embedded in fuse_req */
50 #define FUSE_REQ_INLINE_PAGES 1
51
52 /** List of active connections */
53 extern struct list_head fuse_conn_list;
54
55 /** Global mutex protecting fuse_conn_list and the control filesystem */
56 extern struct mutex fuse_mutex;
57
58 /** Module parameters */
59 extern unsigned max_user_bgreq;
60 extern unsigned max_user_congthresh;
61
62 /* One forget request */
63 struct fuse_forget_link {
64 struct fuse_forget_one forget_one;
65 struct fuse_forget_link *next;
66 };
67
68 /** FUSE inode */
69 struct 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
77 /** Number of lookups on this inode */
78 u64 nlookup;
79
80 /** The request used for sending the FORGET message */
81 struct fuse_forget_link *forget;
82
83 /** Time in jiffies until the file attributes are valid */
84 u64 i_time;
85
86 /** The sticky bit in inode->i_mode may have been removed, so
87 preserve the original mode */
88 umode_t orig_i_mode;
89
90 /** 64 bit inode number */
91 u64 orig_ino;
92
93 /** Version of last attribute change */
94 u64 attr_version;
95
96 /** Files usable in writepage. Protected by fc->lock */
97 struct list_head write_files;
98
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;
111
112 /** Miscellaneous bits describing inode state */
113 unsigned long state;
114
115 /** Lock for serializing lookup and readdir for back compatibility*/
116 struct mutex mutex;
117 };
118
119 /** FUSE inode state bits */
120 enum {
121 /** Advise readdirplus */
122 FUSE_I_ADVISE_RDPLUS,
123 /** Initialized with readdirplus */
124 FUSE_I_INIT_RDPLUS,
125 /** An operation changing file size is in progress */
126 FUSE_I_SIZE_UNSTABLE,
127 };
128
129 struct fuse_conn;
130
131 /** FUSE specific file data */
132 struct fuse_file {
133 /** Fuse connection for this file */
134 struct fuse_conn *fc;
135
136 /** Request reserved for flush and release */
137 struct fuse_req *reserved_req;
138
139 /** Kernel file handle guaranteed to be unique */
140 u64 kh;
141
142 /** File handle used by userspace */
143 u64 fh;
144
145 /** Node id of this file */
146 u64 nodeid;
147
148 /** Refcount */
149 atomic_t count;
150
151 /** FOPEN_* flags returned by open */
152 u32 open_flags;
153
154 /** Entry on inode's write_files list */
155 struct list_head write_entry;
156
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;
162
163 /** Has flock been performed on this file? */
164 bool flock:1;
165 };
166
167 /** One input argument of a request */
168 struct fuse_in_arg {
169 unsigned size;
170 const void *value;
171 };
172
173 /** The request input */
174 struct 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 */
189 struct fuse_arg {
190 unsigned size;
191 void *value;
192 };
193
194 /** The request output */
195 struct fuse_out {
196 /** Header returned from userspace */
197 struct fuse_out_header h;
198
199 /*
200 * The following bitfields are not changed during the request
201 * processing
202 */
203
204 /** 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
214 /** Pages may be replaced with new ones */
215 unsigned page_replace:1;
216
217 /** Number or arguments */
218 unsigned numargs;
219
220 /** Array of arguments */
221 struct fuse_arg args[2];
222 };
223
224 /** FUSE page descriptor */
225 struct fuse_page_desc {
226 unsigned int length;
227 unsigned int offset;
228 };
229
230 struct 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
249 /** The request IO state (for asynchronous processing) */
250 struct fuse_io_priv {
251 struct kref refcnt;
252 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;
262 struct completion *done;
263 bool blocking;
264 };
265
266 #define FUSE_IO_PRIV_SYNC(f) \
267 { \
268 .refcnt = { ATOMIC_INIT(1) }, \
269 .async = 0, \
270 .file = f, \
271 }
272
273 /**
274 * 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
283 * 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
286 * FR_PRIVATE: request is on private list
287 */
288 enum fuse_req_flag {
289 FR_ISREPLY,
290 FR_FORCE,
291 FR_BACKGROUND,
292 FR_WAITING,
293 FR_ABORTED,
294 FR_INTERRUPTED,
295 FR_LOCKED,
296 FR_PENDING,
297 FR_SENT,
298 FR_FINISHED,
299 FR_PRIVATE,
300 };
301
302 /**
303 * A request to the client
304 *
305 * .waitq.lock protects the following fields:
306 * - FR_ABORTED
307 * - FR_LOCKED (may also be modified under fc->lock, tested under both)
308 */
309 struct fuse_req {
310 /** This can be on either pending processing or io lists in
311 fuse_conn */
312 struct list_head list;
313
314 /** Entry on the interrupts list */
315 struct list_head intr_entry;
316
317 /** refcount */
318 atomic_t count;
319
320 /** Unique ID for the interrupt request */
321 u64 intr_unique;
322
323 /* Request flags, updated with test/set/clear_bit() */
324 unsigned long flags;
325
326 /** 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 {
337 struct {
338 struct fuse_release_in in;
339 struct inode *inode;
340 } release;
341 struct fuse_init_in init_in;
342 struct fuse_init_out init_out;
343 struct cuse_init_in cuse_init_in;
344 struct {
345 struct fuse_read_in in;
346 u64 attr_ver;
347 } read;
348 struct {
349 struct fuse_write_in in;
350 struct fuse_write_out out;
351 struct fuse_req *next;
352 } write;
353 struct fuse_notify_retrieve_in retrieve_in;
354 } misc;
355
356 /** page vector */
357 struct page **pages;
358
359 /** page-descriptor vector */
360 struct fuse_page_desc *page_descs;
361
362 /** size of the 'pages' array */
363 unsigned max_pages;
364
365 /** inline page vector */
366 struct page *inline_pages[FUSE_REQ_INLINE_PAGES];
367
368 /** inline page-descriptor vector */
369 struct fuse_page_desc inline_page_descs[FUSE_REQ_INLINE_PAGES];
370
371 /** number of pages in vector */
372 unsigned num_pages;
373
374 /** File used in the request (or NULL) */
375 struct fuse_file *ff;
376
377 /** Inode used in the request or NULL */
378 struct inode *inode;
379
380 /** AIO control block */
381 struct fuse_io_priv *io;
382
383 /** Link on fi->writepages */
384 struct list_head writepages_entry;
385
386 /** Request completion callback */
387 void (*end)(struct fuse_conn *, struct fuse_req *);
388
389 /** Request is stolen from fuse_file->reserved_req */
390 struct file *stolen_file;
391 };
392
393 struct fuse_iqueue {
394 /** Connection established */
395 unsigned connected;
396
397 /** 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
420 struct fuse_pqueue {
421 /** Connection established */
422 unsigned connected;
423
424 /** Lock protecting accessess to members of this structure */
425 spinlock_t lock;
426
427 /** 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
434 /**
435 * Fuse device instance
436 */
437 struct fuse_dev {
438 /** Fuse connection for this device */
439 struct fuse_conn *fc;
440
441 /** Processing queue */
442 struct fuse_pqueue pq;
443
444 /** list entry on fc->devices */
445 struct list_head entry;
446 };
447
448 /**
449 * 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 */
455 struct fuse_conn {
456 /** Lock protecting accessess to members of this structure */
457 spinlock_t lock;
458
459 /** Refcount */
460 atomic_t count;
461
462 /** Number of fuse_dev's */
463 atomic_t dev_count;
464
465 struct rcu_head rcu;
466
467 /** The user id for this mount */
468 kuid_t user_id;
469
470 /** The group id for this mount */
471 kgid_t group_id;
472
473 /** The fuse mount flags for this mount */
474 unsigned flags;
475
476 /** Maximum read size */
477 unsigned max_read;
478
479 /** Maximum write size */
480 unsigned max_write;
481
482 /** Input queue */
483 struct fuse_iqueue iq;
484
485 /** The next unique kernel file handle */
486 u64 khctr;
487
488 /** rbtree of fuse_files waiting for poll events indexed by ph */
489 struct rb_root polled_files;
490
491 /** 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
497 /** Number of requests currently in the background */
498 unsigned num_background;
499
500 /** 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
506 /** 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
510 /** 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
518 /** waitq for reserved requests */
519 wait_queue_head_t reserved_req_waitq;
520
521 /** Connection established, cleared on umount, connection
522 abort and device release */
523 unsigned connected;
524
525 /** 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 */
528 unsigned conn_error:1;
529
530 /** Connection successful. Only set in INIT */
531 unsigned conn_init:1;
532
533 /** Do readpages asynchronously? Only set in INIT */
534 unsigned async_read:1;
535
536 /** Do not send separate SETATTR request before open(O_TRUNC) */
537 unsigned atomic_o_trunc:1;
538
539 /** Filesystem supports NFS exporting. Only set in INIT */
540 unsigned export_support:1;
541
542 /** Set if bdi is valid */
543 unsigned bdi_initialized:1;
544
545 /** write-back cache policy (default is write-through) */
546 unsigned writeback_cache:1;
547
548 /** allow parallel lookups and readdir (default is serialized) */
549 unsigned parallel_dirops:1;
550
551 /** handle fs handles killing suid/sgid/cap on write/chown/trunc */
552 unsigned handle_killpriv:1;
553
554 /*
555 * The following bitfields are only for optimization purposes
556 * and hence races in setting them will not cause malfunction
557 */
558
559 /** Is open/release not implemented by fs? */
560 unsigned no_open:1;
561
562 /** Is fsync not implemented by fs? */
563 unsigned no_fsync:1;
564
565 /** Is fsyncdir not implemented by fs? */
566 unsigned no_fsyncdir:1;
567
568 /** Is flush not implemented by fs? */
569 unsigned no_flush:1;
570
571 /** Is setxattr not implemented by fs? */
572 unsigned no_setxattr:1;
573
574 /** Is getxattr not implemented by fs? */
575 unsigned no_getxattr:1;
576
577 /** Is listxattr not implemented by fs? */
578 unsigned no_listxattr:1;
579
580 /** Is removexattr not implemented by fs? */
581 unsigned no_removexattr:1;
582
583 /** Are posix file locking primitives not implemented by fs? */
584 unsigned no_lock:1;
585
586 /** Is access not implemented by fs? */
587 unsigned no_access:1;
588
589 /** Is create not implemented by fs? */
590 unsigned no_create:1;
591
592 /** Is interrupt not implemented by fs? */
593 unsigned no_interrupt:1;
594
595 /** Is bmap not implemented by fs? */
596 unsigned no_bmap:1;
597
598 /** Is poll not implemented by fs? */
599 unsigned no_poll:1;
600
601 /** Do multi-page cached writes */
602 unsigned big_writes:1;
603
604 /** Don't apply umask to creation modes */
605 unsigned dont_mask:1;
606
607 /** Are BSD file locking primitives not implemented by fs? */
608 unsigned no_flock:1;
609
610 /** Is fallocate not implemented by fs? */
611 unsigned no_fallocate:1;
612
613 /** Is rename with flags implemented by fs? */
614 unsigned no_rename2:1;
615
616 /** Use enhanced/automatic page cache invalidation. */
617 unsigned auto_inval_data:1;
618
619 /** Does the filesystem support readdirplus? */
620 unsigned do_readdirplus:1;
621
622 /** Does the filesystem want adaptive readdirplus? */
623 unsigned readdirplus_auto:1;
624
625 /** Does the filesystem support asynchronous direct-IO submission? */
626 unsigned async_dio:1;
627
628 /** Is lseek not implemented by fs? */
629 unsigned no_lseek:1;
630
631 /** Does the filesystem support posix acls? */
632 unsigned posix_acl:1;
633
634 /** The number of requests waiting for completion */
635 atomic_t num_waiting;
636
637 /** Negotiated minor version */
638 unsigned minor;
639
640 /** Backing dev info */
641 struct backing_dev_info bdi;
642
643 /** Entry on the fuse_conn_list */
644 struct list_head entry;
645
646 /** Device ID from super block */
647 dev_t dev;
648
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;
654
655 /** Key for lock owner ID scrambling */
656 u32 scramble_key[4];
657
658 /** Reserved request for the DESTROY message */
659 struct fuse_req *destroy_req;
660
661 /** Version counter for attribute changes */
662 u64 attr_version;
663
664 /** Called on final put */
665 void (*release)(struct fuse_conn *);
666
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;
672
673 /** List of device instances belonging to this connection */
674 struct list_head devices;
675 };
676
677 static inline struct fuse_conn *get_fuse_conn_super(struct super_block *sb)
678 {
679 return sb->s_fs_info;
680 }
681
682 static inline struct fuse_conn *get_fuse_conn(struct inode *inode)
683 {
684 return get_fuse_conn_super(inode->i_sb);
685 }
686
687 static inline struct fuse_inode *get_fuse_inode(struct inode *inode)
688 {
689 return container_of(inode, struct fuse_inode, inode);
690 }
691
692 static inline u64 get_node_id(struct inode *inode)
693 {
694 return get_fuse_inode(inode)->nodeid;
695 }
696
697 /** Device operations */
698 extern const struct file_operations fuse_dev_operations;
699
700 extern const struct dentry_operations fuse_dentry_operations;
701
702 /**
703 * Inode to nodeid comparison.
704 */
705 int fuse_inode_eq(struct inode *inode, void *_nodeidp);
706
707 /**
708 * Get a filled in inode
709 */
710 struct inode *fuse_iget(struct super_block *sb, u64 nodeid,
711 int generation, struct fuse_attr *attr,
712 u64 attr_valid, u64 attr_version);
713
714 int fuse_lookup_name(struct super_block *sb, u64 nodeid, const struct qstr *name,
715 struct fuse_entry_out *outarg, struct inode **inode);
716
717 /**
718 * Send FORGET command
719 */
720 void fuse_queue_forget(struct fuse_conn *fc, struct fuse_forget_link *forget,
721 u64 nodeid, u64 nlookup);
722
723 struct fuse_forget_link *fuse_alloc_forget(void);
724
725 /* Used by READDIRPLUS */
726 void fuse_force_forget(struct file *file, u64 nodeid);
727
728 /**
729 * Initialize READ or READDIR request
730 */
731 void fuse_read_fill(struct fuse_req *req, struct file *file,
732 loff_t pos, size_t count, int opcode);
733
734 /**
735 * Send OPEN or OPENDIR request
736 */
737 int fuse_open_common(struct inode *inode, struct file *file, bool isdir);
738
739 struct fuse_file *fuse_file_alloc(struct fuse_conn *fc);
740 struct fuse_file *fuse_file_get(struct fuse_file *ff);
741 void fuse_file_free(struct fuse_file *ff);
742 void fuse_finish_open(struct inode *inode, struct file *file);
743
744 void fuse_sync_release(struct fuse_file *ff, int flags);
745
746 /**
747 * Send RELEASE or RELEASEDIR request
748 */
749 void fuse_release_common(struct file *file, int opcode);
750
751 /**
752 * Send FSYNC or FSYNCDIR request
753 */
754 int fuse_fsync_common(struct file *file, loff_t start, loff_t end,
755 int datasync, int isdir);
756
757 /**
758 * Notify poll wakeup
759 */
760 int fuse_notify_poll_wakeup(struct fuse_conn *fc,
761 struct fuse_notify_poll_wakeup_out *outarg);
762
763 /**
764 * Initialize file operations on a regular file
765 */
766 void fuse_init_file_inode(struct inode *inode);
767
768 /**
769 * Initialize inode operations on regular files and special files
770 */
771 void fuse_init_common(struct inode *inode);
772
773 /**
774 * Initialize inode and file operations on a directory
775 */
776 void fuse_init_dir(struct inode *inode);
777
778 /**
779 * Initialize inode operations on a symlink
780 */
781 void fuse_init_symlink(struct inode *inode);
782
783 /**
784 * Change attributes of an inode
785 */
786 void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr,
787 u64 attr_valid, u64 attr_version);
788
789 void fuse_change_attributes_common(struct inode *inode, struct fuse_attr *attr,
790 u64 attr_valid);
791
792 /**
793 * Initialize the client device
794 */
795 int fuse_dev_init(void);
796
797 /**
798 * Cleanup the client device
799 */
800 void fuse_dev_cleanup(void);
801
802 int fuse_ctl_init(void);
803 void __exit fuse_ctl_cleanup(void);
804
805 /**
806 * Allocate a request
807 */
808 struct fuse_req *fuse_request_alloc(unsigned npages);
809
810 struct fuse_req *fuse_request_alloc_nofs(unsigned npages);
811
812 /**
813 * Free a request
814 */
815 void fuse_request_free(struct fuse_req *req);
816
817 /**
818 * Get a request, may fail with -ENOMEM,
819 * caller should specify # elements in req->pages[] explicitly
820 */
821 struct fuse_req *fuse_get_req(struct fuse_conn *fc, unsigned npages);
822 struct fuse_req *fuse_get_req_for_background(struct fuse_conn *fc,
823 unsigned npages);
824
825 /*
826 * Increment reference count on request
827 */
828 void __fuse_get_request(struct fuse_req *req);
829
830 /**
831 * Gets a requests for a file operation, always succeeds
832 */
833 struct fuse_req *fuse_get_req_nofail_nopages(struct fuse_conn *fc,
834 struct file *file);
835
836 /**
837 * Decrement reference count of a request. If count goes to zero free
838 * the request.
839 */
840 void fuse_put_request(struct fuse_conn *fc, struct fuse_req *req);
841
842 /**
843 * Send a request (synchronous)
844 */
845 void fuse_request_send(struct fuse_conn *fc, struct fuse_req *req);
846
847 /**
848 * Simple request sending that does request allocation and freeing
849 */
850 ssize_t fuse_simple_request(struct fuse_conn *fc, struct fuse_args *args);
851
852 /**
853 * Send a request in the background
854 */
855 void fuse_request_send_background(struct fuse_conn *fc, struct fuse_req *req);
856
857 void fuse_request_send_background_locked(struct fuse_conn *fc,
858 struct fuse_req *req);
859
860 /* Abort all requests */
861 void fuse_abort_conn(struct fuse_conn *fc);
862
863 /**
864 * Invalidate inode attributes
865 */
866 void fuse_invalidate_attr(struct inode *inode);
867
868 void fuse_invalidate_entry_cache(struct dentry *entry);
869
870 void fuse_invalidate_atime(struct inode *inode);
871
872 /**
873 * Acquire reference to fuse_conn
874 */
875 struct fuse_conn *fuse_conn_get(struct fuse_conn *fc);
876
877 /**
878 * Initialize fuse_conn
879 */
880 void fuse_conn_init(struct fuse_conn *fc);
881
882 /**
883 * Release reference to fuse_conn
884 */
885 void fuse_conn_put(struct fuse_conn *fc);
886
887 struct fuse_dev *fuse_dev_alloc(struct fuse_conn *fc);
888 void fuse_dev_free(struct fuse_dev *fud);
889
890 /**
891 * Add connection to control filesystem
892 */
893 int fuse_ctl_add_conn(struct fuse_conn *fc);
894
895 /**
896 * Remove connection from control filesystem
897 */
898 void fuse_ctl_remove_conn(struct fuse_conn *fc);
899
900 /**
901 * Is file type valid?
902 */
903 int fuse_valid_type(int m);
904
905 /**
906 * Is current process allowed to perform filesystem operation?
907 */
908 int fuse_allow_current_process(struct fuse_conn *fc);
909
910 u64 fuse_lock_owner_id(struct fuse_conn *fc, fl_owner_t id);
911
912 void fuse_update_ctime(struct inode *inode);
913
914 int fuse_update_attributes(struct inode *inode, struct kstat *stat,
915 struct file *file, bool *refreshed);
916
917 void fuse_flush_writepages(struct inode *inode);
918
919 void fuse_set_nowrite(struct inode *inode);
920 void fuse_release_nowrite(struct inode *inode);
921
922 u64 fuse_get_attr_version(struct fuse_conn *fc);
923
924 /**
925 * File-system tells the kernel to invalidate cache for the given node id.
926 */
927 int 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.
933 *
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()).
939 */
940 int fuse_reverse_inval_entry(struct super_block *sb, u64 parent_nodeid,
941 u64 child_nodeid, struct qstr *name);
942
943 int fuse_do_open(struct fuse_conn *fc, u64 nodeid, struct file *file,
944 bool isdir);
945
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
956 ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter,
957 loff_t *ppos, int flags);
958 long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg,
959 unsigned int flags);
960 long fuse_ioctl_common(struct file *file, unsigned int cmd,
961 unsigned long arg, unsigned int flags);
962 unsigned fuse_file_poll(struct file *file, poll_table *wait);
963 int fuse_dev_release(struct inode *inode, struct file *file);
964
965 bool fuse_write_update_size(struct inode *inode, loff_t pos);
966
967 int fuse_flush_times(struct inode *inode, struct fuse_file *ff);
968 int fuse_write_inode(struct inode *inode, struct writeback_control *wbc);
969
970 int fuse_do_setattr(struct inode *inode, struct iattr *attr,
971 struct file *file);
972
973 void fuse_set_initialized(struct fuse_conn *fc);
974
975 void fuse_unlock_inode(struct inode *inode);
976 void fuse_lock_inode(struct inode *inode);
977
978 int fuse_setxattr(struct inode *inode, const char *name, const void *value,
979 size_t size, int flags);
980 ssize_t fuse_getxattr(struct inode *inode, const char *name, void *value,
981 size_t size);
982 ssize_t fuse_listxattr(struct dentry *entry, char *list, size_t size);
983 int fuse_removexattr(struct inode *inode, const char *name);
984 extern const struct xattr_handler *fuse_xattr_handlers[];
985 extern const struct xattr_handler *fuse_acl_xattr_handlers[];
986
987 struct posix_acl;
988 struct posix_acl *fuse_get_acl(struct inode *inode, int type);
989 int fuse_set_acl(struct inode *inode, struct posix_acl *acl, int type);
990
991 #endif /* _FS_FUSE_I_H */