xref: /aosp_15_r20/external/libfuse/include/fuse_lowlevel.h (revision 9e5649576b786774a32d7b0252c9cd8c6538fa49)
1*9e564957SAndroid Build Coastguard Worker /*
2*9e564957SAndroid Build Coastguard Worker   FUSE: Filesystem in Userspace
3*9e564957SAndroid Build Coastguard Worker   Copyright (C) 2001-2007  Miklos Szeredi <[email protected]>
4*9e564957SAndroid Build Coastguard Worker 
5*9e564957SAndroid Build Coastguard Worker   This program can be distributed under the terms of the GNU LGPLv2.
6*9e564957SAndroid Build Coastguard Worker   See the file COPYING.LIB.
7*9e564957SAndroid Build Coastguard Worker */
8*9e564957SAndroid Build Coastguard Worker 
9*9e564957SAndroid Build Coastguard Worker #ifndef FUSE_LOWLEVEL_H_
10*9e564957SAndroid Build Coastguard Worker #define FUSE_LOWLEVEL_H_
11*9e564957SAndroid Build Coastguard Worker 
12*9e564957SAndroid Build Coastguard Worker /** @file
13*9e564957SAndroid Build Coastguard Worker  *
14*9e564957SAndroid Build Coastguard Worker  * Low level API
15*9e564957SAndroid Build Coastguard Worker  *
16*9e564957SAndroid Build Coastguard Worker  * IMPORTANT: you should define FUSE_USE_VERSION before including this
17*9e564957SAndroid Build Coastguard Worker  * header.  To use the newest API define it to 35 (recommended for any
18*9e564957SAndroid Build Coastguard Worker  * new application).
19*9e564957SAndroid Build Coastguard Worker  */
20*9e564957SAndroid Build Coastguard Worker 
21*9e564957SAndroid Build Coastguard Worker #ifndef FUSE_USE_VERSION
22*9e564957SAndroid Build Coastguard Worker #error FUSE_USE_VERSION not defined
23*9e564957SAndroid Build Coastguard Worker #endif
24*9e564957SAndroid Build Coastguard Worker 
25*9e564957SAndroid Build Coastguard Worker #include "fuse_common.h"
26*9e564957SAndroid Build Coastguard Worker 
27*9e564957SAndroid Build Coastguard Worker #include <utime.h>
28*9e564957SAndroid Build Coastguard Worker #include <fcntl.h>
29*9e564957SAndroid Build Coastguard Worker #include <sys/types.h>
30*9e564957SAndroid Build Coastguard Worker #include <sys/stat.h>
31*9e564957SAndroid Build Coastguard Worker #include <sys/statvfs.h>
32*9e564957SAndroid Build Coastguard Worker #include <sys/uio.h>
33*9e564957SAndroid Build Coastguard Worker 
34*9e564957SAndroid Build Coastguard Worker #ifdef __cplusplus
35*9e564957SAndroid Build Coastguard Worker extern "C" {
36*9e564957SAndroid Build Coastguard Worker #endif
37*9e564957SAndroid Build Coastguard Worker 
38*9e564957SAndroid Build Coastguard Worker /* ----------------------------------------------------------- *
39*9e564957SAndroid Build Coastguard Worker  * Miscellaneous definitions				       *
40*9e564957SAndroid Build Coastguard Worker  * ----------------------------------------------------------- */
41*9e564957SAndroid Build Coastguard Worker 
42*9e564957SAndroid Build Coastguard Worker /** The node ID of the root inode */
43*9e564957SAndroid Build Coastguard Worker #define FUSE_ROOT_ID 1
44*9e564957SAndroid Build Coastguard Worker 
45*9e564957SAndroid Build Coastguard Worker /** Inode number type */
46*9e564957SAndroid Build Coastguard Worker typedef uint64_t fuse_ino_t;
47*9e564957SAndroid Build Coastguard Worker 
48*9e564957SAndroid Build Coastguard Worker /** Request pointer type */
49*9e564957SAndroid Build Coastguard Worker typedef struct fuse_req *fuse_req_t;
50*9e564957SAndroid Build Coastguard Worker 
51*9e564957SAndroid Build Coastguard Worker /**
52*9e564957SAndroid Build Coastguard Worker  * Session
53*9e564957SAndroid Build Coastguard Worker  *
54*9e564957SAndroid Build Coastguard Worker  * This provides hooks for processing requests, and exiting
55*9e564957SAndroid Build Coastguard Worker  */
56*9e564957SAndroid Build Coastguard Worker struct fuse_session;
57*9e564957SAndroid Build Coastguard Worker 
58*9e564957SAndroid Build Coastguard Worker /** Directory entry parameters supplied to fuse_reply_entry() */
59*9e564957SAndroid Build Coastguard Worker struct fuse_entry_param {
60*9e564957SAndroid Build Coastguard Worker 	/** Unique inode number
61*9e564957SAndroid Build Coastguard Worker 	 *
62*9e564957SAndroid Build Coastguard Worker 	 * In lookup, zero means negative entry (from version 2.5)
63*9e564957SAndroid Build Coastguard Worker 	 * Returning ENOENT also means negative entry, but by setting zero
64*9e564957SAndroid Build Coastguard Worker 	 * ino the kernel may cache negative entries for entry_timeout
65*9e564957SAndroid Build Coastguard Worker 	 * seconds.
66*9e564957SAndroid Build Coastguard Worker 	 */
67*9e564957SAndroid Build Coastguard Worker 	fuse_ino_t ino;
68*9e564957SAndroid Build Coastguard Worker 
69*9e564957SAndroid Build Coastguard Worker 	/** Generation number for this entry.
70*9e564957SAndroid Build Coastguard Worker 	 *
71*9e564957SAndroid Build Coastguard Worker 	 * If the file system will be exported over NFS, the
72*9e564957SAndroid Build Coastguard Worker 	 * ino/generation pairs need to be unique over the file
73*9e564957SAndroid Build Coastguard Worker 	 * system's lifetime (rather than just the mount time). So if
74*9e564957SAndroid Build Coastguard Worker 	 * the file system reuses an inode after it has been deleted,
75*9e564957SAndroid Build Coastguard Worker 	 * it must assign a new, previously unused generation number
76*9e564957SAndroid Build Coastguard Worker 	 * to the inode at the same time.
77*9e564957SAndroid Build Coastguard Worker 	 *
78*9e564957SAndroid Build Coastguard Worker 	 */
79*9e564957SAndroid Build Coastguard Worker 	uint64_t generation;
80*9e564957SAndroid Build Coastguard Worker 
81*9e564957SAndroid Build Coastguard Worker 	/** Inode attributes.
82*9e564957SAndroid Build Coastguard Worker 	 *
83*9e564957SAndroid Build Coastguard Worker 	 * Even if attr_timeout == 0, attr must be correct. For example,
84*9e564957SAndroid Build Coastguard Worker 	 * for open(), FUSE uses attr.st_size from lookup() to determine
85*9e564957SAndroid Build Coastguard Worker 	 * how many bytes to request. If this value is not correct,
86*9e564957SAndroid Build Coastguard Worker 	 * incorrect data will be returned.
87*9e564957SAndroid Build Coastguard Worker 	 */
88*9e564957SAndroid Build Coastguard Worker 	struct stat attr;
89*9e564957SAndroid Build Coastguard Worker 
90*9e564957SAndroid Build Coastguard Worker 	/** Validity timeout (in seconds) for inode attributes. If
91*9e564957SAndroid Build Coastguard Worker 	    attributes only change as a result of requests that come
92*9e564957SAndroid Build Coastguard Worker 	    through the kernel, this should be set to a very large
93*9e564957SAndroid Build Coastguard Worker 	    value. */
94*9e564957SAndroid Build Coastguard Worker 	double attr_timeout;
95*9e564957SAndroid Build Coastguard Worker 
96*9e564957SAndroid Build Coastguard Worker 	/** Validity timeout (in seconds) for the name. If directory
97*9e564957SAndroid Build Coastguard Worker 	    entries are changed/deleted only as a result of requests
98*9e564957SAndroid Build Coastguard Worker 	    that come through the kernel, this should be set to a very
99*9e564957SAndroid Build Coastguard Worker 	    large value. */
100*9e564957SAndroid Build Coastguard Worker 	double entry_timeout;
101*9e564957SAndroid Build Coastguard Worker         uint64_t        backing_action;
102*9e564957SAndroid Build Coastguard Worker         uint64_t        backing_fd;
103*9e564957SAndroid Build Coastguard Worker         uint64_t        bpf_action;
104*9e564957SAndroid Build Coastguard Worker         uint64_t        bpf_fd;
105*9e564957SAndroid Build Coastguard Worker };
106*9e564957SAndroid Build Coastguard Worker 
107*9e564957SAndroid Build Coastguard Worker /**
108*9e564957SAndroid Build Coastguard Worker  * Additional context associated with requests.
109*9e564957SAndroid Build Coastguard Worker  *
110*9e564957SAndroid Build Coastguard Worker  * Note that the reported client uid, gid and pid may be zero in some
111*9e564957SAndroid Build Coastguard Worker  * situations. For example, if the FUSE file system is running in a
112*9e564957SAndroid Build Coastguard Worker  * PID or user namespace but then accessed from outside the namespace,
113*9e564957SAndroid Build Coastguard Worker  * there is no valid uid/pid/gid that could be reported.
114*9e564957SAndroid Build Coastguard Worker  */
115*9e564957SAndroid Build Coastguard Worker struct fuse_ctx {
116*9e564957SAndroid Build Coastguard Worker 	/** User ID of the calling process */
117*9e564957SAndroid Build Coastguard Worker 	uid_t uid;
118*9e564957SAndroid Build Coastguard Worker 
119*9e564957SAndroid Build Coastguard Worker 	/** Group ID of the calling process */
120*9e564957SAndroid Build Coastguard Worker 	gid_t gid;
121*9e564957SAndroid Build Coastguard Worker 
122*9e564957SAndroid Build Coastguard Worker 	/** Thread ID of the calling process */
123*9e564957SAndroid Build Coastguard Worker 	pid_t pid;
124*9e564957SAndroid Build Coastguard Worker 
125*9e564957SAndroid Build Coastguard Worker 	/** Umask of the calling process */
126*9e564957SAndroid Build Coastguard Worker 	mode_t umask;
127*9e564957SAndroid Build Coastguard Worker };
128*9e564957SAndroid Build Coastguard Worker 
129*9e564957SAndroid Build Coastguard Worker struct fuse_forget_data {
130*9e564957SAndroid Build Coastguard Worker 	fuse_ino_t ino;
131*9e564957SAndroid Build Coastguard Worker 	uint64_t nlookup;
132*9e564957SAndroid Build Coastguard Worker };
133*9e564957SAndroid Build Coastguard Worker 
134*9e564957SAndroid Build Coastguard Worker struct fuse_custom_io {
135*9e564957SAndroid Build Coastguard Worker 	ssize_t (*writev)(int fd, struct iovec *iov, int count, void *userdata);
136*9e564957SAndroid Build Coastguard Worker 	ssize_t (*read)(int fd, void *buf, size_t buf_len, void *userdata);
137*9e564957SAndroid Build Coastguard Worker 	ssize_t (*splice_receive)(int fdin, off_t *offin, int fdout,
138*9e564957SAndroid Build Coastguard Worker 					  off_t *offout, size_t len,
139*9e564957SAndroid Build Coastguard Worker 				  	  unsigned int flags, void *userdata);
140*9e564957SAndroid Build Coastguard Worker 	ssize_t (*splice_send)(int fdin, off_t *offin, int fdout,
141*9e564957SAndroid Build Coastguard Worker 				     off_t *offout, size_t len,
142*9e564957SAndroid Build Coastguard Worker 			           unsigned int flags, void *userdata);
143*9e564957SAndroid Build Coastguard Worker 	int (*clone_fd)(int master_fd);
144*9e564957SAndroid Build Coastguard Worker };
145*9e564957SAndroid Build Coastguard Worker 
146*9e564957SAndroid Build Coastguard Worker /**
147*9e564957SAndroid Build Coastguard Worker  * Flags for fuse_lowlevel_notify_entry()
148*9e564957SAndroid Build Coastguard Worker  * 0 = invalidate entry
149*9e564957SAndroid Build Coastguard Worker  * FUSE_LL_EXPIRE_ONLY = expire entry
150*9e564957SAndroid Build Coastguard Worker */
151*9e564957SAndroid Build Coastguard Worker enum fuse_notify_entry_flags {
152*9e564957SAndroid Build Coastguard Worker 	FUSE_LL_INVALIDATE = 0,
153*9e564957SAndroid Build Coastguard Worker 	FUSE_LL_EXPIRE_ONLY	= (1 << 0),
154*9e564957SAndroid Build Coastguard Worker };
155*9e564957SAndroid Build Coastguard Worker 
156*9e564957SAndroid Build Coastguard Worker /* 'to_set' flags in setattr */
157*9e564957SAndroid Build Coastguard Worker #define FUSE_SET_ATTR_MODE	(1 << 0)
158*9e564957SAndroid Build Coastguard Worker #define FUSE_SET_ATTR_UID	(1 << 1)
159*9e564957SAndroid Build Coastguard Worker #define FUSE_SET_ATTR_GID	(1 << 2)
160*9e564957SAndroid Build Coastguard Worker #define FUSE_SET_ATTR_SIZE	(1 << 3)
161*9e564957SAndroid Build Coastguard Worker #define FUSE_SET_ATTR_ATIME	(1 << 4)
162*9e564957SAndroid Build Coastguard Worker #define FUSE_SET_ATTR_MTIME	(1 << 5)
163*9e564957SAndroid Build Coastguard Worker #define FUSE_SET_ATTR_ATIME_NOW	(1 << 7)
164*9e564957SAndroid Build Coastguard Worker #define FUSE_SET_ATTR_MTIME_NOW	(1 << 8)
165*9e564957SAndroid Build Coastguard Worker #define FUSE_SET_ATTR_FORCE	(1 << 9)
166*9e564957SAndroid Build Coastguard Worker #define FUSE_SET_ATTR_CTIME	(1 << 10)
167*9e564957SAndroid Build Coastguard Worker #define FUSE_SET_ATTR_KILL_SUID	(1 << 11)
168*9e564957SAndroid Build Coastguard Worker #define FUSE_SET_ATTR_KILL_SGID	(1 << 12)
169*9e564957SAndroid Build Coastguard Worker #define FUSE_SET_ATTR_FILE	(1 << 13)
170*9e564957SAndroid Build Coastguard Worker #define FUSE_SET_ATTR_KILL_PRIV	(1 << 14)
171*9e564957SAndroid Build Coastguard Worker #define FUSE_SET_ATTR_OPEN	(1 << 15)
172*9e564957SAndroid Build Coastguard Worker #define FUSE_SET_ATTR_TIMES_SET	(1 << 16)
173*9e564957SAndroid Build Coastguard Worker #define FUSE_SET_ATTR_TOUCH	(1 << 17)
174*9e564957SAndroid Build Coastguard Worker 
175*9e564957SAndroid Build Coastguard Worker /* ----------------------------------------------------------- *
176*9e564957SAndroid Build Coastguard Worker  * structs from fuse_kernel.h                                  *
177*9e564957SAndroid Build Coastguard Worker  * ----------------------------------------------------------- */
178*9e564957SAndroid Build Coastguard Worker struct fuse_entry_out;
179*9e564957SAndroid Build Coastguard Worker struct fuse_entry_bpf_out;
180*9e564957SAndroid Build Coastguard Worker 
181*9e564957SAndroid Build Coastguard Worker /* ----------------------------------------------------------- *
182*9e564957SAndroid Build Coastguard Worker  * Request methods and replies				       *
183*9e564957SAndroid Build Coastguard Worker  * ----------------------------------------------------------- */
184*9e564957SAndroid Build Coastguard Worker 
185*9e564957SAndroid Build Coastguard Worker /**
186*9e564957SAndroid Build Coastguard Worker  * Low level filesystem operations
187*9e564957SAndroid Build Coastguard Worker  *
188*9e564957SAndroid Build Coastguard Worker  * Most of the methods (with the exception of init and destroy)
189*9e564957SAndroid Build Coastguard Worker  * receive a request handle (fuse_req_t) as their first argument.
190*9e564957SAndroid Build Coastguard Worker  * This handle must be passed to one of the specified reply functions.
191*9e564957SAndroid Build Coastguard Worker  *
192*9e564957SAndroid Build Coastguard Worker  * This may be done inside the method invocation, or after the call
193*9e564957SAndroid Build Coastguard Worker  * has returned.  The request handle is valid until one of the reply
194*9e564957SAndroid Build Coastguard Worker  * functions is called.
195*9e564957SAndroid Build Coastguard Worker  *
196*9e564957SAndroid Build Coastguard Worker  * Other pointer arguments (name, fuse_file_info, etc) are not valid
197*9e564957SAndroid Build Coastguard Worker  * after the call has returned, so if they are needed later, their
198*9e564957SAndroid Build Coastguard Worker  * contents have to be copied.
199*9e564957SAndroid Build Coastguard Worker  *
200*9e564957SAndroid Build Coastguard Worker  * In general, all methods are expected to perform any necessary
201*9e564957SAndroid Build Coastguard Worker  * permission checking. However, a filesystem may delegate this task
202*9e564957SAndroid Build Coastguard Worker  * to the kernel by passing the `default_permissions` mount option to
203*9e564957SAndroid Build Coastguard Worker  * `fuse_session_new()`. In this case, methods will only be called if
204*9e564957SAndroid Build Coastguard Worker  * the kernel's permission check has succeeded.
205*9e564957SAndroid Build Coastguard Worker  *
206*9e564957SAndroid Build Coastguard Worker  * The filesystem sometimes needs to handle a return value of -ENOENT
207*9e564957SAndroid Build Coastguard Worker  * from the reply function, which means, that the request was
208*9e564957SAndroid Build Coastguard Worker  * interrupted, and the reply discarded.  For example if
209*9e564957SAndroid Build Coastguard Worker  * fuse_reply_open() return -ENOENT means, that the release method for
210*9e564957SAndroid Build Coastguard Worker  * this file will not be called.
211*9e564957SAndroid Build Coastguard Worker  */
212*9e564957SAndroid Build Coastguard Worker struct fuse_lowlevel_ops {
213*9e564957SAndroid Build Coastguard Worker 	/**
214*9e564957SAndroid Build Coastguard Worker 	 * Initialize filesystem
215*9e564957SAndroid Build Coastguard Worker 	 *
216*9e564957SAndroid Build Coastguard Worker 	 * This function is called when libfuse establishes
217*9e564957SAndroid Build Coastguard Worker 	 * communication with the FUSE kernel module. The file system
218*9e564957SAndroid Build Coastguard Worker 	 * should use this module to inspect and/or modify the
219*9e564957SAndroid Build Coastguard Worker 	 * connection parameters provided in the `conn` structure.
220*9e564957SAndroid Build Coastguard Worker 	 *
221*9e564957SAndroid Build Coastguard Worker 	 * Note that some parameters may be overwritten by options
222*9e564957SAndroid Build Coastguard Worker 	 * passed to fuse_session_new() which take precedence over the
223*9e564957SAndroid Build Coastguard Worker 	 * values set in this handler.
224*9e564957SAndroid Build Coastguard Worker 	 *
225*9e564957SAndroid Build Coastguard Worker 	 * There's no reply to this function
226*9e564957SAndroid Build Coastguard Worker 	 *
227*9e564957SAndroid Build Coastguard Worker 	 * @param userdata the user data passed to fuse_session_new()
228*9e564957SAndroid Build Coastguard Worker 	 */
229*9e564957SAndroid Build Coastguard Worker 	void (*init) (void *userdata, struct fuse_conn_info *conn);
230*9e564957SAndroid Build Coastguard Worker 
231*9e564957SAndroid Build Coastguard Worker 	/**
232*9e564957SAndroid Build Coastguard Worker 	 * Clean up filesystem.
233*9e564957SAndroid Build Coastguard Worker 	 *
234*9e564957SAndroid Build Coastguard Worker 	 * Called on filesystem exit. When this method is called, the
235*9e564957SAndroid Build Coastguard Worker 	 * connection to the kernel may be gone already, so that eg. calls
236*9e564957SAndroid Build Coastguard Worker 	 * to fuse_lowlevel_notify_* will fail.
237*9e564957SAndroid Build Coastguard Worker 	 *
238*9e564957SAndroid Build Coastguard Worker 	 * There's no reply to this function
239*9e564957SAndroid Build Coastguard Worker 	 *
240*9e564957SAndroid Build Coastguard Worker 	 * @param userdata the user data passed to fuse_session_new()
241*9e564957SAndroid Build Coastguard Worker 	 */
242*9e564957SAndroid Build Coastguard Worker 	void (*destroy) (void *userdata);
243*9e564957SAndroid Build Coastguard Worker 
244*9e564957SAndroid Build Coastguard Worker 	/**
245*9e564957SAndroid Build Coastguard Worker 	 * Look up a directory entry by name and get its attributes.
246*9e564957SAndroid Build Coastguard Worker 	 *
247*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
248*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_entry
249*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
250*9e564957SAndroid Build Coastguard Worker 	 *
251*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
252*9e564957SAndroid Build Coastguard Worker 	 * @param parent inode number of the parent directory
253*9e564957SAndroid Build Coastguard Worker 	 * @param name the name to look up
254*9e564957SAndroid Build Coastguard Worker 	 */
255*9e564957SAndroid Build Coastguard Worker 	void (*lookup) (fuse_req_t req, fuse_ino_t parent, const char *name);
256*9e564957SAndroid Build Coastguard Worker 
257*9e564957SAndroid Build Coastguard Worker 	/**
258*9e564957SAndroid Build Coastguard Worker 	 * post filter a lookup
259*9e564957SAndroid Build Coastguard Worker 	 *
260*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
261*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_entry
262*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
263*9e564957SAndroid Build Coastguard Worker 	 *
264*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
265*9e564957SAndroid Build Coastguard Worker 	 * @param parent inode number of the parent directory
266*9e564957SAndroid Build Coastguard Worker 	 * @param error_in the error, or 0, of the lookup
267*9e564957SAndroid Build Coastguard Worker 	 * @param name the name that was looked up
268*9e564957SAndroid Build Coastguard Worker 	 * @param feo the fuse entry out struct from the lookup
269*9e564957SAndroid Build Coastguard Worker 	 * @param febo the fuse entry bpf out struct from the lookup
270*9e564957SAndroid Build Coastguard Worker 	 */
271*9e564957SAndroid Build Coastguard Worker 	void (*lookup_postfilter)(fuse_req_t req, fuse_ino_t parent,
272*9e564957SAndroid Build Coastguard Worker 								uint32_t error_in, const char *name,
273*9e564957SAndroid Build Coastguard Worker 								struct fuse_entry_out *feo,
274*9e564957SAndroid Build Coastguard Worker 								struct fuse_entry_bpf_out *febo);
275*9e564957SAndroid Build Coastguard Worker 
276*9e564957SAndroid Build Coastguard Worker 	/**
277*9e564957SAndroid Build Coastguard Worker 	 * Forget about an inode
278*9e564957SAndroid Build Coastguard Worker 	 *
279*9e564957SAndroid Build Coastguard Worker 	 * This function is called when the kernel removes an inode
280*9e564957SAndroid Build Coastguard Worker 	 * from its internal caches.
281*9e564957SAndroid Build Coastguard Worker 	 *
282*9e564957SAndroid Build Coastguard Worker 	 * The inode's lookup count increases by one for every call to
283*9e564957SAndroid Build Coastguard Worker 	 * fuse_reply_entry and fuse_reply_create. The nlookup parameter
284*9e564957SAndroid Build Coastguard Worker 	 * indicates by how much the lookup count should be decreased.
285*9e564957SAndroid Build Coastguard Worker 	 *
286*9e564957SAndroid Build Coastguard Worker 	 * Inodes with a non-zero lookup count may receive request from
287*9e564957SAndroid Build Coastguard Worker 	 * the kernel even after calls to unlink, rmdir or (when
288*9e564957SAndroid Build Coastguard Worker 	 * overwriting an existing file) rename. Filesystems must handle
289*9e564957SAndroid Build Coastguard Worker 	 * such requests properly and it is recommended to defer removal
290*9e564957SAndroid Build Coastguard Worker 	 * of the inode until the lookup count reaches zero. Calls to
291*9e564957SAndroid Build Coastguard Worker 	 * unlink, rmdir or rename will be followed closely by forget
292*9e564957SAndroid Build Coastguard Worker 	 * unless the file or directory is open, in which case the
293*9e564957SAndroid Build Coastguard Worker 	 * kernel issues forget only after the release or releasedir
294*9e564957SAndroid Build Coastguard Worker 	 * calls.
295*9e564957SAndroid Build Coastguard Worker 	 *
296*9e564957SAndroid Build Coastguard Worker 	 * Note that if a file system will be exported over NFS the
297*9e564957SAndroid Build Coastguard Worker 	 * inodes lifetime must extend even beyond forget. See the
298*9e564957SAndroid Build Coastguard Worker 	 * generation field in struct fuse_entry_param above.
299*9e564957SAndroid Build Coastguard Worker 	 *
300*9e564957SAndroid Build Coastguard Worker 	 * On unmount the lookup count for all inodes implicitly drops
301*9e564957SAndroid Build Coastguard Worker 	 * to zero. It is not guaranteed that the file system will
302*9e564957SAndroid Build Coastguard Worker 	 * receive corresponding forget messages for the affected
303*9e564957SAndroid Build Coastguard Worker 	 * inodes.
304*9e564957SAndroid Build Coastguard Worker 	 *
305*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
306*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_none
307*9e564957SAndroid Build Coastguard Worker 	 *
308*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
309*9e564957SAndroid Build Coastguard Worker 	 * @param ino the inode number
310*9e564957SAndroid Build Coastguard Worker 	 * @param nlookup the number of lookups to forget
311*9e564957SAndroid Build Coastguard Worker 	 */
312*9e564957SAndroid Build Coastguard Worker 	void (*forget) (fuse_req_t req, fuse_ino_t ino, uint64_t nlookup);
313*9e564957SAndroid Build Coastguard Worker 
314*9e564957SAndroid Build Coastguard Worker 	/**
315*9e564957SAndroid Build Coastguard Worker 	 * Get file attributes.
316*9e564957SAndroid Build Coastguard Worker 	 *
317*9e564957SAndroid Build Coastguard Worker 	 * If writeback caching is enabled, the kernel may have a
318*9e564957SAndroid Build Coastguard Worker 	 * better idea of a file's length than the FUSE file system
319*9e564957SAndroid Build Coastguard Worker 	 * (eg if there has been a write that extended the file size,
320*9e564957SAndroid Build Coastguard Worker 	 * but that has not yet been passed to the filesystem.n
321*9e564957SAndroid Build Coastguard Worker 	 *
322*9e564957SAndroid Build Coastguard Worker 	 * In this case, the st_size value provided by the file system
323*9e564957SAndroid Build Coastguard Worker 	 * will be ignored.
324*9e564957SAndroid Build Coastguard Worker 	 *
325*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
326*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_attr
327*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
328*9e564957SAndroid Build Coastguard Worker 	 *
329*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
330*9e564957SAndroid Build Coastguard Worker 	 * @param ino the inode number
331*9e564957SAndroid Build Coastguard Worker 	 * @param fi for future use, currently always NULL
332*9e564957SAndroid Build Coastguard Worker 	 */
333*9e564957SAndroid Build Coastguard Worker 	void (*getattr) (fuse_req_t req, fuse_ino_t ino,
334*9e564957SAndroid Build Coastguard Worker 			 struct fuse_file_info *fi);
335*9e564957SAndroid Build Coastguard Worker 
336*9e564957SAndroid Build Coastguard Worker 	/**
337*9e564957SAndroid Build Coastguard Worker 	 * Set file attributes
338*9e564957SAndroid Build Coastguard Worker 	 *
339*9e564957SAndroid Build Coastguard Worker 	 * In the 'attr' argument only members indicated by the 'to_set'
340*9e564957SAndroid Build Coastguard Worker 	 * bitmask contain valid values.  Other members contain undefined
341*9e564957SAndroid Build Coastguard Worker 	 * values.
342*9e564957SAndroid Build Coastguard Worker 	 *
343*9e564957SAndroid Build Coastguard Worker 	 * Unless FUSE_CAP_HANDLE_KILLPRIV is disabled, this method is
344*9e564957SAndroid Build Coastguard Worker 	 * expected to reset the setuid and setgid bits if the file
345*9e564957SAndroid Build Coastguard Worker 	 * size or owner is being changed.
346*9e564957SAndroid Build Coastguard Worker 	 *
347*9e564957SAndroid Build Coastguard Worker 	 * This method will not be called to update st_atime or st_ctime implicitly
348*9e564957SAndroid Build Coastguard Worker 	 * (eg. after a read() request), and only be called to implicitly update st_mtime
349*9e564957SAndroid Build Coastguard Worker 	 * if writeback caching is active. It is the filesystem's responsibility to update
350*9e564957SAndroid Build Coastguard Worker 	 * these timestamps when needed, and (if desired) to implement mount options like
351*9e564957SAndroid Build Coastguard Worker 	 * `noatime` or `relatime`.
352*9e564957SAndroid Build Coastguard Worker 	 *
353*9e564957SAndroid Build Coastguard Worker 	 * If the setattr was invoked from the ftruncate() system call
354*9e564957SAndroid Build Coastguard Worker 	 * under Linux kernel versions 2.6.15 or later, the fi->fh will
355*9e564957SAndroid Build Coastguard Worker 	 * contain the value set by the open method or will be undefined
356*9e564957SAndroid Build Coastguard Worker 	 * if the open method didn't set any value.  Otherwise (not
357*9e564957SAndroid Build Coastguard Worker 	 * ftruncate call, or kernel version earlier than 2.6.15) the fi
358*9e564957SAndroid Build Coastguard Worker 	 * parameter will be NULL.
359*9e564957SAndroid Build Coastguard Worker 	 *
360*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
361*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_attr
362*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
363*9e564957SAndroid Build Coastguard Worker 	 *
364*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
365*9e564957SAndroid Build Coastguard Worker 	 * @param ino the inode number
366*9e564957SAndroid Build Coastguard Worker 	 * @param attr the attributes
367*9e564957SAndroid Build Coastguard Worker 	 * @param to_set bit mask of attributes which should be set
368*9e564957SAndroid Build Coastguard Worker 	 * @param fi file information, or NULL
369*9e564957SAndroid Build Coastguard Worker 	 */
370*9e564957SAndroid Build Coastguard Worker 	void (*setattr) (fuse_req_t req, fuse_ino_t ino, struct stat *attr,
371*9e564957SAndroid Build Coastguard Worker 			 int to_set, struct fuse_file_info *fi);
372*9e564957SAndroid Build Coastguard Worker 
373*9e564957SAndroid Build Coastguard Worker 	/**
374*9e564957SAndroid Build Coastguard Worker 	 * Read symbolic link
375*9e564957SAndroid Build Coastguard Worker 	 *
376*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
377*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_readlink
378*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
379*9e564957SAndroid Build Coastguard Worker 	 *
380*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
381*9e564957SAndroid Build Coastguard Worker 	 * @param ino the inode number
382*9e564957SAndroid Build Coastguard Worker 	 */
383*9e564957SAndroid Build Coastguard Worker 	void (*readlink) (fuse_req_t req, fuse_ino_t ino);
384*9e564957SAndroid Build Coastguard Worker 
385*9e564957SAndroid Build Coastguard Worker         /**
386*9e564957SAndroid Build Coastguard Worker 	 * Return canonical path for inotify
387*9e564957SAndroid Build Coastguard Worker 	 *
388*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
389*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_canonical_path
390*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
391*9e564957SAndroid Build Coastguard Worker 	 *
392*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
393*9e564957SAndroid Build Coastguard Worker 	 * @param ino the inode number
394*9e564957SAndroid Build Coastguard Worker 	 */
395*9e564957SAndroid Build Coastguard Worker 	void (*canonical_path) (fuse_req_t req, fuse_ino_t ino);
396*9e564957SAndroid Build Coastguard Worker 
397*9e564957SAndroid Build Coastguard Worker 	/**
398*9e564957SAndroid Build Coastguard Worker 	 * Create file node
399*9e564957SAndroid Build Coastguard Worker 	 *
400*9e564957SAndroid Build Coastguard Worker 	 * Create a regular file, character device, block device, fifo or
401*9e564957SAndroid Build Coastguard Worker 	 * socket node.
402*9e564957SAndroid Build Coastguard Worker 	 *
403*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
404*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_entry
405*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
406*9e564957SAndroid Build Coastguard Worker 	 *
407*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
408*9e564957SAndroid Build Coastguard Worker 	 * @param parent inode number of the parent directory
409*9e564957SAndroid Build Coastguard Worker 	 * @param name to create
410*9e564957SAndroid Build Coastguard Worker 	 * @param mode file type and mode with which to create the new file
411*9e564957SAndroid Build Coastguard Worker 	 * @param rdev the device number (only valid if created file is a device)
412*9e564957SAndroid Build Coastguard Worker 	 */
413*9e564957SAndroid Build Coastguard Worker 	void (*mknod) (fuse_req_t req, fuse_ino_t parent, const char *name,
414*9e564957SAndroid Build Coastguard Worker 		       mode_t mode, dev_t rdev);
415*9e564957SAndroid Build Coastguard Worker 
416*9e564957SAndroid Build Coastguard Worker 	/**
417*9e564957SAndroid Build Coastguard Worker 	 * Create a directory
418*9e564957SAndroid Build Coastguard Worker 	 *
419*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
420*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_entry
421*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
422*9e564957SAndroid Build Coastguard Worker 	 *
423*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
424*9e564957SAndroid Build Coastguard Worker 	 * @param parent inode number of the parent directory
425*9e564957SAndroid Build Coastguard Worker 	 * @param name to create
426*9e564957SAndroid Build Coastguard Worker 	 * @param mode with which to create the new file
427*9e564957SAndroid Build Coastguard Worker 	 */
428*9e564957SAndroid Build Coastguard Worker 	void (*mkdir) (fuse_req_t req, fuse_ino_t parent, const char *name,
429*9e564957SAndroid Build Coastguard Worker 		       mode_t mode);
430*9e564957SAndroid Build Coastguard Worker 
431*9e564957SAndroid Build Coastguard Worker 	/**
432*9e564957SAndroid Build Coastguard Worker 	 * Remove a file
433*9e564957SAndroid Build Coastguard Worker 	 *
434*9e564957SAndroid Build Coastguard Worker 	 * If the file's inode's lookup count is non-zero, the file
435*9e564957SAndroid Build Coastguard Worker 	 * system is expected to postpone any removal of the inode
436*9e564957SAndroid Build Coastguard Worker 	 * until the lookup count reaches zero (see description of the
437*9e564957SAndroid Build Coastguard Worker 	 * forget function).
438*9e564957SAndroid Build Coastguard Worker 	 *
439*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
440*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
441*9e564957SAndroid Build Coastguard Worker 	 *
442*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
443*9e564957SAndroid Build Coastguard Worker 	 * @param parent inode number of the parent directory
444*9e564957SAndroid Build Coastguard Worker 	 * @param name to remove
445*9e564957SAndroid Build Coastguard Worker 	 */
446*9e564957SAndroid Build Coastguard Worker 	void (*unlink) (fuse_req_t req, fuse_ino_t parent, const char *name);
447*9e564957SAndroid Build Coastguard Worker 
448*9e564957SAndroid Build Coastguard Worker 	/**
449*9e564957SAndroid Build Coastguard Worker 	 * Remove a directory
450*9e564957SAndroid Build Coastguard Worker 	 *
451*9e564957SAndroid Build Coastguard Worker 	 * If the directory's inode's lookup count is non-zero, the
452*9e564957SAndroid Build Coastguard Worker 	 * file system is expected to postpone any removal of the
453*9e564957SAndroid Build Coastguard Worker 	 * inode until the lookup count reaches zero (see description
454*9e564957SAndroid Build Coastguard Worker 	 * of the forget function).
455*9e564957SAndroid Build Coastguard Worker 	 *
456*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
457*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
458*9e564957SAndroid Build Coastguard Worker 	 *
459*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
460*9e564957SAndroid Build Coastguard Worker 	 * @param parent inode number of the parent directory
461*9e564957SAndroid Build Coastguard Worker 	 * @param name to remove
462*9e564957SAndroid Build Coastguard Worker 	 */
463*9e564957SAndroid Build Coastguard Worker 	void (*rmdir) (fuse_req_t req, fuse_ino_t parent, const char *name);
464*9e564957SAndroid Build Coastguard Worker 
465*9e564957SAndroid Build Coastguard Worker 	/**
466*9e564957SAndroid Build Coastguard Worker 	 * Create a symbolic link
467*9e564957SAndroid Build Coastguard Worker 	 *
468*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
469*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_entry
470*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
471*9e564957SAndroid Build Coastguard Worker 	 *
472*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
473*9e564957SAndroid Build Coastguard Worker 	 * @param link the contents of the symbolic link
474*9e564957SAndroid Build Coastguard Worker 	 * @param parent inode number of the parent directory
475*9e564957SAndroid Build Coastguard Worker 	 * @param name to create
476*9e564957SAndroid Build Coastguard Worker 	 */
477*9e564957SAndroid Build Coastguard Worker 	void (*symlink) (fuse_req_t req, const char *link, fuse_ino_t parent,
478*9e564957SAndroid Build Coastguard Worker 			 const char *name);
479*9e564957SAndroid Build Coastguard Worker 
480*9e564957SAndroid Build Coastguard Worker 	/** Rename a file
481*9e564957SAndroid Build Coastguard Worker 	 *
482*9e564957SAndroid Build Coastguard Worker 	 * If the target exists it should be atomically replaced. If
483*9e564957SAndroid Build Coastguard Worker 	 * the target's inode's lookup count is non-zero, the file
484*9e564957SAndroid Build Coastguard Worker 	 * system is expected to postpone any removal of the inode
485*9e564957SAndroid Build Coastguard Worker 	 * until the lookup count reaches zero (see description of the
486*9e564957SAndroid Build Coastguard Worker 	 * forget function).
487*9e564957SAndroid Build Coastguard Worker 	 *
488*9e564957SAndroid Build Coastguard Worker 	 * If this request is answered with an error code of ENOSYS, this is
489*9e564957SAndroid Build Coastguard Worker 	 * treated as a permanent failure with error code EINVAL, i.e. all
490*9e564957SAndroid Build Coastguard Worker 	 * future bmap requests will fail with EINVAL without being
491*9e564957SAndroid Build Coastguard Worker 	 * send to the filesystem process.
492*9e564957SAndroid Build Coastguard Worker 	 *
493*9e564957SAndroid Build Coastguard Worker 	 * *flags* may be `RENAME_EXCHANGE` or `RENAME_NOREPLACE`. If
494*9e564957SAndroid Build Coastguard Worker 	 * RENAME_NOREPLACE is specified, the filesystem must not
495*9e564957SAndroid Build Coastguard Worker 	 * overwrite *newname* if it exists and return an error
496*9e564957SAndroid Build Coastguard Worker 	 * instead. If `RENAME_EXCHANGE` is specified, the filesystem
497*9e564957SAndroid Build Coastguard Worker 	 * must atomically exchange the two files, i.e. both must
498*9e564957SAndroid Build Coastguard Worker 	 * exist and neither may be deleted.
499*9e564957SAndroid Build Coastguard Worker 	 *
500*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
501*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
502*9e564957SAndroid Build Coastguard Worker 	 *
503*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
504*9e564957SAndroid Build Coastguard Worker 	 * @param parent inode number of the old parent directory
505*9e564957SAndroid Build Coastguard Worker 	 * @param name old name
506*9e564957SAndroid Build Coastguard Worker 	 * @param newparent inode number of the new parent directory
507*9e564957SAndroid Build Coastguard Worker 	 * @param newname new name
508*9e564957SAndroid Build Coastguard Worker 	 */
509*9e564957SAndroid Build Coastguard Worker 	void (*rename) (fuse_req_t req, fuse_ino_t parent, const char *name,
510*9e564957SAndroid Build Coastguard Worker 			fuse_ino_t newparent, const char *newname,
511*9e564957SAndroid Build Coastguard Worker 			unsigned int flags);
512*9e564957SAndroid Build Coastguard Worker 
513*9e564957SAndroid Build Coastguard Worker 	/**
514*9e564957SAndroid Build Coastguard Worker 	 * Create a hard link
515*9e564957SAndroid Build Coastguard Worker 	 *
516*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
517*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_entry
518*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
519*9e564957SAndroid Build Coastguard Worker 	 *
520*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
521*9e564957SAndroid Build Coastguard Worker 	 * @param ino the old inode number
522*9e564957SAndroid Build Coastguard Worker 	 * @param newparent inode number of the new parent directory
523*9e564957SAndroid Build Coastguard Worker 	 * @param newname new name to create
524*9e564957SAndroid Build Coastguard Worker 	 */
525*9e564957SAndroid Build Coastguard Worker 	void (*link) (fuse_req_t req, fuse_ino_t ino, fuse_ino_t newparent,
526*9e564957SAndroid Build Coastguard Worker 		      const char *newname);
527*9e564957SAndroid Build Coastguard Worker 
528*9e564957SAndroid Build Coastguard Worker 	/**
529*9e564957SAndroid Build Coastguard Worker 	 * Open a file
530*9e564957SAndroid Build Coastguard Worker 	 *
531*9e564957SAndroid Build Coastguard Worker 	 * Open flags are available in fi->flags. The following rules
532*9e564957SAndroid Build Coastguard Worker 	 * apply.
533*9e564957SAndroid Build Coastguard Worker 	 *
534*9e564957SAndroid Build Coastguard Worker 	 *  - Creation (O_CREAT, O_EXCL, O_NOCTTY) flags will be
535*9e564957SAndroid Build Coastguard Worker 	 *    filtered out / handled by the kernel.
536*9e564957SAndroid Build Coastguard Worker 	 *
537*9e564957SAndroid Build Coastguard Worker 	 *  - Access modes (O_RDONLY, O_WRONLY, O_RDWR) should be used
538*9e564957SAndroid Build Coastguard Worker 	 *    by the filesystem to check if the operation is
539*9e564957SAndroid Build Coastguard Worker 	 *    permitted.  If the ``-o default_permissions`` mount
540*9e564957SAndroid Build Coastguard Worker 	 *    option is given, this check is already done by the
541*9e564957SAndroid Build Coastguard Worker 	 *    kernel before calling open() and may thus be omitted by
542*9e564957SAndroid Build Coastguard Worker 	 *    the filesystem.
543*9e564957SAndroid Build Coastguard Worker 	 *
544*9e564957SAndroid Build Coastguard Worker 	 *  - When writeback caching is enabled, the kernel may send
545*9e564957SAndroid Build Coastguard Worker 	 *    read requests even for files opened with O_WRONLY. The
546*9e564957SAndroid Build Coastguard Worker 	 *    filesystem should be prepared to handle this.
547*9e564957SAndroid Build Coastguard Worker 	 *
548*9e564957SAndroid Build Coastguard Worker 	 *  - When writeback caching is disabled, the filesystem is
549*9e564957SAndroid Build Coastguard Worker 	 *    expected to properly handle the O_APPEND flag and ensure
550*9e564957SAndroid Build Coastguard Worker 	 *    that each write is appending to the end of the file.
551*9e564957SAndroid Build Coastguard Worker 	 *
552*9e564957SAndroid Build Coastguard Worker          *  - When writeback caching is enabled, the kernel will
553*9e564957SAndroid Build Coastguard Worker 	 *    handle O_APPEND. However, unless all changes to the file
554*9e564957SAndroid Build Coastguard Worker 	 *    come through the kernel this will not work reliably. The
555*9e564957SAndroid Build Coastguard Worker 	 *    filesystem should thus either ignore the O_APPEND flag
556*9e564957SAndroid Build Coastguard Worker 	 *    (and let the kernel handle it), or return an error
557*9e564957SAndroid Build Coastguard Worker 	 *    (indicating that reliably O_APPEND is not available).
558*9e564957SAndroid Build Coastguard Worker 	 *
559*9e564957SAndroid Build Coastguard Worker 	 * Filesystem may store an arbitrary file handle (pointer,
560*9e564957SAndroid Build Coastguard Worker 	 * index, etc) in fi->fh, and use this in other all other file
561*9e564957SAndroid Build Coastguard Worker 	 * operations (read, write, flush, release, fsync).
562*9e564957SAndroid Build Coastguard Worker 	 *
563*9e564957SAndroid Build Coastguard Worker 	 * Filesystem may also implement stateless file I/O and not store
564*9e564957SAndroid Build Coastguard Worker 	 * anything in fi->fh.
565*9e564957SAndroid Build Coastguard Worker 	 *
566*9e564957SAndroid Build Coastguard Worker 	 * There are also some flags (direct_io, keep_cache) which the
567*9e564957SAndroid Build Coastguard Worker 	 * filesystem may set in fi, to change the way the file is opened.
568*9e564957SAndroid Build Coastguard Worker 	 * See fuse_file_info structure in <fuse_common.h> for more details.
569*9e564957SAndroid Build Coastguard Worker 	 *
570*9e564957SAndroid Build Coastguard Worker 	 * If this request is answered with an error code of ENOSYS
571*9e564957SAndroid Build Coastguard Worker 	 * and FUSE_CAP_NO_OPEN_SUPPORT is set in
572*9e564957SAndroid Build Coastguard Worker 	 * `fuse_conn_info.capable`, this is treated as success and
573*9e564957SAndroid Build Coastguard Worker 	 * future calls to open and release will also succeed without being
574*9e564957SAndroid Build Coastguard Worker 	 * sent to the filesystem process.
575*9e564957SAndroid Build Coastguard Worker 	 *
576*9e564957SAndroid Build Coastguard Worker 	 * To get this behavior without providing an opendir handler, you may
577*9e564957SAndroid Build Coastguard Worker 	 * set FUSE_CAP_NO_OPEN_SUPPORT in `fuse_conn_info.want` on supported
578*9e564957SAndroid Build Coastguard Worker 	 * kernels to automatically get the zero message open().
579*9e564957SAndroid Build Coastguard Worker 	 *
580*9e564957SAndroid Build Coastguard Worker 	 * If this callback is not provided and FUSE_CAP_NO_OPEN_SUPPORT is not
581*9e564957SAndroid Build Coastguard Worker 	 * set in `fuse_conn_info.want` then an empty reply will be sent.
582*9e564957SAndroid Build Coastguard Worker 	 *
583*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
584*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_open
585*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
586*9e564957SAndroid Build Coastguard Worker 	 *
587*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
588*9e564957SAndroid Build Coastguard Worker 	 * @param ino the inode number
589*9e564957SAndroid Build Coastguard Worker 	 * @param fi file information
590*9e564957SAndroid Build Coastguard Worker 	 */
591*9e564957SAndroid Build Coastguard Worker 	void (*open) (fuse_req_t req, fuse_ino_t ino,
592*9e564957SAndroid Build Coastguard Worker 		      struct fuse_file_info *fi);
593*9e564957SAndroid Build Coastguard Worker 
594*9e564957SAndroid Build Coastguard Worker 	/**
595*9e564957SAndroid Build Coastguard Worker 	 * Read data
596*9e564957SAndroid Build Coastguard Worker 	 *
597*9e564957SAndroid Build Coastguard Worker 	 * Read should send exactly the number of bytes requested except
598*9e564957SAndroid Build Coastguard Worker 	 * on EOF or error, otherwise the rest of the data will be
599*9e564957SAndroid Build Coastguard Worker 	 * substituted with zeroes.  An exception to this is when the file
600*9e564957SAndroid Build Coastguard Worker 	 * has been opened in 'direct_io' mode, in which case the return
601*9e564957SAndroid Build Coastguard Worker 	 * value of the read system call will reflect the return value of
602*9e564957SAndroid Build Coastguard Worker 	 * this operation.
603*9e564957SAndroid Build Coastguard Worker 	 *
604*9e564957SAndroid Build Coastguard Worker 	 * fi->fh will contain the value set by the open method, or will
605*9e564957SAndroid Build Coastguard Worker 	 * be undefined if the open method didn't set any value.
606*9e564957SAndroid Build Coastguard Worker 	 *
607*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
608*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_buf
609*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_iov
610*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_data
611*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
612*9e564957SAndroid Build Coastguard Worker 	 *
613*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
614*9e564957SAndroid Build Coastguard Worker 	 * @param ino the inode number
615*9e564957SAndroid Build Coastguard Worker 	 * @param size number of bytes to read
616*9e564957SAndroid Build Coastguard Worker 	 * @param off offset to read from
617*9e564957SAndroid Build Coastguard Worker 	 * @param fi file information
618*9e564957SAndroid Build Coastguard Worker 	 */
619*9e564957SAndroid Build Coastguard Worker 	void (*read) (fuse_req_t req, fuse_ino_t ino, size_t size, off_t off,
620*9e564957SAndroid Build Coastguard Worker 		      struct fuse_file_info *fi);
621*9e564957SAndroid Build Coastguard Worker 
622*9e564957SAndroid Build Coastguard Worker 	/**
623*9e564957SAndroid Build Coastguard Worker 	 * Write data
624*9e564957SAndroid Build Coastguard Worker 	 *
625*9e564957SAndroid Build Coastguard Worker 	 * Write should return exactly the number of bytes requested
626*9e564957SAndroid Build Coastguard Worker 	 * except on error.  An exception to this is when the file has
627*9e564957SAndroid Build Coastguard Worker 	 * been opened in 'direct_io' mode, in which case the return value
628*9e564957SAndroid Build Coastguard Worker 	 * of the write system call will reflect the return value of this
629*9e564957SAndroid Build Coastguard Worker 	 * operation.
630*9e564957SAndroid Build Coastguard Worker 	 *
631*9e564957SAndroid Build Coastguard Worker 	 * Unless FUSE_CAP_HANDLE_KILLPRIV is disabled, this method is
632*9e564957SAndroid Build Coastguard Worker 	 * expected to reset the setuid and setgid bits.
633*9e564957SAndroid Build Coastguard Worker 	 *
634*9e564957SAndroid Build Coastguard Worker 	 * fi->fh will contain the value set by the open method, or will
635*9e564957SAndroid Build Coastguard Worker 	 * be undefined if the open method didn't set any value.
636*9e564957SAndroid Build Coastguard Worker 	 *
637*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
638*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_write
639*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
640*9e564957SAndroid Build Coastguard Worker 	 *
641*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
642*9e564957SAndroid Build Coastguard Worker 	 * @param ino the inode number
643*9e564957SAndroid Build Coastguard Worker 	 * @param buf data to write
644*9e564957SAndroid Build Coastguard Worker 	 * @param size number of bytes to write
645*9e564957SAndroid Build Coastguard Worker 	 * @param off offset to write to
646*9e564957SAndroid Build Coastguard Worker 	 * @param fi file information
647*9e564957SAndroid Build Coastguard Worker 	 */
648*9e564957SAndroid Build Coastguard Worker 	void (*write) (fuse_req_t req, fuse_ino_t ino, const char *buf,
649*9e564957SAndroid Build Coastguard Worker 		       size_t size, off_t off, struct fuse_file_info *fi);
650*9e564957SAndroid Build Coastguard Worker 
651*9e564957SAndroid Build Coastguard Worker 	/**
652*9e564957SAndroid Build Coastguard Worker 	 * Flush method
653*9e564957SAndroid Build Coastguard Worker 	 *
654*9e564957SAndroid Build Coastguard Worker 	 * This is called on each close() of the opened file.
655*9e564957SAndroid Build Coastguard Worker 	 *
656*9e564957SAndroid Build Coastguard Worker 	 * Since file descriptors can be duplicated (dup, dup2, fork), for
657*9e564957SAndroid Build Coastguard Worker 	 * one open call there may be many flush calls.
658*9e564957SAndroid Build Coastguard Worker 	 *
659*9e564957SAndroid Build Coastguard Worker 	 * Filesystems shouldn't assume that flush will always be called
660*9e564957SAndroid Build Coastguard Worker 	 * after some writes, or that if will be called at all.
661*9e564957SAndroid Build Coastguard Worker 	 *
662*9e564957SAndroid Build Coastguard Worker 	 * fi->fh will contain the value set by the open method, or will
663*9e564957SAndroid Build Coastguard Worker 	 * be undefined if the open method didn't set any value.
664*9e564957SAndroid Build Coastguard Worker 	 *
665*9e564957SAndroid Build Coastguard Worker 	 * NOTE: the name of the method is misleading, since (unlike
666*9e564957SAndroid Build Coastguard Worker 	 * fsync) the filesystem is not forced to flush pending writes.
667*9e564957SAndroid Build Coastguard Worker 	 * One reason to flush data is if the filesystem wants to return
668*9e564957SAndroid Build Coastguard Worker 	 * write errors during close.  However, such use is non-portable
669*9e564957SAndroid Build Coastguard Worker 	 * because POSIX does not require [close] to wait for delayed I/O to
670*9e564957SAndroid Build Coastguard Worker 	 * complete.
671*9e564957SAndroid Build Coastguard Worker 	 *
672*9e564957SAndroid Build Coastguard Worker 	 * If the filesystem supports file locking operations (setlk,
673*9e564957SAndroid Build Coastguard Worker 	 * getlk) it should remove all locks belonging to 'fi->owner'.
674*9e564957SAndroid Build Coastguard Worker 	 *
675*9e564957SAndroid Build Coastguard Worker 	 * If this request is answered with an error code of ENOSYS,
676*9e564957SAndroid Build Coastguard Worker 	 * this is treated as success and future calls to flush() will
677*9e564957SAndroid Build Coastguard Worker 	 * succeed automatically without being send to the filesystem
678*9e564957SAndroid Build Coastguard Worker 	 * process.
679*9e564957SAndroid Build Coastguard Worker 	 *
680*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
681*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
682*9e564957SAndroid Build Coastguard Worker 	 *
683*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
684*9e564957SAndroid Build Coastguard Worker 	 * @param ino the inode number
685*9e564957SAndroid Build Coastguard Worker 	 * @param fi file information
686*9e564957SAndroid Build Coastguard Worker 	 *
687*9e564957SAndroid Build Coastguard Worker 	 * [close]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/close.html
688*9e564957SAndroid Build Coastguard Worker 	 */
689*9e564957SAndroid Build Coastguard Worker 	void (*flush) (fuse_req_t req, fuse_ino_t ino,
690*9e564957SAndroid Build Coastguard Worker 		       struct fuse_file_info *fi);
691*9e564957SAndroid Build Coastguard Worker 
692*9e564957SAndroid Build Coastguard Worker 	/**
693*9e564957SAndroid Build Coastguard Worker 	 * Release an open file
694*9e564957SAndroid Build Coastguard Worker 	 *
695*9e564957SAndroid Build Coastguard Worker 	 * Release is called when there are no more references to an open
696*9e564957SAndroid Build Coastguard Worker 	 * file: all file descriptors are closed and all memory mappings
697*9e564957SAndroid Build Coastguard Worker 	 * are unmapped.
698*9e564957SAndroid Build Coastguard Worker 	 *
699*9e564957SAndroid Build Coastguard Worker 	 * For every open call there will be exactly one release call (unless
700*9e564957SAndroid Build Coastguard Worker 	 * the filesystem is force-unmounted).
701*9e564957SAndroid Build Coastguard Worker 	 *
702*9e564957SAndroid Build Coastguard Worker 	 * The filesystem may reply with an error, but error values are
703*9e564957SAndroid Build Coastguard Worker 	 * not returned to close() or munmap() which triggered the
704*9e564957SAndroid Build Coastguard Worker 	 * release.
705*9e564957SAndroid Build Coastguard Worker 	 *
706*9e564957SAndroid Build Coastguard Worker 	 * fi->fh will contain the value set by the open method, or will
707*9e564957SAndroid Build Coastguard Worker 	 * be undefined if the open method didn't set any value.
708*9e564957SAndroid Build Coastguard Worker 	 * fi->flags will contain the same flags as for open.
709*9e564957SAndroid Build Coastguard Worker 	 *
710*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
711*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
712*9e564957SAndroid Build Coastguard Worker 	 *
713*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
714*9e564957SAndroid Build Coastguard Worker 	 * @param ino the inode number
715*9e564957SAndroid Build Coastguard Worker 	 * @param fi file information
716*9e564957SAndroid Build Coastguard Worker 	 */
717*9e564957SAndroid Build Coastguard Worker 	void (*release) (fuse_req_t req, fuse_ino_t ino,
718*9e564957SAndroid Build Coastguard Worker 			 struct fuse_file_info *fi);
719*9e564957SAndroid Build Coastguard Worker 
720*9e564957SAndroid Build Coastguard Worker 	/**
721*9e564957SAndroid Build Coastguard Worker 	 * Synchronize file contents
722*9e564957SAndroid Build Coastguard Worker 	 *
723*9e564957SAndroid Build Coastguard Worker 	 * If the datasync parameter is non-zero, then only the user data
724*9e564957SAndroid Build Coastguard Worker 	 * should be flushed, not the meta data.
725*9e564957SAndroid Build Coastguard Worker 	 *
726*9e564957SAndroid Build Coastguard Worker 	 * If this request is answered with an error code of ENOSYS,
727*9e564957SAndroid Build Coastguard Worker 	 * this is treated as success and future calls to fsync() will
728*9e564957SAndroid Build Coastguard Worker 	 * succeed automatically without being send to the filesystem
729*9e564957SAndroid Build Coastguard Worker 	 * process.
730*9e564957SAndroid Build Coastguard Worker 	 *
731*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
732*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
733*9e564957SAndroid Build Coastguard Worker 	 *
734*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
735*9e564957SAndroid Build Coastguard Worker 	 * @param ino the inode number
736*9e564957SAndroid Build Coastguard Worker 	 * @param datasync flag indicating if only data should be flushed
737*9e564957SAndroid Build Coastguard Worker 	 * @param fi file information
738*9e564957SAndroid Build Coastguard Worker 	 */
739*9e564957SAndroid Build Coastguard Worker 	void (*fsync) (fuse_req_t req, fuse_ino_t ino, int datasync,
740*9e564957SAndroid Build Coastguard Worker 		       struct fuse_file_info *fi);
741*9e564957SAndroid Build Coastguard Worker 
742*9e564957SAndroid Build Coastguard Worker 	/**
743*9e564957SAndroid Build Coastguard Worker 	 * Open a directory
744*9e564957SAndroid Build Coastguard Worker 	 *
745*9e564957SAndroid Build Coastguard Worker 	 * Filesystem may store an arbitrary file handle (pointer, index,
746*9e564957SAndroid Build Coastguard Worker 	 * etc) in fi->fh, and use this in other all other directory
747*9e564957SAndroid Build Coastguard Worker 	 * stream operations (readdir, releasedir, fsyncdir).
748*9e564957SAndroid Build Coastguard Worker 	 *
749*9e564957SAndroid Build Coastguard Worker 	 * If this request is answered with an error code of ENOSYS and
750*9e564957SAndroid Build Coastguard Worker 	 * FUSE_CAP_NO_OPENDIR_SUPPORT is set in `fuse_conn_info.capable`,
751*9e564957SAndroid Build Coastguard Worker 	 * this is treated as success and future calls to opendir and
752*9e564957SAndroid Build Coastguard Worker 	 * releasedir will also succeed without being sent to the filesystem
753*9e564957SAndroid Build Coastguard Worker 	 * process. In addition, the kernel will cache readdir results
754*9e564957SAndroid Build Coastguard Worker 	 * as if opendir returned FOPEN_KEEP_CACHE | FOPEN_CACHE_DIR.
755*9e564957SAndroid Build Coastguard Worker 	 *
756*9e564957SAndroid Build Coastguard Worker 	 * To get this behavior without providing an opendir handler, you may
757*9e564957SAndroid Build Coastguard Worker 	 * set FUSE_CAP_NO_OPENDIR_SUPPORT in `fuse_conn_info.want` on supported
758*9e564957SAndroid Build Coastguard Worker 	 * kernels to automatically get the zero message opendir().
759*9e564957SAndroid Build Coastguard Worker 	 *
760*9e564957SAndroid Build Coastguard Worker 	 * If this callback is not provided and FUSE_CAP_NO_OPENDIR_SUPPORT is
761*9e564957SAndroid Build Coastguard Worker 	 * not set in `fuse_conn_info.want` then an empty reply will be sent.
762*9e564957SAndroid Build Coastguard Worker 	 *
763*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
764*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_open
765*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
766*9e564957SAndroid Build Coastguard Worker 	 *
767*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
768*9e564957SAndroid Build Coastguard Worker 	 * @param ino the inode number
769*9e564957SAndroid Build Coastguard Worker 	 * @param fi file information
770*9e564957SAndroid Build Coastguard Worker 	 */
771*9e564957SAndroid Build Coastguard Worker 	void (*opendir) (fuse_req_t req, fuse_ino_t ino,
772*9e564957SAndroid Build Coastguard Worker 			 struct fuse_file_info *fi);
773*9e564957SAndroid Build Coastguard Worker 
774*9e564957SAndroid Build Coastguard Worker 	/**
775*9e564957SAndroid Build Coastguard Worker 	 * Read directory
776*9e564957SAndroid Build Coastguard Worker 	 *
777*9e564957SAndroid Build Coastguard Worker 	 * Send a buffer filled using fuse_add_direntry(), with size not
778*9e564957SAndroid Build Coastguard Worker 	 * exceeding the requested size.  Send an empty buffer on end of
779*9e564957SAndroid Build Coastguard Worker 	 * stream.
780*9e564957SAndroid Build Coastguard Worker 	 *
781*9e564957SAndroid Build Coastguard Worker 	 * fi->fh will contain the value set by the opendir method, or
782*9e564957SAndroid Build Coastguard Worker 	 * will be undefined if the opendir method didn't set any value.
783*9e564957SAndroid Build Coastguard Worker 	 *
784*9e564957SAndroid Build Coastguard Worker 	 * Returning a directory entry from readdir() does not affect
785*9e564957SAndroid Build Coastguard Worker 	 * its lookup count.
786*9e564957SAndroid Build Coastguard Worker 	 *
787*9e564957SAndroid Build Coastguard Worker          * If off_t is non-zero, then it will correspond to one of the off_t
788*9e564957SAndroid Build Coastguard Worker 	 * values that was previously returned by readdir() for the same
789*9e564957SAndroid Build Coastguard Worker 	 * directory handle. In this case, readdir() should skip over entries
790*9e564957SAndroid Build Coastguard Worker 	 * coming before the position defined by the off_t value. If entries
791*9e564957SAndroid Build Coastguard Worker 	 * are added or removed while the directory handle is open, the filesystem
792*9e564957SAndroid Build Coastguard Worker 	 * may still include the entries that have been removed, and may not
793*9e564957SAndroid Build Coastguard Worker 	 * report the entries that have been created. However, addition or
794*9e564957SAndroid Build Coastguard Worker 	 * removal of entries must never cause readdir() to skip over unrelated
795*9e564957SAndroid Build Coastguard Worker 	 * entries or to report them more than once. This means
796*9e564957SAndroid Build Coastguard Worker 	 * that off_t can not be a simple index that enumerates the entries
797*9e564957SAndroid Build Coastguard Worker 	 * that have been returned but must contain sufficient information to
798*9e564957SAndroid Build Coastguard Worker 	 * uniquely determine the next directory entry to return even when the
799*9e564957SAndroid Build Coastguard Worker 	 * set of entries is changing.
800*9e564957SAndroid Build Coastguard Worker 	 *
801*9e564957SAndroid Build Coastguard Worker 	 * The function does not have to report the '.' and '..'
802*9e564957SAndroid Build Coastguard Worker 	 * entries, but is allowed to do so. Note that, if readdir does
803*9e564957SAndroid Build Coastguard Worker 	 * not return '.' or '..', they will not be implicitly returned,
804*9e564957SAndroid Build Coastguard Worker 	 * and this behavior is observable by the caller.
805*9e564957SAndroid Build Coastguard Worker 	 *
806*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
807*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_buf
808*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_data
809*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
810*9e564957SAndroid Build Coastguard Worker 	 *
811*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
812*9e564957SAndroid Build Coastguard Worker 	 * @param ino the inode number
813*9e564957SAndroid Build Coastguard Worker 	 * @param size maximum number of bytes to send
814*9e564957SAndroid Build Coastguard Worker 	 * @param off offset to continue reading the directory stream
815*9e564957SAndroid Build Coastguard Worker 	 * @param fi file information
816*9e564957SAndroid Build Coastguard Worker 	 */
817*9e564957SAndroid Build Coastguard Worker 	void (*readdir) (fuse_req_t req, fuse_ino_t ino, size_t size, off_t off,
818*9e564957SAndroid Build Coastguard Worker 			 struct fuse_file_info *fi);
819*9e564957SAndroid Build Coastguard Worker 
820*9e564957SAndroid Build Coastguard Worker 	/**
821*9e564957SAndroid Build Coastguard Worker 	 * Read directory postfilter
822*9e564957SAndroid Build Coastguard Worker 	 *
823*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
824*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_buf
825*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_data
826*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
827*9e564957SAndroid Build Coastguard Worker 	 *
828*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
829*9e564957SAndroid Build Coastguard Worker 	 * @param ino the inode number
830*9e564957SAndroid Build Coastguard Worker 	 * @param error_in the error from the readdir
831*9e564957SAndroid Build Coastguard Worker 	 * @param off_in offset to continue reading the directory stream before backing
832*9e564957SAndroid Build Coastguard Worker 	 * @param off_out offset to continue reading the directory stream after backing
833*9e564957SAndroid Build Coastguard Worker 	 * @param size_out length in bytes of dirents
834*9e564957SAndroid Build Coastguard Worker 	 * @param dirents array of dirents read by backing
835*9e564957SAndroid Build Coastguard Worker 	 * @param fi file information
836*9e564957SAndroid Build Coastguard Worker 	 */
837*9e564957SAndroid Build Coastguard Worker 	void (*readdirpostfilter)(fuse_req_t req, fuse_ino_t ino, uint32_t error_in,
838*9e564957SAndroid Build Coastguard Worker 								off_t off_in, off_t off_out, size_t size_out,
839*9e564957SAndroid Build Coastguard Worker 								const void *dirents, struct fuse_file_info *fi);
840*9e564957SAndroid Build Coastguard Worker 
841*9e564957SAndroid Build Coastguard Worker 	/**
842*9e564957SAndroid Build Coastguard Worker 	 * Release an open directory
843*9e564957SAndroid Build Coastguard Worker 	 *
844*9e564957SAndroid Build Coastguard Worker 	 * For every opendir call there will be exactly one releasedir
845*9e564957SAndroid Build Coastguard Worker 	 * call (unless the filesystem is force-unmounted).
846*9e564957SAndroid Build Coastguard Worker 	 *
847*9e564957SAndroid Build Coastguard Worker 	 * fi->fh will contain the value set by the opendir method, or
848*9e564957SAndroid Build Coastguard Worker 	 * will be undefined if the opendir method didn't set any value.
849*9e564957SAndroid Build Coastguard Worker 	 *
850*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
851*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
852*9e564957SAndroid Build Coastguard Worker 	 *
853*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
854*9e564957SAndroid Build Coastguard Worker 	 * @param ino the inode number
855*9e564957SAndroid Build Coastguard Worker 	 * @param fi file information
856*9e564957SAndroid Build Coastguard Worker 	 */
857*9e564957SAndroid Build Coastguard Worker 	void (*releasedir) (fuse_req_t req, fuse_ino_t ino,
858*9e564957SAndroid Build Coastguard Worker 			    struct fuse_file_info *fi);
859*9e564957SAndroid Build Coastguard Worker 
860*9e564957SAndroid Build Coastguard Worker 	/**
861*9e564957SAndroid Build Coastguard Worker 	 * Synchronize directory contents
862*9e564957SAndroid Build Coastguard Worker 	 *
863*9e564957SAndroid Build Coastguard Worker 	 * If the datasync parameter is non-zero, then only the directory
864*9e564957SAndroid Build Coastguard Worker 	 * contents should be flushed, not the meta data.
865*9e564957SAndroid Build Coastguard Worker 	 *
866*9e564957SAndroid Build Coastguard Worker 	 * fi->fh will contain the value set by the opendir method, or
867*9e564957SAndroid Build Coastguard Worker 	 * will be undefined if the opendir method didn't set any value.
868*9e564957SAndroid Build Coastguard Worker 	 *
869*9e564957SAndroid Build Coastguard Worker 	 * If this request is answered with an error code of ENOSYS,
870*9e564957SAndroid Build Coastguard Worker 	 * this is treated as success and future calls to fsyncdir() will
871*9e564957SAndroid Build Coastguard Worker 	 * succeed automatically without being send to the filesystem
872*9e564957SAndroid Build Coastguard Worker 	 * process.
873*9e564957SAndroid Build Coastguard Worker 	 *
874*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
875*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
876*9e564957SAndroid Build Coastguard Worker 	 *
877*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
878*9e564957SAndroid Build Coastguard Worker 	 * @param ino the inode number
879*9e564957SAndroid Build Coastguard Worker 	 * @param datasync flag indicating if only data should be flushed
880*9e564957SAndroid Build Coastguard Worker 	 * @param fi file information
881*9e564957SAndroid Build Coastguard Worker 	 */
882*9e564957SAndroid Build Coastguard Worker 	void (*fsyncdir) (fuse_req_t req, fuse_ino_t ino, int datasync,
883*9e564957SAndroid Build Coastguard Worker 			  struct fuse_file_info *fi);
884*9e564957SAndroid Build Coastguard Worker 
885*9e564957SAndroid Build Coastguard Worker 	/**
886*9e564957SAndroid Build Coastguard Worker 	 * Get file system statistics
887*9e564957SAndroid Build Coastguard Worker 	 *
888*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
889*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_statfs
890*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
891*9e564957SAndroid Build Coastguard Worker 	 *
892*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
893*9e564957SAndroid Build Coastguard Worker 	 * @param ino the inode number, zero means "undefined"
894*9e564957SAndroid Build Coastguard Worker 	 */
895*9e564957SAndroid Build Coastguard Worker 	void (*statfs) (fuse_req_t req, fuse_ino_t ino);
896*9e564957SAndroid Build Coastguard Worker 
897*9e564957SAndroid Build Coastguard Worker 	/**
898*9e564957SAndroid Build Coastguard Worker 	 * Set an extended attribute
899*9e564957SAndroid Build Coastguard Worker 	 *
900*9e564957SAndroid Build Coastguard Worker 	 * If this request is answered with an error code of ENOSYS, this is
901*9e564957SAndroid Build Coastguard Worker 	 * treated as a permanent failure with error code EOPNOTSUPP, i.e. all
902*9e564957SAndroid Build Coastguard Worker 	 * future setxattr() requests will fail with EOPNOTSUPP without being
903*9e564957SAndroid Build Coastguard Worker 	 * send to the filesystem process.
904*9e564957SAndroid Build Coastguard Worker 	 *
905*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
906*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
907*9e564957SAndroid Build Coastguard Worker 	 */
908*9e564957SAndroid Build Coastguard Worker 	void (*setxattr) (fuse_req_t req, fuse_ino_t ino, const char *name,
909*9e564957SAndroid Build Coastguard Worker 			  const char *value, size_t size, int flags);
910*9e564957SAndroid Build Coastguard Worker 
911*9e564957SAndroid Build Coastguard Worker 	/**
912*9e564957SAndroid Build Coastguard Worker 	 * Get an extended attribute
913*9e564957SAndroid Build Coastguard Worker 	 *
914*9e564957SAndroid Build Coastguard Worker 	 * If size is zero, the size of the value should be sent with
915*9e564957SAndroid Build Coastguard Worker 	 * fuse_reply_xattr.
916*9e564957SAndroid Build Coastguard Worker 	 *
917*9e564957SAndroid Build Coastguard Worker 	 * If the size is non-zero, and the value fits in the buffer, the
918*9e564957SAndroid Build Coastguard Worker 	 * value should be sent with fuse_reply_buf.
919*9e564957SAndroid Build Coastguard Worker 	 *
920*9e564957SAndroid Build Coastguard Worker 	 * If the size is too small for the value, the ERANGE error should
921*9e564957SAndroid Build Coastguard Worker 	 * be sent.
922*9e564957SAndroid Build Coastguard Worker 	 *
923*9e564957SAndroid Build Coastguard Worker 	 * If this request is answered with an error code of ENOSYS, this is
924*9e564957SAndroid Build Coastguard Worker 	 * treated as a permanent failure with error code EOPNOTSUPP, i.e. all
925*9e564957SAndroid Build Coastguard Worker 	 * future getxattr() requests will fail with EOPNOTSUPP without being
926*9e564957SAndroid Build Coastguard Worker 	 * send to the filesystem process.
927*9e564957SAndroid Build Coastguard Worker 	 *
928*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
929*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_buf
930*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_data
931*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_xattr
932*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
933*9e564957SAndroid Build Coastguard Worker 	 *
934*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
935*9e564957SAndroid Build Coastguard Worker 	 * @param ino the inode number
936*9e564957SAndroid Build Coastguard Worker 	 * @param name of the extended attribute
937*9e564957SAndroid Build Coastguard Worker 	 * @param size maximum size of the value to send
938*9e564957SAndroid Build Coastguard Worker 	 */
939*9e564957SAndroid Build Coastguard Worker 	void (*getxattr) (fuse_req_t req, fuse_ino_t ino, const char *name,
940*9e564957SAndroid Build Coastguard Worker 			  size_t size);
941*9e564957SAndroid Build Coastguard Worker 
942*9e564957SAndroid Build Coastguard Worker 	/**
943*9e564957SAndroid Build Coastguard Worker 	 * List extended attribute names
944*9e564957SAndroid Build Coastguard Worker 	 *
945*9e564957SAndroid Build Coastguard Worker 	 * If size is zero, the total size of the attribute list should be
946*9e564957SAndroid Build Coastguard Worker 	 * sent with fuse_reply_xattr.
947*9e564957SAndroid Build Coastguard Worker 	 *
948*9e564957SAndroid Build Coastguard Worker 	 * If the size is non-zero, and the null character separated
949*9e564957SAndroid Build Coastguard Worker 	 * attribute list fits in the buffer, the list should be sent with
950*9e564957SAndroid Build Coastguard Worker 	 * fuse_reply_buf.
951*9e564957SAndroid Build Coastguard Worker 	 *
952*9e564957SAndroid Build Coastguard Worker 	 * If the size is too small for the list, the ERANGE error should
953*9e564957SAndroid Build Coastguard Worker 	 * be sent.
954*9e564957SAndroid Build Coastguard Worker 	 *
955*9e564957SAndroid Build Coastguard Worker 	 * If this request is answered with an error code of ENOSYS, this is
956*9e564957SAndroid Build Coastguard Worker 	 * treated as a permanent failure with error code EOPNOTSUPP, i.e. all
957*9e564957SAndroid Build Coastguard Worker 	 * future listxattr() requests will fail with EOPNOTSUPP without being
958*9e564957SAndroid Build Coastguard Worker 	 * send to the filesystem process.
959*9e564957SAndroid Build Coastguard Worker 	 *
960*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
961*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_buf
962*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_data
963*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_xattr
964*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
965*9e564957SAndroid Build Coastguard Worker 	 *
966*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
967*9e564957SAndroid Build Coastguard Worker 	 * @param ino the inode number
968*9e564957SAndroid Build Coastguard Worker 	 * @param size maximum size of the list to send
969*9e564957SAndroid Build Coastguard Worker 	 */
970*9e564957SAndroid Build Coastguard Worker 	void (*listxattr) (fuse_req_t req, fuse_ino_t ino, size_t size);
971*9e564957SAndroid Build Coastguard Worker 
972*9e564957SAndroid Build Coastguard Worker 	/**
973*9e564957SAndroid Build Coastguard Worker 	 * Remove an extended attribute
974*9e564957SAndroid Build Coastguard Worker 	 *
975*9e564957SAndroid Build Coastguard Worker 	 * If this request is answered with an error code of ENOSYS, this is
976*9e564957SAndroid Build Coastguard Worker 	 * treated as a permanent failure with error code EOPNOTSUPP, i.e. all
977*9e564957SAndroid Build Coastguard Worker 	 * future removexattr() requests will fail with EOPNOTSUPP without being
978*9e564957SAndroid Build Coastguard Worker 	 * send to the filesystem process.
979*9e564957SAndroid Build Coastguard Worker 	 *
980*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
981*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
982*9e564957SAndroid Build Coastguard Worker 	 *
983*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
984*9e564957SAndroid Build Coastguard Worker 	 * @param ino the inode number
985*9e564957SAndroid Build Coastguard Worker 	 * @param name of the extended attribute
986*9e564957SAndroid Build Coastguard Worker 	 */
987*9e564957SAndroid Build Coastguard Worker 	void (*removexattr) (fuse_req_t req, fuse_ino_t ino, const char *name);
988*9e564957SAndroid Build Coastguard Worker 
989*9e564957SAndroid Build Coastguard Worker 	/**
990*9e564957SAndroid Build Coastguard Worker 	 * Check file access permissions
991*9e564957SAndroid Build Coastguard Worker 	 *
992*9e564957SAndroid Build Coastguard Worker 	 * This will be called for the access() and chdir() system
993*9e564957SAndroid Build Coastguard Worker 	 * calls.  If the 'default_permissions' mount option is given,
994*9e564957SAndroid Build Coastguard Worker 	 * this method is not called.
995*9e564957SAndroid Build Coastguard Worker 	 *
996*9e564957SAndroid Build Coastguard Worker 	 * This method is not called under Linux kernel versions 2.4.x
997*9e564957SAndroid Build Coastguard Worker 	 *
998*9e564957SAndroid Build Coastguard Worker 	 * If this request is answered with an error code of ENOSYS, this is
999*9e564957SAndroid Build Coastguard Worker 	 * treated as a permanent success, i.e. this and all future access()
1000*9e564957SAndroid Build Coastguard Worker 	 * requests will succeed without being send to the filesystem process.
1001*9e564957SAndroid Build Coastguard Worker 	 *
1002*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
1003*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
1004*9e564957SAndroid Build Coastguard Worker 	 *
1005*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
1006*9e564957SAndroid Build Coastguard Worker 	 * @param ino the inode number
1007*9e564957SAndroid Build Coastguard Worker 	 * @param mask requested access mode
1008*9e564957SAndroid Build Coastguard Worker 	 */
1009*9e564957SAndroid Build Coastguard Worker 	void (*access) (fuse_req_t req, fuse_ino_t ino, int mask);
1010*9e564957SAndroid Build Coastguard Worker 
1011*9e564957SAndroid Build Coastguard Worker 	/**
1012*9e564957SAndroid Build Coastguard Worker 	 * Create and open a file
1013*9e564957SAndroid Build Coastguard Worker 	 *
1014*9e564957SAndroid Build Coastguard Worker 	 * If the file does not exist, first create it with the specified
1015*9e564957SAndroid Build Coastguard Worker 	 * mode, and then open it.
1016*9e564957SAndroid Build Coastguard Worker 	 *
1017*9e564957SAndroid Build Coastguard Worker 	 * See the description of the open handler for more
1018*9e564957SAndroid Build Coastguard Worker 	 * information.
1019*9e564957SAndroid Build Coastguard Worker 	 *
1020*9e564957SAndroid Build Coastguard Worker 	 * If this method is not implemented or under Linux kernel
1021*9e564957SAndroid Build Coastguard Worker 	 * versions earlier than 2.6.15, the mknod() and open() methods
1022*9e564957SAndroid Build Coastguard Worker 	 * will be called instead.
1023*9e564957SAndroid Build Coastguard Worker 	 *
1024*9e564957SAndroid Build Coastguard Worker 	 * If this request is answered with an error code of ENOSYS, the handler
1025*9e564957SAndroid Build Coastguard Worker 	 * is treated as not implemented (i.e., for this and future requests the
1026*9e564957SAndroid Build Coastguard Worker 	 * mknod() and open() handlers will be called instead).
1027*9e564957SAndroid Build Coastguard Worker 	 *
1028*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
1029*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_create
1030*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
1031*9e564957SAndroid Build Coastguard Worker 	 *
1032*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
1033*9e564957SAndroid Build Coastguard Worker 	 * @param parent inode number of the parent directory
1034*9e564957SAndroid Build Coastguard Worker 	 * @param name to create
1035*9e564957SAndroid Build Coastguard Worker 	 * @param mode file type and mode with which to create the new file
1036*9e564957SAndroid Build Coastguard Worker 	 * @param fi file information
1037*9e564957SAndroid Build Coastguard Worker 	 */
1038*9e564957SAndroid Build Coastguard Worker 	void (*create) (fuse_req_t req, fuse_ino_t parent, const char *name,
1039*9e564957SAndroid Build Coastguard Worker 			mode_t mode, struct fuse_file_info *fi);
1040*9e564957SAndroid Build Coastguard Worker 
1041*9e564957SAndroid Build Coastguard Worker 	/**
1042*9e564957SAndroid Build Coastguard Worker 	 * Test for a POSIX file lock
1043*9e564957SAndroid Build Coastguard Worker 	 *
1044*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
1045*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_lock
1046*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
1047*9e564957SAndroid Build Coastguard Worker 	 *
1048*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
1049*9e564957SAndroid Build Coastguard Worker 	 * @param ino the inode number
1050*9e564957SAndroid Build Coastguard Worker 	 * @param fi file information
1051*9e564957SAndroid Build Coastguard Worker 	 * @param lock the region/type to test
1052*9e564957SAndroid Build Coastguard Worker 	 */
1053*9e564957SAndroid Build Coastguard Worker 	void (*getlk) (fuse_req_t req, fuse_ino_t ino,
1054*9e564957SAndroid Build Coastguard Worker 		       struct fuse_file_info *fi, struct flock *lock);
1055*9e564957SAndroid Build Coastguard Worker 
1056*9e564957SAndroid Build Coastguard Worker 	/**
1057*9e564957SAndroid Build Coastguard Worker 	 * Acquire, modify or release a POSIX file lock
1058*9e564957SAndroid Build Coastguard Worker 	 *
1059*9e564957SAndroid Build Coastguard Worker 	 * For POSIX threads (NPTL) there's a 1-1 relation between pid and
1060*9e564957SAndroid Build Coastguard Worker 	 * owner, but otherwise this is not always the case.  For checking
1061*9e564957SAndroid Build Coastguard Worker 	 * lock ownership, 'fi->owner' must be used.  The l_pid field in
1062*9e564957SAndroid Build Coastguard Worker 	 * 'struct flock' should only be used to fill in this field in
1063*9e564957SAndroid Build Coastguard Worker 	 * getlk().
1064*9e564957SAndroid Build Coastguard Worker 	 *
1065*9e564957SAndroid Build Coastguard Worker 	 * Note: if the locking methods are not implemented, the kernel
1066*9e564957SAndroid Build Coastguard Worker 	 * will still allow file locking to work locally.  Hence these are
1067*9e564957SAndroid Build Coastguard Worker 	 * only interesting for network filesystems and similar.
1068*9e564957SAndroid Build Coastguard Worker 	 *
1069*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
1070*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
1071*9e564957SAndroid Build Coastguard Worker 	 *
1072*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
1073*9e564957SAndroid Build Coastguard Worker 	 * @param ino the inode number
1074*9e564957SAndroid Build Coastguard Worker 	 * @param fi file information
1075*9e564957SAndroid Build Coastguard Worker 	 * @param lock the region/type to set
1076*9e564957SAndroid Build Coastguard Worker 	 * @param sleep locking operation may sleep
1077*9e564957SAndroid Build Coastguard Worker 	 */
1078*9e564957SAndroid Build Coastguard Worker 	void (*setlk) (fuse_req_t req, fuse_ino_t ino,
1079*9e564957SAndroid Build Coastguard Worker 		       struct fuse_file_info *fi,
1080*9e564957SAndroid Build Coastguard Worker 		       struct flock *lock, int sleep);
1081*9e564957SAndroid Build Coastguard Worker 
1082*9e564957SAndroid Build Coastguard Worker 	/**
1083*9e564957SAndroid Build Coastguard Worker 	 * Map block index within file to block index within device
1084*9e564957SAndroid Build Coastguard Worker 	 *
1085*9e564957SAndroid Build Coastguard Worker 	 * Note: This makes sense only for block device backed filesystems
1086*9e564957SAndroid Build Coastguard Worker 	 * mounted with the 'blkdev' option
1087*9e564957SAndroid Build Coastguard Worker 	 *
1088*9e564957SAndroid Build Coastguard Worker 	 * If this request is answered with an error code of ENOSYS, this is
1089*9e564957SAndroid Build Coastguard Worker 	 * treated as a permanent failure, i.e. all future bmap() requests will
1090*9e564957SAndroid Build Coastguard Worker 	 * fail with the same error code without being send to the filesystem
1091*9e564957SAndroid Build Coastguard Worker 	 * process.
1092*9e564957SAndroid Build Coastguard Worker 	 *
1093*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
1094*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_bmap
1095*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
1096*9e564957SAndroid Build Coastguard Worker 	 *
1097*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
1098*9e564957SAndroid Build Coastguard Worker 	 * @param ino the inode number
1099*9e564957SAndroid Build Coastguard Worker 	 * @param blocksize unit of block index
1100*9e564957SAndroid Build Coastguard Worker 	 * @param idx block index within file
1101*9e564957SAndroid Build Coastguard Worker 	 */
1102*9e564957SAndroid Build Coastguard Worker 	void (*bmap) (fuse_req_t req, fuse_ino_t ino, size_t blocksize,
1103*9e564957SAndroid Build Coastguard Worker 		      uint64_t idx);
1104*9e564957SAndroid Build Coastguard Worker 
1105*9e564957SAndroid Build Coastguard Worker #if FUSE_USE_VERSION < 35
1106*9e564957SAndroid Build Coastguard Worker 	void (*ioctl) (fuse_req_t req, fuse_ino_t ino, int cmd,
1107*9e564957SAndroid Build Coastguard Worker 		       void *arg, struct fuse_file_info *fi, unsigned flags,
1108*9e564957SAndroid Build Coastguard Worker 		       const void *in_buf, size_t in_bufsz, size_t out_bufsz);
1109*9e564957SAndroid Build Coastguard Worker #else
1110*9e564957SAndroid Build Coastguard Worker 	/**
1111*9e564957SAndroid Build Coastguard Worker 	 * Ioctl
1112*9e564957SAndroid Build Coastguard Worker 	 *
1113*9e564957SAndroid Build Coastguard Worker 	 * Note: For unrestricted ioctls (not allowed for FUSE
1114*9e564957SAndroid Build Coastguard Worker 	 * servers), data in and out areas can be discovered by giving
1115*9e564957SAndroid Build Coastguard Worker 	 * iovs and setting FUSE_IOCTL_RETRY in *flags*.  For
1116*9e564957SAndroid Build Coastguard Worker 	 * restricted ioctls, kernel prepares in/out data area
1117*9e564957SAndroid Build Coastguard Worker 	 * according to the information encoded in cmd.
1118*9e564957SAndroid Build Coastguard Worker 	 *
1119*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
1120*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_ioctl_retry
1121*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_ioctl
1122*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_ioctl_iov
1123*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
1124*9e564957SAndroid Build Coastguard Worker 	 *
1125*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
1126*9e564957SAndroid Build Coastguard Worker 	 * @param ino the inode number
1127*9e564957SAndroid Build Coastguard Worker 	 * @param cmd ioctl command
1128*9e564957SAndroid Build Coastguard Worker 	 * @param arg ioctl argument
1129*9e564957SAndroid Build Coastguard Worker 	 * @param fi file information
1130*9e564957SAndroid Build Coastguard Worker 	 * @param flags for FUSE_IOCTL_* flags
1131*9e564957SAndroid Build Coastguard Worker 	 * @param in_buf data fetched from the caller
1132*9e564957SAndroid Build Coastguard Worker 	 * @param in_bufsz number of fetched bytes
1133*9e564957SAndroid Build Coastguard Worker 	 * @param out_bufsz maximum size of output data
1134*9e564957SAndroid Build Coastguard Worker 	 *
1135*9e564957SAndroid Build Coastguard Worker 	 * Note : the unsigned long request submitted by the application
1136*9e564957SAndroid Build Coastguard Worker 	 * is truncated to 32 bits.
1137*9e564957SAndroid Build Coastguard Worker 	 */
1138*9e564957SAndroid Build Coastguard Worker 	void (*ioctl) (fuse_req_t req, fuse_ino_t ino, unsigned int cmd,
1139*9e564957SAndroid Build Coastguard Worker 		       void *arg, struct fuse_file_info *fi, unsigned flags,
1140*9e564957SAndroid Build Coastguard Worker 		       const void *in_buf, size_t in_bufsz, size_t out_bufsz);
1141*9e564957SAndroid Build Coastguard Worker #endif
1142*9e564957SAndroid Build Coastguard Worker 
1143*9e564957SAndroid Build Coastguard Worker 	/**
1144*9e564957SAndroid Build Coastguard Worker 	 * Poll for IO readiness
1145*9e564957SAndroid Build Coastguard Worker 	 *
1146*9e564957SAndroid Build Coastguard Worker 	 * The client should immediately respond with fuse_reply_poll(),
1147*9e564957SAndroid Build Coastguard Worker 	 * setting revents appropriately according to which events are ready.
1148*9e564957SAndroid Build Coastguard Worker 	 *
1149*9e564957SAndroid Build Coastguard Worker 	 * Additionally, if ph is non-NULL, the client must retain it and
1150*9e564957SAndroid Build Coastguard Worker 	 * notify when all future IO readiness events occur by calling
1151*9e564957SAndroid Build Coastguard Worker 	 * fuse_lowlevel_notify_poll() with the specified ph.
1152*9e564957SAndroid Build Coastguard Worker 	 *
1153*9e564957SAndroid Build Coastguard Worker 	 * Regardless of the number of times poll with a non-NULL ph is
1154*9e564957SAndroid Build Coastguard Worker 	 * received, a single notify_poll is enough to service all. (Notifying
1155*9e564957SAndroid Build Coastguard Worker 	 * more times incurs overhead but doesn't harm correctness.) Any
1156*9e564957SAndroid Build Coastguard Worker 	 * additional received handles can be immediately destroyed.
1157*9e564957SAndroid Build Coastguard Worker 	 *
1158*9e564957SAndroid Build Coastguard Worker 	 * The callee is responsible for destroying ph with
1159*9e564957SAndroid Build Coastguard Worker 	 * fuse_pollhandle_destroy() when no longer in use.
1160*9e564957SAndroid Build Coastguard Worker 	 *
1161*9e564957SAndroid Build Coastguard Worker 	 * If this request is answered with an error code of ENOSYS, this is
1162*9e564957SAndroid Build Coastguard Worker 	 * treated as success (with a kernel-defined default poll-mask) and
1163*9e564957SAndroid Build Coastguard Worker 	 * future calls to poll() will succeed the same way without being send
1164*9e564957SAndroid Build Coastguard Worker 	 * to the filesystem process.
1165*9e564957SAndroid Build Coastguard Worker 	 *
1166*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
1167*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_poll
1168*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
1169*9e564957SAndroid Build Coastguard Worker 	 *
1170*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
1171*9e564957SAndroid Build Coastguard Worker 	 * @param ino the inode number
1172*9e564957SAndroid Build Coastguard Worker 	 * @param fi file information
1173*9e564957SAndroid Build Coastguard Worker 	 * @param ph poll handle to be used for notification
1174*9e564957SAndroid Build Coastguard Worker 	 */
1175*9e564957SAndroid Build Coastguard Worker 	void (*poll) (fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi,
1176*9e564957SAndroid Build Coastguard Worker 		      struct fuse_pollhandle *ph);
1177*9e564957SAndroid Build Coastguard Worker 
1178*9e564957SAndroid Build Coastguard Worker 	/**
1179*9e564957SAndroid Build Coastguard Worker 	 * Write data made available in a buffer
1180*9e564957SAndroid Build Coastguard Worker 	 *
1181*9e564957SAndroid Build Coastguard Worker 	 * This is a more generic version of the ->write() method.  If
1182*9e564957SAndroid Build Coastguard Worker 	 * FUSE_CAP_SPLICE_READ is set in fuse_conn_info.want and the
1183*9e564957SAndroid Build Coastguard Worker 	 * kernel supports splicing from the fuse device, then the
1184*9e564957SAndroid Build Coastguard Worker 	 * data will be made available in pipe for supporting zero
1185*9e564957SAndroid Build Coastguard Worker 	 * copy data transfer.
1186*9e564957SAndroid Build Coastguard Worker 	 *
1187*9e564957SAndroid Build Coastguard Worker 	 * buf->count is guaranteed to be one (and thus buf->idx is
1188*9e564957SAndroid Build Coastguard Worker 	 * always zero). The write_buf handler must ensure that
1189*9e564957SAndroid Build Coastguard Worker 	 * bufv->off is correctly updated (reflecting the number of
1190*9e564957SAndroid Build Coastguard Worker 	 * bytes read from bufv->buf[0]).
1191*9e564957SAndroid Build Coastguard Worker 	 *
1192*9e564957SAndroid Build Coastguard Worker 	 * Unless FUSE_CAP_HANDLE_KILLPRIV is disabled, this method is
1193*9e564957SAndroid Build Coastguard Worker 	 * expected to reset the setuid and setgid bits.
1194*9e564957SAndroid Build Coastguard Worker 	 *
1195*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
1196*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_write
1197*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
1198*9e564957SAndroid Build Coastguard Worker 	 *
1199*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
1200*9e564957SAndroid Build Coastguard Worker 	 * @param ino the inode number
1201*9e564957SAndroid Build Coastguard Worker 	 * @param bufv buffer containing the data
1202*9e564957SAndroid Build Coastguard Worker 	 * @param off offset to write to
1203*9e564957SAndroid Build Coastguard Worker 	 * @param fi file information
1204*9e564957SAndroid Build Coastguard Worker 	 */
1205*9e564957SAndroid Build Coastguard Worker 	void (*write_buf) (fuse_req_t req, fuse_ino_t ino,
1206*9e564957SAndroid Build Coastguard Worker 			   struct fuse_bufvec *bufv, off_t off,
1207*9e564957SAndroid Build Coastguard Worker 			   struct fuse_file_info *fi);
1208*9e564957SAndroid Build Coastguard Worker 
1209*9e564957SAndroid Build Coastguard Worker 	/**
1210*9e564957SAndroid Build Coastguard Worker 	 * Callback function for the retrieve request
1211*9e564957SAndroid Build Coastguard Worker 	 *
1212*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
1213*9e564957SAndroid Build Coastguard Worker 	 *	fuse_reply_none
1214*9e564957SAndroid Build Coastguard Worker 	 *
1215*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
1216*9e564957SAndroid Build Coastguard Worker 	 * @param cookie user data supplied to fuse_lowlevel_notify_retrieve()
1217*9e564957SAndroid Build Coastguard Worker 	 * @param ino the inode number supplied to fuse_lowlevel_notify_retrieve()
1218*9e564957SAndroid Build Coastguard Worker 	 * @param offset the offset supplied to fuse_lowlevel_notify_retrieve()
1219*9e564957SAndroid Build Coastguard Worker 	 * @param bufv the buffer containing the returned data
1220*9e564957SAndroid Build Coastguard Worker 	 */
1221*9e564957SAndroid Build Coastguard Worker 	void (*retrieve_reply) (fuse_req_t req, void *cookie, fuse_ino_t ino,
1222*9e564957SAndroid Build Coastguard Worker 				off_t offset, struct fuse_bufvec *bufv);
1223*9e564957SAndroid Build Coastguard Worker 
1224*9e564957SAndroid Build Coastguard Worker 	/**
1225*9e564957SAndroid Build Coastguard Worker 	 * Forget about multiple inodes
1226*9e564957SAndroid Build Coastguard Worker 	 *
1227*9e564957SAndroid Build Coastguard Worker 	 * See description of the forget function for more
1228*9e564957SAndroid Build Coastguard Worker 	 * information.
1229*9e564957SAndroid Build Coastguard Worker 	 *
1230*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
1231*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_none
1232*9e564957SAndroid Build Coastguard Worker 	 *
1233*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
1234*9e564957SAndroid Build Coastguard Worker 	 */
1235*9e564957SAndroid Build Coastguard Worker 	void (*forget_multi) (fuse_req_t req, size_t count,
1236*9e564957SAndroid Build Coastguard Worker 			      struct fuse_forget_data *forgets);
1237*9e564957SAndroid Build Coastguard Worker 
1238*9e564957SAndroid Build Coastguard Worker 	/**
1239*9e564957SAndroid Build Coastguard Worker 	 * Acquire, modify or release a BSD file lock
1240*9e564957SAndroid Build Coastguard Worker 	 *
1241*9e564957SAndroid Build Coastguard Worker 	 * Note: if the locking methods are not implemented, the kernel
1242*9e564957SAndroid Build Coastguard Worker 	 * will still allow file locking to work locally.  Hence these are
1243*9e564957SAndroid Build Coastguard Worker 	 * only interesting for network filesystems and similar.
1244*9e564957SAndroid Build Coastguard Worker 	 *
1245*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
1246*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
1247*9e564957SAndroid Build Coastguard Worker 	 *
1248*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
1249*9e564957SAndroid Build Coastguard Worker 	 * @param ino the inode number
1250*9e564957SAndroid Build Coastguard Worker 	 * @param fi file information
1251*9e564957SAndroid Build Coastguard Worker 	 * @param op the locking operation, see flock(2)
1252*9e564957SAndroid Build Coastguard Worker 	 */
1253*9e564957SAndroid Build Coastguard Worker 	void (*flock) (fuse_req_t req, fuse_ino_t ino,
1254*9e564957SAndroid Build Coastguard Worker 		       struct fuse_file_info *fi, int op);
1255*9e564957SAndroid Build Coastguard Worker 
1256*9e564957SAndroid Build Coastguard Worker 	/**
1257*9e564957SAndroid Build Coastguard Worker 	 * Allocate requested space. If this function returns success then
1258*9e564957SAndroid Build Coastguard Worker 	 * subsequent writes to the specified range shall not fail due to the lack
1259*9e564957SAndroid Build Coastguard Worker 	 * of free space on the file system storage media.
1260*9e564957SAndroid Build Coastguard Worker 	 *
1261*9e564957SAndroid Build Coastguard Worker 	 * If this request is answered with an error code of ENOSYS, this is
1262*9e564957SAndroid Build Coastguard Worker 	 * treated as a permanent failure with error code EOPNOTSUPP, i.e. all
1263*9e564957SAndroid Build Coastguard Worker 	 * future fallocate() requests will fail with EOPNOTSUPP without being
1264*9e564957SAndroid Build Coastguard Worker 	 * send to the filesystem process.
1265*9e564957SAndroid Build Coastguard Worker 	 *
1266*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
1267*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
1268*9e564957SAndroid Build Coastguard Worker 	 *
1269*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
1270*9e564957SAndroid Build Coastguard Worker 	 * @param ino the inode number
1271*9e564957SAndroid Build Coastguard Worker 	 * @param offset starting point for allocated region
1272*9e564957SAndroid Build Coastguard Worker 	 * @param length size of allocated region
1273*9e564957SAndroid Build Coastguard Worker 	 * @param mode determines the operation to be performed on the given range,
1274*9e564957SAndroid Build Coastguard Worker 	 *             see fallocate(2)
1275*9e564957SAndroid Build Coastguard Worker 	 */
1276*9e564957SAndroid Build Coastguard Worker 	void (*fallocate) (fuse_req_t req, fuse_ino_t ino, int mode,
1277*9e564957SAndroid Build Coastguard Worker 		       off_t offset, off_t length, struct fuse_file_info *fi);
1278*9e564957SAndroid Build Coastguard Worker 
1279*9e564957SAndroid Build Coastguard Worker 	/**
1280*9e564957SAndroid Build Coastguard Worker 	 * Read directory with attributes
1281*9e564957SAndroid Build Coastguard Worker 	 *
1282*9e564957SAndroid Build Coastguard Worker 	 * Send a buffer filled using fuse_add_direntry_plus(), with size not
1283*9e564957SAndroid Build Coastguard Worker 	 * exceeding the requested size.  Send an empty buffer on end of
1284*9e564957SAndroid Build Coastguard Worker 	 * stream.
1285*9e564957SAndroid Build Coastguard Worker 	 *
1286*9e564957SAndroid Build Coastguard Worker 	 * fi->fh will contain the value set by the opendir method, or
1287*9e564957SAndroid Build Coastguard Worker 	 * will be undefined if the opendir method didn't set any value.
1288*9e564957SAndroid Build Coastguard Worker 	 *
1289*9e564957SAndroid Build Coastguard Worker 	 * In contrast to readdir() (which does not affect the lookup counts),
1290*9e564957SAndroid Build Coastguard Worker 	 * the lookup count of every entry returned by readdirplus(), except "."
1291*9e564957SAndroid Build Coastguard Worker 	 * and "..", is incremented by one.
1292*9e564957SAndroid Build Coastguard Worker 	 *
1293*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
1294*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_buf
1295*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_data
1296*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
1297*9e564957SAndroid Build Coastguard Worker 	 *
1298*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
1299*9e564957SAndroid Build Coastguard Worker 	 * @param ino the inode number
1300*9e564957SAndroid Build Coastguard Worker 	 * @param size maximum number of bytes to send
1301*9e564957SAndroid Build Coastguard Worker 	 * @param off offset to continue reading the directory stream
1302*9e564957SAndroid Build Coastguard Worker 	 * @param fi file information
1303*9e564957SAndroid Build Coastguard Worker 	 */
1304*9e564957SAndroid Build Coastguard Worker 	void (*readdirplus) (fuse_req_t req, fuse_ino_t ino, size_t size, off_t off,
1305*9e564957SAndroid Build Coastguard Worker 			 struct fuse_file_info *fi);
1306*9e564957SAndroid Build Coastguard Worker 
1307*9e564957SAndroid Build Coastguard Worker 	/**
1308*9e564957SAndroid Build Coastguard Worker 	 * Copy a range of data from one file to another
1309*9e564957SAndroid Build Coastguard Worker 	 *
1310*9e564957SAndroid Build Coastguard Worker 	 * Performs an optimized copy between two file descriptors without the
1311*9e564957SAndroid Build Coastguard Worker 	 * additional cost of transferring data through the FUSE kernel module
1312*9e564957SAndroid Build Coastguard Worker 	 * to user space (glibc) and then back into the FUSE filesystem again.
1313*9e564957SAndroid Build Coastguard Worker 	 *
1314*9e564957SAndroid Build Coastguard Worker 	 * In case this method is not implemented, glibc falls back to reading
1315*9e564957SAndroid Build Coastguard Worker 	 * data from the source and writing to the destination. Effectively
1316*9e564957SAndroid Build Coastguard Worker 	 * doing an inefficient copy of the data.
1317*9e564957SAndroid Build Coastguard Worker 	 *
1318*9e564957SAndroid Build Coastguard Worker 	 * If this request is answered with an error code of ENOSYS, this is
1319*9e564957SAndroid Build Coastguard Worker 	 * treated as a permanent failure with error code EOPNOTSUPP, i.e. all
1320*9e564957SAndroid Build Coastguard Worker 	 * future copy_file_range() requests will fail with EOPNOTSUPP without
1321*9e564957SAndroid Build Coastguard Worker 	 * being send to the filesystem process.
1322*9e564957SAndroid Build Coastguard Worker 	 *
1323*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
1324*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_write
1325*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
1326*9e564957SAndroid Build Coastguard Worker 	 *
1327*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
1328*9e564957SAndroid Build Coastguard Worker 	 * @param ino_in the inode number or the source file
1329*9e564957SAndroid Build Coastguard Worker 	 * @param off_in starting point from were the data should be read
1330*9e564957SAndroid Build Coastguard Worker 	 * @param fi_in file information of the source file
1331*9e564957SAndroid Build Coastguard Worker 	 * @param ino_out the inode number or the destination file
1332*9e564957SAndroid Build Coastguard Worker 	 * @param off_out starting point where the data should be written
1333*9e564957SAndroid Build Coastguard Worker 	 * @param fi_out file information of the destination file
1334*9e564957SAndroid Build Coastguard Worker 	 * @param len maximum size of the data to copy
1335*9e564957SAndroid Build Coastguard Worker 	 * @param flags passed along with the copy_file_range() syscall
1336*9e564957SAndroid Build Coastguard Worker 	 */
1337*9e564957SAndroid Build Coastguard Worker 	void (*copy_file_range) (fuse_req_t req, fuse_ino_t ino_in,
1338*9e564957SAndroid Build Coastguard Worker 				 off_t off_in, struct fuse_file_info *fi_in,
1339*9e564957SAndroid Build Coastguard Worker 				 fuse_ino_t ino_out, off_t off_out,
1340*9e564957SAndroid Build Coastguard Worker 				 struct fuse_file_info *fi_out, size_t len,
1341*9e564957SAndroid Build Coastguard Worker 				 int flags);
1342*9e564957SAndroid Build Coastguard Worker 
1343*9e564957SAndroid Build Coastguard Worker 	/**
1344*9e564957SAndroid Build Coastguard Worker 	 * Find next data or hole after the specified offset
1345*9e564957SAndroid Build Coastguard Worker 	 *
1346*9e564957SAndroid Build Coastguard Worker 	 * If this request is answered with an error code of ENOSYS, this is
1347*9e564957SAndroid Build Coastguard Worker 	 * treated as a permanent failure, i.e. all future lseek() requests will
1348*9e564957SAndroid Build Coastguard Worker 	 * fail with the same error code without being send to the filesystem
1349*9e564957SAndroid Build Coastguard Worker 	 * process.
1350*9e564957SAndroid Build Coastguard Worker 	 *
1351*9e564957SAndroid Build Coastguard Worker 	 * Valid replies:
1352*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_lseek
1353*9e564957SAndroid Build Coastguard Worker 	 *   fuse_reply_err
1354*9e564957SAndroid Build Coastguard Worker 	 *
1355*9e564957SAndroid Build Coastguard Worker 	 * @param req request handle
1356*9e564957SAndroid Build Coastguard Worker 	 * @param ino the inode number
1357*9e564957SAndroid Build Coastguard Worker 	 * @param off offset to start search from
1358*9e564957SAndroid Build Coastguard Worker 	 * @param whence either SEEK_DATA or SEEK_HOLE
1359*9e564957SAndroid Build Coastguard Worker 	 * @param fi file information
1360*9e564957SAndroid Build Coastguard Worker 	 */
1361*9e564957SAndroid Build Coastguard Worker 	void (*lseek) (fuse_req_t req, fuse_ino_t ino, off_t off, int whence,
1362*9e564957SAndroid Build Coastguard Worker 		       struct fuse_file_info *fi);
1363*9e564957SAndroid Build Coastguard Worker };
1364*9e564957SAndroid Build Coastguard Worker 
1365*9e564957SAndroid Build Coastguard Worker /**
1366*9e564957SAndroid Build Coastguard Worker  * Reply with an error code or success.
1367*9e564957SAndroid Build Coastguard Worker  *
1368*9e564957SAndroid Build Coastguard Worker  * Possible requests:
1369*9e564957SAndroid Build Coastguard Worker  *   all except forget, forget_multi, retrieve_reply
1370*9e564957SAndroid Build Coastguard Worker  *
1371*9e564957SAndroid Build Coastguard Worker  * Wherever possible, error codes should be chosen from the list of
1372*9e564957SAndroid Build Coastguard Worker  * documented error conditions in the corresponding system calls
1373*9e564957SAndroid Build Coastguard Worker  * manpage.
1374*9e564957SAndroid Build Coastguard Worker  *
1375*9e564957SAndroid Build Coastguard Worker  * An error code of ENOSYS is sometimes treated specially. This is
1376*9e564957SAndroid Build Coastguard Worker  * indicated in the documentation of the affected handler functions.
1377*9e564957SAndroid Build Coastguard Worker  *
1378*9e564957SAndroid Build Coastguard Worker  * The following requests may be answered with a zero error code:
1379*9e564957SAndroid Build Coastguard Worker  * unlink, rmdir, rename, flush, release, fsync, fsyncdir, setxattr,
1380*9e564957SAndroid Build Coastguard Worker  * removexattr, setlk.
1381*9e564957SAndroid Build Coastguard Worker  *
1382*9e564957SAndroid Build Coastguard Worker  * @param req request handle
1383*9e564957SAndroid Build Coastguard Worker  * @param err the positive error value, or zero for success
1384*9e564957SAndroid Build Coastguard Worker  * @return zero for success, -errno for failure to send reply
1385*9e564957SAndroid Build Coastguard Worker  */
1386*9e564957SAndroid Build Coastguard Worker int fuse_reply_err(fuse_req_t req, int err);
1387*9e564957SAndroid Build Coastguard Worker 
1388*9e564957SAndroid Build Coastguard Worker /**
1389*9e564957SAndroid Build Coastguard Worker  * Don't send reply
1390*9e564957SAndroid Build Coastguard Worker  *
1391*9e564957SAndroid Build Coastguard Worker  * Possible requests:
1392*9e564957SAndroid Build Coastguard Worker  *   forget
1393*9e564957SAndroid Build Coastguard Worker  *   forget_multi
1394*9e564957SAndroid Build Coastguard Worker  *   retrieve_reply
1395*9e564957SAndroid Build Coastguard Worker  *
1396*9e564957SAndroid Build Coastguard Worker  * @param req request handle
1397*9e564957SAndroid Build Coastguard Worker  */
1398*9e564957SAndroid Build Coastguard Worker void fuse_reply_none(fuse_req_t req);
1399*9e564957SAndroid Build Coastguard Worker 
1400*9e564957SAndroid Build Coastguard Worker /**
1401*9e564957SAndroid Build Coastguard Worker  * Reply with a directory entry
1402*9e564957SAndroid Build Coastguard Worker  *
1403*9e564957SAndroid Build Coastguard Worker  * Possible requests:
1404*9e564957SAndroid Build Coastguard Worker  *   lookup, mknod, mkdir, symlink, link
1405*9e564957SAndroid Build Coastguard Worker  *
1406*9e564957SAndroid Build Coastguard Worker  * Side effects:
1407*9e564957SAndroid Build Coastguard Worker  *   increments the lookup count on success
1408*9e564957SAndroid Build Coastguard Worker  *
1409*9e564957SAndroid Build Coastguard Worker  * @param req request handle
1410*9e564957SAndroid Build Coastguard Worker  * @param e the entry parameters
1411*9e564957SAndroid Build Coastguard Worker  * @return zero for success, -errno for failure to send reply
1412*9e564957SAndroid Build Coastguard Worker  */
1413*9e564957SAndroid Build Coastguard Worker int fuse_reply_entry(fuse_req_t req, const struct fuse_entry_param *e);
1414*9e564957SAndroid Build Coastguard Worker 
1415*9e564957SAndroid Build Coastguard Worker /**
1416*9e564957SAndroid Build Coastguard Worker  * Reply with a directory entry and open parameters
1417*9e564957SAndroid Build Coastguard Worker  *
1418*9e564957SAndroid Build Coastguard Worker  * currently the following members of 'fi' are used:
1419*9e564957SAndroid Build Coastguard Worker  *   fh, direct_io, keep_cache
1420*9e564957SAndroid Build Coastguard Worker  *
1421*9e564957SAndroid Build Coastguard Worker  * Possible requests:
1422*9e564957SAndroid Build Coastguard Worker  *   create
1423*9e564957SAndroid Build Coastguard Worker  *
1424*9e564957SAndroid Build Coastguard Worker  * Side effects:
1425*9e564957SAndroid Build Coastguard Worker  *   increments the lookup count on success
1426*9e564957SAndroid Build Coastguard Worker  *
1427*9e564957SAndroid Build Coastguard Worker  * @param req request handle
1428*9e564957SAndroid Build Coastguard Worker  * @param e the entry parameters
1429*9e564957SAndroid Build Coastguard Worker  * @param fi file information
1430*9e564957SAndroid Build Coastguard Worker  * @return zero for success, -errno for failure to send reply
1431*9e564957SAndroid Build Coastguard Worker  */
1432*9e564957SAndroid Build Coastguard Worker int fuse_reply_create(fuse_req_t req, const struct fuse_entry_param *e,
1433*9e564957SAndroid Build Coastguard Worker 		      const struct fuse_file_info *fi);
1434*9e564957SAndroid Build Coastguard Worker 
1435*9e564957SAndroid Build Coastguard Worker /**
1436*9e564957SAndroid Build Coastguard Worker  * Reply with attributes
1437*9e564957SAndroid Build Coastguard Worker  *
1438*9e564957SAndroid Build Coastguard Worker  * Possible requests:
1439*9e564957SAndroid Build Coastguard Worker  *   getattr, setattr
1440*9e564957SAndroid Build Coastguard Worker  *
1441*9e564957SAndroid Build Coastguard Worker  * @param req request handle
1442*9e564957SAndroid Build Coastguard Worker  * @param attr the attributes
1443*9e564957SAndroid Build Coastguard Worker  * @param attr_timeout	validity timeout (in seconds) for the attributes
1444*9e564957SAndroid Build Coastguard Worker  * @return zero for success, -errno for failure to send reply
1445*9e564957SAndroid Build Coastguard Worker  */
1446*9e564957SAndroid Build Coastguard Worker int fuse_reply_attr(fuse_req_t req, const struct stat *attr,
1447*9e564957SAndroid Build Coastguard Worker 		    double attr_timeout);
1448*9e564957SAndroid Build Coastguard Worker 
1449*9e564957SAndroid Build Coastguard Worker /**
1450*9e564957SAndroid Build Coastguard Worker  * Reply with the contents of a symbolic link
1451*9e564957SAndroid Build Coastguard Worker  *
1452*9e564957SAndroid Build Coastguard Worker  * Possible requests:
1453*9e564957SAndroid Build Coastguard Worker  *   readlink
1454*9e564957SAndroid Build Coastguard Worker  *
1455*9e564957SAndroid Build Coastguard Worker  * @param req request handle
1456*9e564957SAndroid Build Coastguard Worker  * @param link symbolic link contents
1457*9e564957SAndroid Build Coastguard Worker  * @return zero for success, -errno for failure to send reply
1458*9e564957SAndroid Build Coastguard Worker  */
1459*9e564957SAndroid Build Coastguard Worker int fuse_reply_readlink(fuse_req_t req, const char *link);
1460*9e564957SAndroid Build Coastguard Worker 
1461*9e564957SAndroid Build Coastguard Worker int fuse_passthrough_enable(fuse_req_t req, unsigned int fd);
1462*9e564957SAndroid Build Coastguard Worker 
1463*9e564957SAndroid Build Coastguard Worker /**
1464*9e564957SAndroid Build Coastguard Worker  * Reply with the canonical path for inotify
1465*9e564957SAndroid Build Coastguard Worker  *
1466*9e564957SAndroid Build Coastguard Worker  * Possible requests:
1467*9e564957SAndroid Build Coastguard Worker  *   canonical_path
1468*9e564957SAndroid Build Coastguard Worker  *
1469*9e564957SAndroid Build Coastguard Worker  * @param req request handle
1470*9e564957SAndroid Build Coastguard Worker  * @param path to canonicalize
1471*9e564957SAndroid Build Coastguard Worker  * @return zero for success, -errno for failure to send reply
1472*9e564957SAndroid Build Coastguard Worker  */
1473*9e564957SAndroid Build Coastguard Worker int fuse_reply_canonical_path(fuse_req_t req, const char *path);
1474*9e564957SAndroid Build Coastguard Worker 
1475*9e564957SAndroid Build Coastguard Worker /**
1476*9e564957SAndroid Build Coastguard Worker  * Setup passthrough backing file for open reply
1477*9e564957SAndroid Build Coastguard Worker  *
1478*9e564957SAndroid Build Coastguard Worker  * Possible requests:
1479*9e564957SAndroid Build Coastguard Worker  *   open, opendir, create
1480*9e564957SAndroid Build Coastguard Worker  *
1481*9e564957SAndroid Build Coastguard Worker  * @param req request handle
1482*9e564957SAndroid Build Coastguard Worker  * @param fd backing file descriptor
1483*9e564957SAndroid Build Coastguard Worker  * @return positive backing id for success, 0 for failure
1484*9e564957SAndroid Build Coastguard Worker  */
1485*9e564957SAndroid Build Coastguard Worker int fuse_passthrough_open(fuse_req_t req, int fd);
1486*9e564957SAndroid Build Coastguard Worker int fuse_passthrough_close(fuse_req_t req, int backing_id);
1487*9e564957SAndroid Build Coastguard Worker 
1488*9e564957SAndroid Build Coastguard Worker /**
1489*9e564957SAndroid Build Coastguard Worker  * Reply with open parameters
1490*9e564957SAndroid Build Coastguard Worker  *
1491*9e564957SAndroid Build Coastguard Worker  * currently the following members of 'fi' are used:
1492*9e564957SAndroid Build Coastguard Worker  *   fh, direct_io, keep_cache
1493*9e564957SAndroid Build Coastguard Worker  *
1494*9e564957SAndroid Build Coastguard Worker  * Possible requests:
1495*9e564957SAndroid Build Coastguard Worker  *   open, opendir
1496*9e564957SAndroid Build Coastguard Worker  *
1497*9e564957SAndroid Build Coastguard Worker  * @param req request handle
1498*9e564957SAndroid Build Coastguard Worker  * @param fi file information
1499*9e564957SAndroid Build Coastguard Worker  * @return zero for success, -errno for failure to send reply
1500*9e564957SAndroid Build Coastguard Worker  */
1501*9e564957SAndroid Build Coastguard Worker int fuse_reply_open(fuse_req_t req, const struct fuse_file_info *fi);
1502*9e564957SAndroid Build Coastguard Worker 
1503*9e564957SAndroid Build Coastguard Worker /**
1504*9e564957SAndroid Build Coastguard Worker  * Reply with number of bytes written
1505*9e564957SAndroid Build Coastguard Worker  *
1506*9e564957SAndroid Build Coastguard Worker  * Possible requests:
1507*9e564957SAndroid Build Coastguard Worker  *   write
1508*9e564957SAndroid Build Coastguard Worker  *
1509*9e564957SAndroid Build Coastguard Worker  * @param req request handle
1510*9e564957SAndroid Build Coastguard Worker  * @param count the number of bytes written
1511*9e564957SAndroid Build Coastguard Worker  * @return zero for success, -errno for failure to send reply
1512*9e564957SAndroid Build Coastguard Worker  */
1513*9e564957SAndroid Build Coastguard Worker int fuse_reply_write(fuse_req_t req, size_t count);
1514*9e564957SAndroid Build Coastguard Worker 
1515*9e564957SAndroid Build Coastguard Worker /**
1516*9e564957SAndroid Build Coastguard Worker  * Reply with data
1517*9e564957SAndroid Build Coastguard Worker  *
1518*9e564957SAndroid Build Coastguard Worker  * Possible requests:
1519*9e564957SAndroid Build Coastguard Worker  *   read, readdir, getxattr, listxattr
1520*9e564957SAndroid Build Coastguard Worker  *
1521*9e564957SAndroid Build Coastguard Worker  * @param req request handle
1522*9e564957SAndroid Build Coastguard Worker  * @param buf buffer containing data
1523*9e564957SAndroid Build Coastguard Worker  * @param size the size of data in bytes
1524*9e564957SAndroid Build Coastguard Worker  * @return zero for success, -errno for failure to send reply
1525*9e564957SAndroid Build Coastguard Worker  */
1526*9e564957SAndroid Build Coastguard Worker int fuse_reply_buf(fuse_req_t req, const char *buf, size_t size);
1527*9e564957SAndroid Build Coastguard Worker 
1528*9e564957SAndroid Build Coastguard Worker /**
1529*9e564957SAndroid Build Coastguard Worker  * Reply with data copied/moved from buffer(s)
1530*9e564957SAndroid Build Coastguard Worker  *
1531*9e564957SAndroid Build Coastguard Worker  * Zero copy data transfer ("splicing") will be used under
1532*9e564957SAndroid Build Coastguard Worker  * the following circumstances:
1533*9e564957SAndroid Build Coastguard Worker  *
1534*9e564957SAndroid Build Coastguard Worker  * 1. FUSE_CAP_SPLICE_WRITE is set in fuse_conn_info.want, and
1535*9e564957SAndroid Build Coastguard Worker  * 2. the kernel supports splicing from the fuse device
1536*9e564957SAndroid Build Coastguard Worker  *    (FUSE_CAP_SPLICE_WRITE is set in fuse_conn_info.capable), and
1537*9e564957SAndroid Build Coastguard Worker  * 3. *flags* does not contain FUSE_BUF_NO_SPLICE
1538*9e564957SAndroid Build Coastguard Worker  * 4. The amount of data that is provided in file-descriptor backed
1539*9e564957SAndroid Build Coastguard Worker  *    buffers (i.e., buffers for which bufv[n].flags == FUSE_BUF_FD)
1540*9e564957SAndroid Build Coastguard Worker  *    is at least twice the page size.
1541*9e564957SAndroid Build Coastguard Worker  *
1542*9e564957SAndroid Build Coastguard Worker  * In order for SPLICE_F_MOVE to be used, the following additional
1543*9e564957SAndroid Build Coastguard Worker  * conditions have to be fulfilled:
1544*9e564957SAndroid Build Coastguard Worker  *
1545*9e564957SAndroid Build Coastguard Worker  * 1. FUSE_CAP_SPLICE_MOVE is set in fuse_conn_info.want, and
1546*9e564957SAndroid Build Coastguard Worker  * 2. the kernel supports it (i.e, FUSE_CAP_SPLICE_MOVE is set in
1547*9e564957SAndroid Build Coastguard Worker       fuse_conn_info.capable), and
1548*9e564957SAndroid Build Coastguard Worker  * 3. *flags* contains FUSE_BUF_SPLICE_MOVE
1549*9e564957SAndroid Build Coastguard Worker  *
1550*9e564957SAndroid Build Coastguard Worker  * Note that, if splice is used, the data is actually spliced twice:
1551*9e564957SAndroid Build Coastguard Worker  * once into a temporary pipe (to prepend header data), and then again
1552*9e564957SAndroid Build Coastguard Worker  * into the kernel. If some of the provided buffers are memory-backed,
1553*9e564957SAndroid Build Coastguard Worker  * the data in them is copied in step one and spliced in step two.
1554*9e564957SAndroid Build Coastguard Worker  *
1555*9e564957SAndroid Build Coastguard Worker  * The FUSE_BUF_SPLICE_FORCE_SPLICE and FUSE_BUF_SPLICE_NONBLOCK flags
1556*9e564957SAndroid Build Coastguard Worker  * are silently ignored.
1557*9e564957SAndroid Build Coastguard Worker  *
1558*9e564957SAndroid Build Coastguard Worker  * Possible requests:
1559*9e564957SAndroid Build Coastguard Worker  *   read, readdir, getxattr, listxattr
1560*9e564957SAndroid Build Coastguard Worker  *
1561*9e564957SAndroid Build Coastguard Worker  * Side effects:
1562*9e564957SAndroid Build Coastguard Worker  *   when used to return data from a readdirplus() (but not readdir())
1563*9e564957SAndroid Build Coastguard Worker  *   call, increments the lookup count of each returned entry by one
1564*9e564957SAndroid Build Coastguard Worker  *   on success.
1565*9e564957SAndroid Build Coastguard Worker  *
1566*9e564957SAndroid Build Coastguard Worker  * @param req request handle
1567*9e564957SAndroid Build Coastguard Worker  * @param bufv buffer vector
1568*9e564957SAndroid Build Coastguard Worker  * @param flags flags controlling the copy
1569*9e564957SAndroid Build Coastguard Worker  * @return zero for success, -errno for failure to send reply
1570*9e564957SAndroid Build Coastguard Worker  */
1571*9e564957SAndroid Build Coastguard Worker int fuse_reply_data(fuse_req_t req, struct fuse_bufvec *bufv,
1572*9e564957SAndroid Build Coastguard Worker 		    enum fuse_buf_copy_flags flags);
1573*9e564957SAndroid Build Coastguard Worker 
1574*9e564957SAndroid Build Coastguard Worker /**
1575*9e564957SAndroid Build Coastguard Worker  * Reply with data vector
1576*9e564957SAndroid Build Coastguard Worker  *
1577*9e564957SAndroid Build Coastguard Worker  * Possible requests:
1578*9e564957SAndroid Build Coastguard Worker  *   read, readdir, getxattr, listxattr
1579*9e564957SAndroid Build Coastguard Worker  *
1580*9e564957SAndroid Build Coastguard Worker  * @param req request handle
1581*9e564957SAndroid Build Coastguard Worker  * @param iov the vector containing the data
1582*9e564957SAndroid Build Coastguard Worker  * @param count the size of vector
1583*9e564957SAndroid Build Coastguard Worker  * @return zero for success, -errno for failure to send reply
1584*9e564957SAndroid Build Coastguard Worker  */
1585*9e564957SAndroid Build Coastguard Worker int fuse_reply_iov(fuse_req_t req, const struct iovec *iov, int count);
1586*9e564957SAndroid Build Coastguard Worker 
1587*9e564957SAndroid Build Coastguard Worker /**
1588*9e564957SAndroid Build Coastguard Worker  * Reply with filesystem statistics
1589*9e564957SAndroid Build Coastguard Worker  *
1590*9e564957SAndroid Build Coastguard Worker  * Possible requests:
1591*9e564957SAndroid Build Coastguard Worker  *   statfs
1592*9e564957SAndroid Build Coastguard Worker  *
1593*9e564957SAndroid Build Coastguard Worker  * @param req request handle
1594*9e564957SAndroid Build Coastguard Worker  * @param stbuf filesystem statistics
1595*9e564957SAndroid Build Coastguard Worker  * @return zero for success, -errno for failure to send reply
1596*9e564957SAndroid Build Coastguard Worker  */
1597*9e564957SAndroid Build Coastguard Worker int fuse_reply_statfs(fuse_req_t req, const struct statvfs *stbuf);
1598*9e564957SAndroid Build Coastguard Worker 
1599*9e564957SAndroid Build Coastguard Worker /**
1600*9e564957SAndroid Build Coastguard Worker  * Reply with needed buffer size
1601*9e564957SAndroid Build Coastguard Worker  *
1602*9e564957SAndroid Build Coastguard Worker  * Possible requests:
1603*9e564957SAndroid Build Coastguard Worker  *   getxattr, listxattr
1604*9e564957SAndroid Build Coastguard Worker  *
1605*9e564957SAndroid Build Coastguard Worker  * @param req request handle
1606*9e564957SAndroid Build Coastguard Worker  * @param count the buffer size needed in bytes
1607*9e564957SAndroid Build Coastguard Worker  * @return zero for success, -errno for failure to send reply
1608*9e564957SAndroid Build Coastguard Worker  */
1609*9e564957SAndroid Build Coastguard Worker int fuse_reply_xattr(fuse_req_t req, size_t count);
1610*9e564957SAndroid Build Coastguard Worker 
1611*9e564957SAndroid Build Coastguard Worker /**
1612*9e564957SAndroid Build Coastguard Worker  * Reply with file lock information
1613*9e564957SAndroid Build Coastguard Worker  *
1614*9e564957SAndroid Build Coastguard Worker  * Possible requests:
1615*9e564957SAndroid Build Coastguard Worker  *   getlk
1616*9e564957SAndroid Build Coastguard Worker  *
1617*9e564957SAndroid Build Coastguard Worker  * @param req request handle
1618*9e564957SAndroid Build Coastguard Worker  * @param lock the lock information
1619*9e564957SAndroid Build Coastguard Worker  * @return zero for success, -errno for failure to send reply
1620*9e564957SAndroid Build Coastguard Worker  */
1621*9e564957SAndroid Build Coastguard Worker int fuse_reply_lock(fuse_req_t req, const struct flock *lock);
1622*9e564957SAndroid Build Coastguard Worker 
1623*9e564957SAndroid Build Coastguard Worker /**
1624*9e564957SAndroid Build Coastguard Worker  * Reply with block index
1625*9e564957SAndroid Build Coastguard Worker  *
1626*9e564957SAndroid Build Coastguard Worker  * Possible requests:
1627*9e564957SAndroid Build Coastguard Worker  *   bmap
1628*9e564957SAndroid Build Coastguard Worker  *
1629*9e564957SAndroid Build Coastguard Worker  * @param req request handle
1630*9e564957SAndroid Build Coastguard Worker  * @param idx block index within device
1631*9e564957SAndroid Build Coastguard Worker  * @return zero for success, -errno for failure to send reply
1632*9e564957SAndroid Build Coastguard Worker  */
1633*9e564957SAndroid Build Coastguard Worker int fuse_reply_bmap(fuse_req_t req, uint64_t idx);
1634*9e564957SAndroid Build Coastguard Worker 
1635*9e564957SAndroid Build Coastguard Worker /* ----------------------------------------------------------- *
1636*9e564957SAndroid Build Coastguard Worker  * Filling a buffer in readdir				       *
1637*9e564957SAndroid Build Coastguard Worker  * ----------------------------------------------------------- */
1638*9e564957SAndroid Build Coastguard Worker 
1639*9e564957SAndroid Build Coastguard Worker /**
1640*9e564957SAndroid Build Coastguard Worker  * Add a directory entry to the buffer
1641*9e564957SAndroid Build Coastguard Worker  *
1642*9e564957SAndroid Build Coastguard Worker  * Buffer needs to be large enough to hold the entry.  If it's not,
1643*9e564957SAndroid Build Coastguard Worker  * then the entry is not filled in but the size of the entry is still
1644*9e564957SAndroid Build Coastguard Worker  * returned.  The caller can check this by comparing the bufsize
1645*9e564957SAndroid Build Coastguard Worker  * parameter with the returned entry size.  If the entry size is
1646*9e564957SAndroid Build Coastguard Worker  * larger than the buffer size, the operation failed.
1647*9e564957SAndroid Build Coastguard Worker  *
1648*9e564957SAndroid Build Coastguard Worker  * From the 'stbuf' argument the st_ino field and bits 12-15 of the
1649*9e564957SAndroid Build Coastguard Worker  * st_mode field are used.  The other fields are ignored.
1650*9e564957SAndroid Build Coastguard Worker  *
1651*9e564957SAndroid Build Coastguard Worker  * *off* should be any non-zero value that the filesystem can use to
1652*9e564957SAndroid Build Coastguard Worker  * identify the current point in the directory stream. It does not
1653*9e564957SAndroid Build Coastguard Worker  * need to be the actual physical position. A value of zero is
1654*9e564957SAndroid Build Coastguard Worker  * reserved to mean "from the beginning", and should therefore never
1655*9e564957SAndroid Build Coastguard Worker  * be used (the first call to fuse_add_direntry should be passed the
1656*9e564957SAndroid Build Coastguard Worker  * offset of the second directory entry).
1657*9e564957SAndroid Build Coastguard Worker  *
1658*9e564957SAndroid Build Coastguard Worker  * @param req request handle
1659*9e564957SAndroid Build Coastguard Worker  * @param buf the point where the new entry will be added to the buffer
1660*9e564957SAndroid Build Coastguard Worker  * @param bufsize remaining size of the buffer
1661*9e564957SAndroid Build Coastguard Worker  * @param name the name of the entry
1662*9e564957SAndroid Build Coastguard Worker  * @param stbuf the file attributes
1663*9e564957SAndroid Build Coastguard Worker  * @param off the offset of the next entry
1664*9e564957SAndroid Build Coastguard Worker  * @return the space needed for the entry
1665*9e564957SAndroid Build Coastguard Worker  */
1666*9e564957SAndroid Build Coastguard Worker size_t fuse_add_direntry(fuse_req_t req, char *buf, size_t bufsize,
1667*9e564957SAndroid Build Coastguard Worker 			 const char *name, const struct stat *stbuf,
1668*9e564957SAndroid Build Coastguard Worker 			 off_t off);
1669*9e564957SAndroid Build Coastguard Worker 
1670*9e564957SAndroid Build Coastguard Worker /**
1671*9e564957SAndroid Build Coastguard Worker  * Add a directory entry to the buffer with the attributes
1672*9e564957SAndroid Build Coastguard Worker  *
1673*9e564957SAndroid Build Coastguard Worker  * See documentation of `fuse_add_direntry()` for more details.
1674*9e564957SAndroid Build Coastguard Worker  *
1675*9e564957SAndroid Build Coastguard Worker  * @param req request handle
1676*9e564957SAndroid Build Coastguard Worker  * @param buf the point where the new entry will be added to the buffer
1677*9e564957SAndroid Build Coastguard Worker  * @param bufsize remaining size of the buffer
1678*9e564957SAndroid Build Coastguard Worker  * @param name the name of the entry
1679*9e564957SAndroid Build Coastguard Worker  * @param e the directory entry
1680*9e564957SAndroid Build Coastguard Worker  * @param off the offset of the next entry
1681*9e564957SAndroid Build Coastguard Worker  * @return the space needed for the entry
1682*9e564957SAndroid Build Coastguard Worker  */
1683*9e564957SAndroid Build Coastguard Worker size_t fuse_add_direntry_plus(fuse_req_t req, char *buf, size_t bufsize,
1684*9e564957SAndroid Build Coastguard Worker 			      const char *name,
1685*9e564957SAndroid Build Coastguard Worker 			      const struct fuse_entry_param *e, off_t off);
1686*9e564957SAndroid Build Coastguard Worker 
1687*9e564957SAndroid Build Coastguard Worker /**
1688*9e564957SAndroid Build Coastguard Worker  * Reply to ask for data fetch and output buffer preparation.  ioctl
1689*9e564957SAndroid Build Coastguard Worker  * will be retried with the specified input data fetched and output
1690*9e564957SAndroid Build Coastguard Worker  * buffer prepared.
1691*9e564957SAndroid Build Coastguard Worker  *
1692*9e564957SAndroid Build Coastguard Worker  * Possible requests:
1693*9e564957SAndroid Build Coastguard Worker  *   ioctl
1694*9e564957SAndroid Build Coastguard Worker  *
1695*9e564957SAndroid Build Coastguard Worker  * @param req request handle
1696*9e564957SAndroid Build Coastguard Worker  * @param in_iov iovec specifying data to fetch from the caller
1697*9e564957SAndroid Build Coastguard Worker  * @param in_count number of entries in in_iov
1698*9e564957SAndroid Build Coastguard Worker  * @param out_iov iovec specifying addresses to write output to
1699*9e564957SAndroid Build Coastguard Worker  * @param out_count number of entries in out_iov
1700*9e564957SAndroid Build Coastguard Worker  * @return zero for success, -errno for failure to send reply
1701*9e564957SAndroid Build Coastguard Worker  */
1702*9e564957SAndroid Build Coastguard Worker int fuse_reply_ioctl_retry(fuse_req_t req,
1703*9e564957SAndroid Build Coastguard Worker 			   const struct iovec *in_iov, size_t in_count,
1704*9e564957SAndroid Build Coastguard Worker 			   const struct iovec *out_iov, size_t out_count);
1705*9e564957SAndroid Build Coastguard Worker 
1706*9e564957SAndroid Build Coastguard Worker /**
1707*9e564957SAndroid Build Coastguard Worker  * Reply to finish ioctl
1708*9e564957SAndroid Build Coastguard Worker  *
1709*9e564957SAndroid Build Coastguard Worker  * Possible requests:
1710*9e564957SAndroid Build Coastguard Worker  *   ioctl
1711*9e564957SAndroid Build Coastguard Worker  *
1712*9e564957SAndroid Build Coastguard Worker  * @param req request handle
1713*9e564957SAndroid Build Coastguard Worker  * @param result result to be passed to the caller
1714*9e564957SAndroid Build Coastguard Worker  * @param buf buffer containing output data
1715*9e564957SAndroid Build Coastguard Worker  * @param size length of output data
1716*9e564957SAndroid Build Coastguard Worker  */
1717*9e564957SAndroid Build Coastguard Worker int fuse_reply_ioctl(fuse_req_t req, int result, const void *buf, size_t size);
1718*9e564957SAndroid Build Coastguard Worker 
1719*9e564957SAndroid Build Coastguard Worker /**
1720*9e564957SAndroid Build Coastguard Worker  * Reply to finish ioctl with iov buffer
1721*9e564957SAndroid Build Coastguard Worker  *
1722*9e564957SAndroid Build Coastguard Worker  * Possible requests:
1723*9e564957SAndroid Build Coastguard Worker  *   ioctl
1724*9e564957SAndroid Build Coastguard Worker  *
1725*9e564957SAndroid Build Coastguard Worker  * @param req request handle
1726*9e564957SAndroid Build Coastguard Worker  * @param result result to be passed to the caller
1727*9e564957SAndroid Build Coastguard Worker  * @param iov the vector containing the data
1728*9e564957SAndroid Build Coastguard Worker  * @param count the size of vector
1729*9e564957SAndroid Build Coastguard Worker  */
1730*9e564957SAndroid Build Coastguard Worker int fuse_reply_ioctl_iov(fuse_req_t req, int result, const struct iovec *iov,
1731*9e564957SAndroid Build Coastguard Worker 			 int count);
1732*9e564957SAndroid Build Coastguard Worker 
1733*9e564957SAndroid Build Coastguard Worker /**
1734*9e564957SAndroid Build Coastguard Worker  * Reply with poll result event mask
1735*9e564957SAndroid Build Coastguard Worker  *
1736*9e564957SAndroid Build Coastguard Worker  * @param req request handle
1737*9e564957SAndroid Build Coastguard Worker  * @param revents poll result event mask
1738*9e564957SAndroid Build Coastguard Worker  */
1739*9e564957SAndroid Build Coastguard Worker int fuse_reply_poll(fuse_req_t req, unsigned revents);
1740*9e564957SAndroid Build Coastguard Worker 
1741*9e564957SAndroid Build Coastguard Worker /**
1742*9e564957SAndroid Build Coastguard Worker  * Reply with offset
1743*9e564957SAndroid Build Coastguard Worker  *
1744*9e564957SAndroid Build Coastguard Worker  * Possible requests:
1745*9e564957SAndroid Build Coastguard Worker  *   lseek
1746*9e564957SAndroid Build Coastguard Worker  *
1747*9e564957SAndroid Build Coastguard Worker  * @param req request handle
1748*9e564957SAndroid Build Coastguard Worker  * @param off offset of next data or hole
1749*9e564957SAndroid Build Coastguard Worker  * @return zero for success, -errno for failure to send reply
1750*9e564957SAndroid Build Coastguard Worker  */
1751*9e564957SAndroid Build Coastguard Worker int fuse_reply_lseek(fuse_req_t req, off_t off);
1752*9e564957SAndroid Build Coastguard Worker 
1753*9e564957SAndroid Build Coastguard Worker /* ----------------------------------------------------------- *
1754*9e564957SAndroid Build Coastguard Worker  * Notification						       *
1755*9e564957SAndroid Build Coastguard Worker  * ----------------------------------------------------------- */
1756*9e564957SAndroid Build Coastguard Worker 
1757*9e564957SAndroid Build Coastguard Worker /**
1758*9e564957SAndroid Build Coastguard Worker  * Notify IO readiness event
1759*9e564957SAndroid Build Coastguard Worker  *
1760*9e564957SAndroid Build Coastguard Worker  * For more information, please read comment for poll operation.
1761*9e564957SAndroid Build Coastguard Worker  *
1762*9e564957SAndroid Build Coastguard Worker  * @param ph poll handle to notify IO readiness event for
1763*9e564957SAndroid Build Coastguard Worker  */
1764*9e564957SAndroid Build Coastguard Worker int fuse_lowlevel_notify_poll(struct fuse_pollhandle *ph);
1765*9e564957SAndroid Build Coastguard Worker 
1766*9e564957SAndroid Build Coastguard Worker /**
1767*9e564957SAndroid Build Coastguard Worker  * Notify to invalidate cache for an inode.
1768*9e564957SAndroid Build Coastguard Worker  *
1769*9e564957SAndroid Build Coastguard Worker  * Added in FUSE protocol version 7.12. If the kernel does not support
1770*9e564957SAndroid Build Coastguard Worker  * this (or a newer) version, the function will return -ENOSYS and do
1771*9e564957SAndroid Build Coastguard Worker  * nothing.
1772*9e564957SAndroid Build Coastguard Worker  *
1773*9e564957SAndroid Build Coastguard Worker  * If the filesystem has writeback caching enabled, invalidating an
1774*9e564957SAndroid Build Coastguard Worker  * inode will first trigger a writeback of all dirty pages. The call
1775*9e564957SAndroid Build Coastguard Worker  * will block until all writeback requests have completed and the
1776*9e564957SAndroid Build Coastguard Worker  * inode has been invalidated. It will, however, not wait for
1777*9e564957SAndroid Build Coastguard Worker  * completion of pending writeback requests that have been issued
1778*9e564957SAndroid Build Coastguard Worker  * before.
1779*9e564957SAndroid Build Coastguard Worker  *
1780*9e564957SAndroid Build Coastguard Worker  * If there are no dirty pages, this function will never block.
1781*9e564957SAndroid Build Coastguard Worker  *
1782*9e564957SAndroid Build Coastguard Worker  * @param se the session object
1783*9e564957SAndroid Build Coastguard Worker  * @param ino the inode number
1784*9e564957SAndroid Build Coastguard Worker  * @param off the offset in the inode where to start invalidating
1785*9e564957SAndroid Build Coastguard Worker  *            or negative to invalidate attributes only
1786*9e564957SAndroid Build Coastguard Worker  * @param len the amount of cache to invalidate or 0 for all
1787*9e564957SAndroid Build Coastguard Worker  * @return zero for success, -errno for failure
1788*9e564957SAndroid Build Coastguard Worker  */
1789*9e564957SAndroid Build Coastguard Worker int fuse_lowlevel_notify_inval_inode(struct fuse_session *se, fuse_ino_t ino,
1790*9e564957SAndroid Build Coastguard Worker 				     off_t off, off_t len);
1791*9e564957SAndroid Build Coastguard Worker 
1792*9e564957SAndroid Build Coastguard Worker /**
1793*9e564957SAndroid Build Coastguard Worker  * Notify to invalidate parent attributes and the dentry matching parent/name
1794*9e564957SAndroid Build Coastguard Worker  *
1795*9e564957SAndroid Build Coastguard Worker  * To avoid a deadlock this function must not be called in the
1796*9e564957SAndroid Build Coastguard Worker  * execution path of a related filesystem operation or within any code
1797*9e564957SAndroid Build Coastguard Worker  * that could hold a lock that could be needed to execute such an
1798*9e564957SAndroid Build Coastguard Worker  * operation. As of kernel 4.18, a "related operation" is a lookup(),
1799*9e564957SAndroid Build Coastguard Worker  * symlink(), mknod(), mkdir(), unlink(), rename(), link() or create()
1800*9e564957SAndroid Build Coastguard Worker  * request for the parent, and a setattr(), unlink(), rmdir(),
1801*9e564957SAndroid Build Coastguard Worker  * rename(), setxattr(), removexattr(), readdir() or readdirplus()
1802*9e564957SAndroid Build Coastguard Worker  * request for the inode itself.
1803*9e564957SAndroid Build Coastguard Worker  *
1804*9e564957SAndroid Build Coastguard Worker  * When called correctly, this function will never block.
1805*9e564957SAndroid Build Coastguard Worker  *
1806*9e564957SAndroid Build Coastguard Worker  * Added in FUSE protocol version 7.12. If the kernel does not support
1807*9e564957SAndroid Build Coastguard Worker  * this (or a newer) version, the function will return -ENOSYS and do
1808*9e564957SAndroid Build Coastguard Worker  * nothing.
1809*9e564957SAndroid Build Coastguard Worker  *
1810*9e564957SAndroid Build Coastguard Worker  * @param se the session object
1811*9e564957SAndroid Build Coastguard Worker  * @param parent inode number
1812*9e564957SAndroid Build Coastguard Worker  * @param name file name
1813*9e564957SAndroid Build Coastguard Worker  * @param namelen strlen() of file name
1814*9e564957SAndroid Build Coastguard Worker  * @return zero for success, -errno for failure
1815*9e564957SAndroid Build Coastguard Worker  */
1816*9e564957SAndroid Build Coastguard Worker int fuse_lowlevel_notify_inval_entry(struct fuse_session *se, fuse_ino_t parent,
1817*9e564957SAndroid Build Coastguard Worker 				     const char *name, size_t namelen);
1818*9e564957SAndroid Build Coastguard Worker 
1819*9e564957SAndroid Build Coastguard Worker /**
1820*9e564957SAndroid Build Coastguard Worker  * Notify to expire parent attributes and the dentry matching parent/name
1821*9e564957SAndroid Build Coastguard Worker  *
1822*9e564957SAndroid Build Coastguard Worker  * Same restrictions apply as for fuse_lowlevel_notify_inval_entry()
1823*9e564957SAndroid Build Coastguard Worker  *
1824*9e564957SAndroid Build Coastguard Worker  * Compared to invalidating an entry, expiring the entry results not in a
1825*9e564957SAndroid Build Coastguard Worker  * forceful removal of that entry from kernel cache but instead the next access
1826*9e564957SAndroid Build Coastguard Worker  * to it forces a lookup from the filesystem.
1827*9e564957SAndroid Build Coastguard Worker  *
1828*9e564957SAndroid Build Coastguard Worker  * This makes a difference for overmounted dentries, where plain invalidation
1829*9e564957SAndroid Build Coastguard Worker  * would detach all submounts before dropping the dentry from the cache.
1830*9e564957SAndroid Build Coastguard Worker  * If only expiry is set on the dentry, then any overmounts are left alone and
1831*9e564957SAndroid Build Coastguard Worker  * until ->d_revalidate() is called.
1832*9e564957SAndroid Build Coastguard Worker  *
1833*9e564957SAndroid Build Coastguard Worker  * Note: ->d_revalidate() is not called for the case of following a submount,
1834*9e564957SAndroid Build Coastguard Worker  * so invalidation will only be triggered for the non-overmounted case.
1835*9e564957SAndroid Build Coastguard Worker  * The dentry could also be mounted in a different mount instance, in which case
1836*9e564957SAndroid Build Coastguard Worker  * any submounts will still be detached.
1837*9e564957SAndroid Build Coastguard Worker  *
1838*9e564957SAndroid Build Coastguard Worker  * Added in FUSE protocol version 7.38. If the kernel does not support
1839*9e564957SAndroid Build Coastguard Worker  * this (or a newer) version, the function will return -ENOSYS and do nothing.
1840*9e564957SAndroid Build Coastguard Worker  *
1841*9e564957SAndroid Build Coastguard Worker  * @param se the session object
1842*9e564957SAndroid Build Coastguard Worker  * @param parent inode number
1843*9e564957SAndroid Build Coastguard Worker  * @param name file name
1844*9e564957SAndroid Build Coastguard Worker  * @param namelen strlen() of file name
1845*9e564957SAndroid Build Coastguard Worker  * @return zero for success, -errno for failure, -enosys if no kernel support
1846*9e564957SAndroid Build Coastguard Worker */
1847*9e564957SAndroid Build Coastguard Worker int fuse_lowlevel_notify_expire_entry(struct fuse_session *se, fuse_ino_t parent,
1848*9e564957SAndroid Build Coastguard Worker                                       const char *name, size_t namelen);
1849*9e564957SAndroid Build Coastguard Worker 
1850*9e564957SAndroid Build Coastguard Worker /**
1851*9e564957SAndroid Build Coastguard Worker  * This function behaves like fuse_lowlevel_notify_inval_entry() with
1852*9e564957SAndroid Build Coastguard Worker  * the following additional effect (at least as of Linux kernel 4.8):
1853*9e564957SAndroid Build Coastguard Worker  *
1854*9e564957SAndroid Build Coastguard Worker  * If the provided *child* inode matches the inode that is currently
1855*9e564957SAndroid Build Coastguard Worker  * associated with the cached dentry, and if there are any inotify
1856*9e564957SAndroid Build Coastguard Worker  * watches registered for the dentry, then the watchers are informed
1857*9e564957SAndroid Build Coastguard Worker  * that the dentry has been deleted.
1858*9e564957SAndroid Build Coastguard Worker  *
1859*9e564957SAndroid Build Coastguard Worker  * To avoid a deadlock this function must not be called while
1860*9e564957SAndroid Build Coastguard Worker  * executing a related filesystem operation or while holding a lock
1861*9e564957SAndroid Build Coastguard Worker  * that could be needed to execute such an operation (see the
1862*9e564957SAndroid Build Coastguard Worker  * description of fuse_lowlevel_notify_inval_entry() for more
1863*9e564957SAndroid Build Coastguard Worker  * details).
1864*9e564957SAndroid Build Coastguard Worker  *
1865*9e564957SAndroid Build Coastguard Worker  * When called correctly, this function will never block.
1866*9e564957SAndroid Build Coastguard Worker  *
1867*9e564957SAndroid Build Coastguard Worker  * Added in FUSE protocol version 7.18. If the kernel does not support
1868*9e564957SAndroid Build Coastguard Worker  * this (or a newer) version, the function will return -ENOSYS and do
1869*9e564957SAndroid Build Coastguard Worker  * nothing.
1870*9e564957SAndroid Build Coastguard Worker  *
1871*9e564957SAndroid Build Coastguard Worker  * @param se the session object
1872*9e564957SAndroid Build Coastguard Worker  * @param parent inode number
1873*9e564957SAndroid Build Coastguard Worker  * @param child inode number
1874*9e564957SAndroid Build Coastguard Worker  * @param name file name
1875*9e564957SAndroid Build Coastguard Worker  * @param namelen strlen() of file name
1876*9e564957SAndroid Build Coastguard Worker  * @return zero for success, -errno for failure
1877*9e564957SAndroid Build Coastguard Worker  */
1878*9e564957SAndroid Build Coastguard Worker int fuse_lowlevel_notify_delete(struct fuse_session *se,
1879*9e564957SAndroid Build Coastguard Worker 				fuse_ino_t parent, fuse_ino_t child,
1880*9e564957SAndroid Build Coastguard Worker 				const char *name, size_t namelen);
1881*9e564957SAndroid Build Coastguard Worker 
1882*9e564957SAndroid Build Coastguard Worker /**
1883*9e564957SAndroid Build Coastguard Worker  * Store data to the kernel buffers
1884*9e564957SAndroid Build Coastguard Worker  *
1885*9e564957SAndroid Build Coastguard Worker  * Synchronously store data in the kernel buffers belonging to the
1886*9e564957SAndroid Build Coastguard Worker  * given inode.  The stored data is marked up-to-date (no read will be
1887*9e564957SAndroid Build Coastguard Worker  * performed against it, unless it's invalidated or evicted from the
1888*9e564957SAndroid Build Coastguard Worker  * cache).
1889*9e564957SAndroid Build Coastguard Worker  *
1890*9e564957SAndroid Build Coastguard Worker  * If the stored data overflows the current file size, then the size
1891*9e564957SAndroid Build Coastguard Worker  * is extended, similarly to a write(2) on the filesystem.
1892*9e564957SAndroid Build Coastguard Worker  *
1893*9e564957SAndroid Build Coastguard Worker  * If this function returns an error, then the store wasn't fully
1894*9e564957SAndroid Build Coastguard Worker  * completed, but it may have been partially completed.
1895*9e564957SAndroid Build Coastguard Worker  *
1896*9e564957SAndroid Build Coastguard Worker  * Added in FUSE protocol version 7.15. If the kernel does not support
1897*9e564957SAndroid Build Coastguard Worker  * this (or a newer) version, the function will return -ENOSYS and do
1898*9e564957SAndroid Build Coastguard Worker  * nothing.
1899*9e564957SAndroid Build Coastguard Worker  *
1900*9e564957SAndroid Build Coastguard Worker  * @param se the session object
1901*9e564957SAndroid Build Coastguard Worker  * @param ino the inode number
1902*9e564957SAndroid Build Coastguard Worker  * @param offset the starting offset into the file to store to
1903*9e564957SAndroid Build Coastguard Worker  * @param bufv buffer vector
1904*9e564957SAndroid Build Coastguard Worker  * @param flags flags controlling the copy
1905*9e564957SAndroid Build Coastguard Worker  * @return zero for success, -errno for failure
1906*9e564957SAndroid Build Coastguard Worker  */
1907*9e564957SAndroid Build Coastguard Worker int fuse_lowlevel_notify_store(struct fuse_session *se, fuse_ino_t ino,
1908*9e564957SAndroid Build Coastguard Worker 			       off_t offset, struct fuse_bufvec *bufv,
1909*9e564957SAndroid Build Coastguard Worker 			       enum fuse_buf_copy_flags flags);
1910*9e564957SAndroid Build Coastguard Worker /**
1911*9e564957SAndroid Build Coastguard Worker  * Retrieve data from the kernel buffers
1912*9e564957SAndroid Build Coastguard Worker  *
1913*9e564957SAndroid Build Coastguard Worker  * Retrieve data in the kernel buffers belonging to the given inode.
1914*9e564957SAndroid Build Coastguard Worker  * If successful then the retrieve_reply() method will be called with
1915*9e564957SAndroid Build Coastguard Worker  * the returned data.
1916*9e564957SAndroid Build Coastguard Worker  *
1917*9e564957SAndroid Build Coastguard Worker  * Only present pages are returned in the retrieve reply.  Retrieving
1918*9e564957SAndroid Build Coastguard Worker  * stops when it finds a non-present page and only data prior to that
1919*9e564957SAndroid Build Coastguard Worker  * is returned.
1920*9e564957SAndroid Build Coastguard Worker  *
1921*9e564957SAndroid Build Coastguard Worker  * If this function returns an error, then the retrieve will not be
1922*9e564957SAndroid Build Coastguard Worker  * completed and no reply will be sent.
1923*9e564957SAndroid Build Coastguard Worker  *
1924*9e564957SAndroid Build Coastguard Worker  * This function doesn't change the dirty state of pages in the kernel
1925*9e564957SAndroid Build Coastguard Worker  * buffer.  For dirty pages the write() method will be called
1926*9e564957SAndroid Build Coastguard Worker  * regardless of having been retrieved previously.
1927*9e564957SAndroid Build Coastguard Worker  *
1928*9e564957SAndroid Build Coastguard Worker  * Added in FUSE protocol version 7.15. If the kernel does not support
1929*9e564957SAndroid Build Coastguard Worker  * this (or a newer) version, the function will return -ENOSYS and do
1930*9e564957SAndroid Build Coastguard Worker  * nothing.
1931*9e564957SAndroid Build Coastguard Worker  *
1932*9e564957SAndroid Build Coastguard Worker  * @param se the session object
1933*9e564957SAndroid Build Coastguard Worker  * @param ino the inode number
1934*9e564957SAndroid Build Coastguard Worker  * @param size the number of bytes to retrieve
1935*9e564957SAndroid Build Coastguard Worker  * @param offset the starting offset into the file to retrieve from
1936*9e564957SAndroid Build Coastguard Worker  * @param cookie user data to supply to the reply callback
1937*9e564957SAndroid Build Coastguard Worker  * @return zero for success, -errno for failure
1938*9e564957SAndroid Build Coastguard Worker  */
1939*9e564957SAndroid Build Coastguard Worker int fuse_lowlevel_notify_retrieve(struct fuse_session *se, fuse_ino_t ino,
1940*9e564957SAndroid Build Coastguard Worker 				  size_t size, off_t offset, void *cookie);
1941*9e564957SAndroid Build Coastguard Worker 
1942*9e564957SAndroid Build Coastguard Worker 
1943*9e564957SAndroid Build Coastguard Worker /* ----------------------------------------------------------- *
1944*9e564957SAndroid Build Coastguard Worker  * Utility functions					       *
1945*9e564957SAndroid Build Coastguard Worker  * ----------------------------------------------------------- */
1946*9e564957SAndroid Build Coastguard Worker 
1947*9e564957SAndroid Build Coastguard Worker /**
1948*9e564957SAndroid Build Coastguard Worker  * Get the userdata from the request
1949*9e564957SAndroid Build Coastguard Worker  *
1950*9e564957SAndroid Build Coastguard Worker  * @param req request handle
1951*9e564957SAndroid Build Coastguard Worker  * @return the user data passed to fuse_session_new()
1952*9e564957SAndroid Build Coastguard Worker  */
1953*9e564957SAndroid Build Coastguard Worker void *fuse_req_userdata(fuse_req_t req);
1954*9e564957SAndroid Build Coastguard Worker 
1955*9e564957SAndroid Build Coastguard Worker /**
1956*9e564957SAndroid Build Coastguard Worker  * Get the context from the request
1957*9e564957SAndroid Build Coastguard Worker  *
1958*9e564957SAndroid Build Coastguard Worker  * The pointer returned by this function will only be valid for the
1959*9e564957SAndroid Build Coastguard Worker  * request's lifetime
1960*9e564957SAndroid Build Coastguard Worker  *
1961*9e564957SAndroid Build Coastguard Worker  * @param req request handle
1962*9e564957SAndroid Build Coastguard Worker  * @return the context structure
1963*9e564957SAndroid Build Coastguard Worker  */
1964*9e564957SAndroid Build Coastguard Worker const struct fuse_ctx *fuse_req_ctx(fuse_req_t req);
1965*9e564957SAndroid Build Coastguard Worker 
1966*9e564957SAndroid Build Coastguard Worker /**
1967*9e564957SAndroid Build Coastguard Worker  * Get the current supplementary group IDs for the specified request
1968*9e564957SAndroid Build Coastguard Worker  *
1969*9e564957SAndroid Build Coastguard Worker  * Similar to the getgroups(2) system call, except the return value is
1970*9e564957SAndroid Build Coastguard Worker  * always the total number of group IDs, even if it is larger than the
1971*9e564957SAndroid Build Coastguard Worker  * specified size.
1972*9e564957SAndroid Build Coastguard Worker  *
1973*9e564957SAndroid Build Coastguard Worker  * The current fuse kernel module in linux (as of 2.6.30) doesn't pass
1974*9e564957SAndroid Build Coastguard Worker  * the group list to userspace, hence this function needs to parse
1975*9e564957SAndroid Build Coastguard Worker  * "/proc/$TID/task/$TID/status" to get the group IDs.
1976*9e564957SAndroid Build Coastguard Worker  *
1977*9e564957SAndroid Build Coastguard Worker  * This feature may not be supported on all operating systems.  In
1978*9e564957SAndroid Build Coastguard Worker  * such a case this function will return -ENOSYS.
1979*9e564957SAndroid Build Coastguard Worker  *
1980*9e564957SAndroid Build Coastguard Worker  * @param req request handle
1981*9e564957SAndroid Build Coastguard Worker  * @param size size of given array
1982*9e564957SAndroid Build Coastguard Worker  * @param list array of group IDs to be filled in
1983*9e564957SAndroid Build Coastguard Worker  * @return the total number of supplementary group IDs or -errno on failure
1984*9e564957SAndroid Build Coastguard Worker  */
1985*9e564957SAndroid Build Coastguard Worker int fuse_req_getgroups(fuse_req_t req, int size, gid_t list[]);
1986*9e564957SAndroid Build Coastguard Worker 
1987*9e564957SAndroid Build Coastguard Worker /**
1988*9e564957SAndroid Build Coastguard Worker  * Callback function for an interrupt
1989*9e564957SAndroid Build Coastguard Worker  *
1990*9e564957SAndroid Build Coastguard Worker  * @param req interrupted request
1991*9e564957SAndroid Build Coastguard Worker  * @param data user data
1992*9e564957SAndroid Build Coastguard Worker  */
1993*9e564957SAndroid Build Coastguard Worker typedef void (*fuse_interrupt_func_t)(fuse_req_t req, void *data);
1994*9e564957SAndroid Build Coastguard Worker 
1995*9e564957SAndroid Build Coastguard Worker /**
1996*9e564957SAndroid Build Coastguard Worker  * Register/unregister callback for an interrupt
1997*9e564957SAndroid Build Coastguard Worker  *
1998*9e564957SAndroid Build Coastguard Worker  * If an interrupt has already happened, then the callback function is
1999*9e564957SAndroid Build Coastguard Worker  * called from within this function, hence it's not possible for
2000*9e564957SAndroid Build Coastguard Worker  * interrupts to be lost.
2001*9e564957SAndroid Build Coastguard Worker  *
2002*9e564957SAndroid Build Coastguard Worker  * @param req request handle
2003*9e564957SAndroid Build Coastguard Worker  * @param func the callback function or NULL for unregister
2004*9e564957SAndroid Build Coastguard Worker  * @param data user data passed to the callback function
2005*9e564957SAndroid Build Coastguard Worker  */
2006*9e564957SAndroid Build Coastguard Worker void fuse_req_interrupt_func(fuse_req_t req, fuse_interrupt_func_t func,
2007*9e564957SAndroid Build Coastguard Worker 			     void *data);
2008*9e564957SAndroid Build Coastguard Worker 
2009*9e564957SAndroid Build Coastguard Worker /**
2010*9e564957SAndroid Build Coastguard Worker  * Check if a request has already been interrupted
2011*9e564957SAndroid Build Coastguard Worker  *
2012*9e564957SAndroid Build Coastguard Worker  * @param req request handle
2013*9e564957SAndroid Build Coastguard Worker  * @return 1 if the request has been interrupted, 0 otherwise
2014*9e564957SAndroid Build Coastguard Worker  */
2015*9e564957SAndroid Build Coastguard Worker int fuse_req_interrupted(fuse_req_t req);
2016*9e564957SAndroid Build Coastguard Worker 
2017*9e564957SAndroid Build Coastguard Worker 
2018*9e564957SAndroid Build Coastguard Worker /* ----------------------------------------------------------- *
2019*9e564957SAndroid Build Coastguard Worker  * Inquiry functions                                           *
2020*9e564957SAndroid Build Coastguard Worker  * ----------------------------------------------------------- */
2021*9e564957SAndroid Build Coastguard Worker 
2022*9e564957SAndroid Build Coastguard Worker /**
2023*9e564957SAndroid Build Coastguard Worker  * Print low-level version information to stdout.
2024*9e564957SAndroid Build Coastguard Worker  */
2025*9e564957SAndroid Build Coastguard Worker void fuse_lowlevel_version(void);
2026*9e564957SAndroid Build Coastguard Worker 
2027*9e564957SAndroid Build Coastguard Worker /**
2028*9e564957SAndroid Build Coastguard Worker  * Print available low-level options to stdout. This is not an
2029*9e564957SAndroid Build Coastguard Worker  * exhaustive list, but includes only those options that may be of
2030*9e564957SAndroid Build Coastguard Worker  * interest to an end-user of a file system.
2031*9e564957SAndroid Build Coastguard Worker  */
2032*9e564957SAndroid Build Coastguard Worker void fuse_lowlevel_help(void);
2033*9e564957SAndroid Build Coastguard Worker 
2034*9e564957SAndroid Build Coastguard Worker /**
2035*9e564957SAndroid Build Coastguard Worker  * Print available options for `fuse_parse_cmdline()`.
2036*9e564957SAndroid Build Coastguard Worker  */
2037*9e564957SAndroid Build Coastguard Worker void fuse_cmdline_help(void);
2038*9e564957SAndroid Build Coastguard Worker 
2039*9e564957SAndroid Build Coastguard Worker /* ----------------------------------------------------------- *
2040*9e564957SAndroid Build Coastguard Worker  * Filesystem setup & teardown                                 *
2041*9e564957SAndroid Build Coastguard Worker  * ----------------------------------------------------------- */
2042*9e564957SAndroid Build Coastguard Worker 
2043*9e564957SAndroid Build Coastguard Worker /**
2044*9e564957SAndroid Build Coastguard Worker  * Note: Any addition to this struct needs to create a compatibility symbol
2045*9e564957SAndroid Build Coastguard Worker  *       for fuse_parse_cmdline(). For ABI compatibility reasons it is also
2046*9e564957SAndroid Build Coastguard Worker  *       not possible to remove struct members.
2047*9e564957SAndroid Build Coastguard Worker  */
2048*9e564957SAndroid Build Coastguard Worker struct fuse_cmdline_opts {
2049*9e564957SAndroid Build Coastguard Worker 	int singlethread;
2050*9e564957SAndroid Build Coastguard Worker 	int foreground;
2051*9e564957SAndroid Build Coastguard Worker 	int debug;
2052*9e564957SAndroid Build Coastguard Worker 	int nodefault_subtype;
2053*9e564957SAndroid Build Coastguard Worker 	char *mountpoint;
2054*9e564957SAndroid Build Coastguard Worker 	int show_version;
2055*9e564957SAndroid Build Coastguard Worker 	int show_help;
2056*9e564957SAndroid Build Coastguard Worker 	int clone_fd;
2057*9e564957SAndroid Build Coastguard Worker 	unsigned int max_idle_threads; /* discouraged, due to thread
2058*9e564957SAndroid Build Coastguard Worker 	                                * destruct overhead */
2059*9e564957SAndroid Build Coastguard Worker 
2060*9e564957SAndroid Build Coastguard Worker 	/* Added in libfuse-3.12 */
2061*9e564957SAndroid Build Coastguard Worker 	unsigned int max_threads;
2062*9e564957SAndroid Build Coastguard Worker };
2063*9e564957SAndroid Build Coastguard Worker 
2064*9e564957SAndroid Build Coastguard Worker /**
2065*9e564957SAndroid Build Coastguard Worker  * Utility function to parse common options for simple file systems
2066*9e564957SAndroid Build Coastguard Worker  * using the low-level API. A help text that describes the available
2067*9e564957SAndroid Build Coastguard Worker  * options can be printed with `fuse_cmdline_help`. A single
2068*9e564957SAndroid Build Coastguard Worker  * non-option argument is treated as the mountpoint. Multiple
2069*9e564957SAndroid Build Coastguard Worker  * non-option arguments will result in an error.
2070*9e564957SAndroid Build Coastguard Worker  *
2071*9e564957SAndroid Build Coastguard Worker  * If neither -o subtype= or -o fsname= options are given, a new
2072*9e564957SAndroid Build Coastguard Worker  * subtype option will be added and set to the basename of the program
2073*9e564957SAndroid Build Coastguard Worker  * (the fsname will remain unset, and then defaults to "fuse").
2074*9e564957SAndroid Build Coastguard Worker  *
2075*9e564957SAndroid Build Coastguard Worker  * Known options will be removed from *args*, unknown options will
2076*9e564957SAndroid Build Coastguard Worker  * remain.
2077*9e564957SAndroid Build Coastguard Worker  *
2078*9e564957SAndroid Build Coastguard Worker  * @param args argument vector (input+output)
2079*9e564957SAndroid Build Coastguard Worker  * @param opts output argument for parsed options
2080*9e564957SAndroid Build Coastguard Worker  * @return 0 on success, -1 on failure
2081*9e564957SAndroid Build Coastguard Worker  */
2082*9e564957SAndroid Build Coastguard Worker #if (defined(LIBFUSE_BUILT_WITH_VERSIONED_SYMBOLS))
2083*9e564957SAndroid Build Coastguard Worker int fuse_parse_cmdline(struct fuse_args *args,
2084*9e564957SAndroid Build Coastguard Worker 		       struct fuse_cmdline_opts *opts);
2085*9e564957SAndroid Build Coastguard Worker #else
2086*9e564957SAndroid Build Coastguard Worker #if FUSE_USE_VERSION < FUSE_MAKE_VERSION(3, 12)
2087*9e564957SAndroid Build Coastguard Worker int fuse_parse_cmdline_30(struct fuse_args *args,
2088*9e564957SAndroid Build Coastguard Worker 			   struct fuse_cmdline_opts *opts);
2089*9e564957SAndroid Build Coastguard Worker #define fuse_parse_cmdline(args, opts) fuse_parse_cmdline_30(args, opts)
2090*9e564957SAndroid Build Coastguard Worker #else
2091*9e564957SAndroid Build Coastguard Worker int fuse_parse_cmdline_312(struct fuse_args *args,
2092*9e564957SAndroid Build Coastguard Worker 			   struct fuse_cmdline_opts *opts);
2093*9e564957SAndroid Build Coastguard Worker #define fuse_parse_cmdline(args, opts) fuse_parse_cmdline_312(args, opts)
2094*9e564957SAndroid Build Coastguard Worker #endif
2095*9e564957SAndroid Build Coastguard Worker #endif
2096*9e564957SAndroid Build Coastguard Worker 
2097*9e564957SAndroid Build Coastguard Worker /*
2098*9e564957SAndroid Build Coastguard Worker  * This should mostly not be called directly, but instead the fuse_session_new()
2099*9e564957SAndroid Build Coastguard Worker  * macro should be used, which fills in the libfuse version compilation
2100*9e564957SAndroid Build Coastguard Worker  * is done against automatically.
2101*9e564957SAndroid Build Coastguard Worker  */
2102*9e564957SAndroid Build Coastguard Worker struct fuse_session *_fuse_session_new_317(struct fuse_args *args,
2103*9e564957SAndroid Build Coastguard Worker 					  const struct fuse_lowlevel_ops *op,
2104*9e564957SAndroid Build Coastguard Worker 					  size_t op_size,
2105*9e564957SAndroid Build Coastguard Worker 					  struct libfuse_version *version,
2106*9e564957SAndroid Build Coastguard Worker 					  void *userdata);
2107*9e564957SAndroid Build Coastguard Worker 
2108*9e564957SAndroid Build Coastguard Worker /* Do not call this directly, but only through fuse_session_new() */
2109*9e564957SAndroid Build Coastguard Worker #if (defined(LIBFUSE_BUILT_WITH_VERSIONED_SYMBOLS))
2110*9e564957SAndroid Build Coastguard Worker struct fuse_session *
2111*9e564957SAndroid Build Coastguard Worker _fuse_session_new(struct fuse_args *args,
2112*9e564957SAndroid Build Coastguard Worker 		 const struct fuse_lowlevel_ops *op,
2113*9e564957SAndroid Build Coastguard Worker 		 size_t op_size,
2114*9e564957SAndroid Build Coastguard Worker 		 struct libfuse_version *version,
2115*9e564957SAndroid Build Coastguard Worker 		 void *userdata);
2116*9e564957SAndroid Build Coastguard Worker #else
2117*9e564957SAndroid Build Coastguard Worker struct fuse_session *
2118*9e564957SAndroid Build Coastguard Worker _fuse_session_new_317(struct fuse_args *args,
2119*9e564957SAndroid Build Coastguard Worker 		      const struct fuse_lowlevel_ops *op,
2120*9e564957SAndroid Build Coastguard Worker 		      size_t op_size,
2121*9e564957SAndroid Build Coastguard Worker 		      struct libfuse_version *version,
2122*9e564957SAndroid Build Coastguard Worker 		      void *userdata);
2123*9e564957SAndroid Build Coastguard Worker #define _fuse_session_new(args, op, op_size, version, userdata)	\
2124*9e564957SAndroid Build Coastguard Worker 	_fuse_session_new_317(args, op, op_size, version, userdata)
2125*9e564957SAndroid Build Coastguard Worker #endif
2126*9e564957SAndroid Build Coastguard Worker 
2127*9e564957SAndroid Build Coastguard Worker /**
2128*9e564957SAndroid Build Coastguard Worker  * Create a low level session.
2129*9e564957SAndroid Build Coastguard Worker  *
2130*9e564957SAndroid Build Coastguard Worker  * Returns a session structure suitable for passing to
2131*9e564957SAndroid Build Coastguard Worker  * fuse_session_mount() and fuse_session_loop().
2132*9e564957SAndroid Build Coastguard Worker  *
2133*9e564957SAndroid Build Coastguard Worker  * This function accepts most file-system independent mount options
2134*9e564957SAndroid Build Coastguard Worker  * (like context, nodev, ro - see mount(8)), as well as the general
2135*9e564957SAndroid Build Coastguard Worker  * fuse mount options listed in mount.fuse(8) (e.g. -o allow_root and
2136*9e564957SAndroid Build Coastguard Worker  * -o default_permissions, but not ``-o use_ino``).  Instead of `-o
2137*9e564957SAndroid Build Coastguard Worker  * debug`, debugging may also enabled with `-d` or `--debug`.
2138*9e564957SAndroid Build Coastguard Worker  *
2139*9e564957SAndroid Build Coastguard Worker  * If not all options are known, an error message is written to stderr
2140*9e564957SAndroid Build Coastguard Worker  * and the function returns NULL.
2141*9e564957SAndroid Build Coastguard Worker  *
2142*9e564957SAndroid Build Coastguard Worker  * Option parsing skips argv[0], which is assumed to contain the
2143*9e564957SAndroid Build Coastguard Worker  * program name. To prevent accidentally passing an option in
2144*9e564957SAndroid Build Coastguard Worker  * argv[0], this element must always be present (even if no options
2145*9e564957SAndroid Build Coastguard Worker  * are specified). It may be set to the empty string ('\0') if no
2146*9e564957SAndroid Build Coastguard Worker  * reasonable value can be provided.
2147*9e564957SAndroid Build Coastguard Worker  *
2148*9e564957SAndroid Build Coastguard Worker  * @param args argument vector
2149*9e564957SAndroid Build Coastguard Worker  * @param op the (low-level) filesystem operations
2150*9e564957SAndroid Build Coastguard Worker  * @param op_size sizeof(struct fuse_lowlevel_ops)
2151*9e564957SAndroid Build Coastguard Worker  * @param version the libfuse version a file system server was compiled against
2152*9e564957SAndroid Build Coastguard Worker  * @param userdata user data
2153*9e564957SAndroid Build Coastguard Worker  * @return the fuse session on success, NULL on failure
2154*9e564957SAndroid Build Coastguard Worker  **/
2155*9e564957SAndroid Build Coastguard Worker static inline struct fuse_session *
fuse_session_new(struct fuse_args * args,const struct fuse_lowlevel_ops * op,size_t op_size,void * userdata)2156*9e564957SAndroid Build Coastguard Worker fuse_session_new(struct fuse_args *args,
2157*9e564957SAndroid Build Coastguard Worker 		 const struct fuse_lowlevel_ops *op,
2158*9e564957SAndroid Build Coastguard Worker 		 size_t op_size,
2159*9e564957SAndroid Build Coastguard Worker 		 void *userdata)
2160*9e564957SAndroid Build Coastguard Worker {
2161*9e564957SAndroid Build Coastguard Worker 	struct libfuse_version version = {
2162*9e564957SAndroid Build Coastguard Worker 		.major = FUSE_MAJOR_VERSION,
2163*9e564957SAndroid Build Coastguard Worker 		.minor = FUSE_MINOR_VERSION,
2164*9e564957SAndroid Build Coastguard Worker 		.hotfix = FUSE_HOTFIX_VERSION,
2165*9e564957SAndroid Build Coastguard Worker 		.padding = 0
2166*9e564957SAndroid Build Coastguard Worker 	};
2167*9e564957SAndroid Build Coastguard Worker 
2168*9e564957SAndroid Build Coastguard Worker 	return _fuse_session_new(args, op, op_size, &version, userdata);
2169*9e564957SAndroid Build Coastguard Worker }
2170*9e564957SAndroid Build Coastguard Worker 
2171*9e564957SAndroid Build Coastguard Worker /**
2172*9e564957SAndroid Build Coastguard Worker  * Set a file descriptor for the session.
2173*9e564957SAndroid Build Coastguard Worker  *
2174*9e564957SAndroid Build Coastguard Worker  * This function can be used if you want to have a custom communication
2175*9e564957SAndroid Build Coastguard Worker  * interface instead of using a mountpoint. In practice, this means that instead
2176*9e564957SAndroid Build Coastguard Worker  * of calling fuse_session_mount() and fuse_session_unmount(), one could call
2177*9e564957SAndroid Build Coastguard Worker  * fuse_session_custom_io() where fuse_session_mount() would have otherwise been
2178*9e564957SAndroid Build Coastguard Worker  * called.
2179*9e564957SAndroid Build Coastguard Worker  *
2180*9e564957SAndroid Build Coastguard Worker  * In `io`, implementations for read and writev MUST be provided. Otherwise -1
2181*9e564957SAndroid Build Coastguard Worker  * will be returned and `fd` will not be used. Implementations for `splice_send`
2182*9e564957SAndroid Build Coastguard Worker  * and `splice_receive` are optional. If they are not provided splice will not
2183*9e564957SAndroid Build Coastguard Worker  * be used for send or receive respectively.
2184*9e564957SAndroid Build Coastguard Worker  *
2185*9e564957SAndroid Build Coastguard Worker  * The provided file descriptor `fd` will be closed when fuse_session_destroy()
2186*9e564957SAndroid Build Coastguard Worker  * is called.
2187*9e564957SAndroid Build Coastguard Worker  *
2188*9e564957SAndroid Build Coastguard Worker  * @param se session object
2189*9e564957SAndroid Build Coastguard Worker  * @param io Custom io to use when retrieving/sending requests/responses
2190*9e564957SAndroid Build Coastguard Worker  * @param fd file descriptor for the session
2191*9e564957SAndroid Build Coastguard Worker  *
2192*9e564957SAndroid Build Coastguard Worker  * @return 0  on success
2193*9e564957SAndroid Build Coastguard Worker  * @return -EINVAL if `io`, `io->read` or `ìo->writev` are NULL
2194*9e564957SAndroid Build Coastguard Worker  * @return -EBADF  if `fd` was smaller than 0
2195*9e564957SAndroid Build Coastguard Worker  * @return -errno  if failed to allocate memory to store `io`
2196*9e564957SAndroid Build Coastguard Worker  *
2197*9e564957SAndroid Build Coastguard Worker  **/
2198*9e564957SAndroid Build Coastguard Worker int fuse_session_custom_io(struct fuse_session *se,
2199*9e564957SAndroid Build Coastguard Worker 				   const struct fuse_custom_io *io, int fd);
2200*9e564957SAndroid Build Coastguard Worker 
2201*9e564957SAndroid Build Coastguard Worker /**
2202*9e564957SAndroid Build Coastguard Worker  * Mount a FUSE file system.
2203*9e564957SAndroid Build Coastguard Worker  *
2204*9e564957SAndroid Build Coastguard Worker  * @param mountpoint the mount point path
2205*9e564957SAndroid Build Coastguard Worker  * @param se session object
2206*9e564957SAndroid Build Coastguard Worker  *
2207*9e564957SAndroid Build Coastguard Worker  * @return 0 on success, -1 on failure.
2208*9e564957SAndroid Build Coastguard Worker  **/
2209*9e564957SAndroid Build Coastguard Worker int fuse_session_mount(struct fuse_session *se, const char *mountpoint);
2210*9e564957SAndroid Build Coastguard Worker 
2211*9e564957SAndroid Build Coastguard Worker /**
2212*9e564957SAndroid Build Coastguard Worker  * Enter a single threaded, blocking event loop.
2213*9e564957SAndroid Build Coastguard Worker  *
2214*9e564957SAndroid Build Coastguard Worker  * When the event loop terminates because the connection to the FUSE
2215*9e564957SAndroid Build Coastguard Worker  * kernel module has been closed, this function returns zero. This
2216*9e564957SAndroid Build Coastguard Worker  * happens when the filesystem is unmounted regularly (by the
2217*9e564957SAndroid Build Coastguard Worker  * filesystem owner or root running the umount(8) or fusermount(1)
2218*9e564957SAndroid Build Coastguard Worker  * command), or if connection is explicitly severed by writing ``1``
2219*9e564957SAndroid Build Coastguard Worker  * to the``abort`` file in ``/sys/fs/fuse/connections/NNN``. The only
2220*9e564957SAndroid Build Coastguard Worker  * way to distinguish between these two conditions is to check if the
2221*9e564957SAndroid Build Coastguard Worker  * filesystem is still mounted after the session loop returns.
2222*9e564957SAndroid Build Coastguard Worker  *
2223*9e564957SAndroid Build Coastguard Worker  * When some error occurs during request processing, the function
2224*9e564957SAndroid Build Coastguard Worker  * returns a negated errno(3) value.
2225*9e564957SAndroid Build Coastguard Worker  *
2226*9e564957SAndroid Build Coastguard Worker  * If the loop has been terminated because of a signal handler
2227*9e564957SAndroid Build Coastguard Worker  * installed by fuse_set_signal_handlers(), this function returns the
2228*9e564957SAndroid Build Coastguard Worker  * (positive) signal value that triggered the exit.
2229*9e564957SAndroid Build Coastguard Worker  *
2230*9e564957SAndroid Build Coastguard Worker  * @param se the session
2231*9e564957SAndroid Build Coastguard Worker  * @return 0, -errno, or a signal value
2232*9e564957SAndroid Build Coastguard Worker  */
2233*9e564957SAndroid Build Coastguard Worker int fuse_session_loop(struct fuse_session *se);
2234*9e564957SAndroid Build Coastguard Worker 
2235*9e564957SAndroid Build Coastguard Worker #if FUSE_USE_VERSION < 32
2236*9e564957SAndroid Build Coastguard Worker 	int fuse_session_loop_mt_31(struct fuse_session *se, int clone_fd);
2237*9e564957SAndroid Build Coastguard Worker 	#define fuse_session_loop_mt(se, clone_fd) fuse_session_loop_mt_31(se, clone_fd)
2238*9e564957SAndroid Build Coastguard Worker #elif FUSE_USE_VERSION < FUSE_MAKE_VERSION(3, 12)
2239*9e564957SAndroid Build Coastguard Worker 	int fuse_session_loop_mt_32(struct fuse_session *se, struct fuse_loop_config *config);
2240*9e564957SAndroid Build Coastguard Worker 	#define fuse_session_loop_mt(se, config) fuse_session_loop_mt_32(se, config)
2241*9e564957SAndroid Build Coastguard Worker #else
2242*9e564957SAndroid Build Coastguard Worker 	#if (defined(LIBFUSE_BUILT_WITH_VERSIONED_SYMBOLS))
2243*9e564957SAndroid Build Coastguard Worker 		/**
2244*9e564957SAndroid Build Coastguard Worker 		 * Enter a multi-threaded event loop.
2245*9e564957SAndroid Build Coastguard Worker 		 *
2246*9e564957SAndroid Build Coastguard Worker 		 * For a description of the return value and the conditions when the
2247*9e564957SAndroid Build Coastguard Worker 		 * event loop exits, refer to the documentation of
2248*9e564957SAndroid Build Coastguard Worker 		 * fuse_session_loop().
2249*9e564957SAndroid Build Coastguard Worker 		 *
2250*9e564957SAndroid Build Coastguard Worker 		 * @param se the session
2251*9e564957SAndroid Build Coastguard Worker 		 * @param config session loop configuration
2252*9e564957SAndroid Build Coastguard Worker 		 * @return see fuse_session_loop()
2253*9e564957SAndroid Build Coastguard Worker 		 */
2254*9e564957SAndroid Build Coastguard Worker 		int fuse_session_loop_mt(struct fuse_session *se, struct fuse_loop_config *config);
2255*9e564957SAndroid Build Coastguard Worker 	#else
2256*9e564957SAndroid Build Coastguard Worker 		int fuse_session_loop_mt_312(struct fuse_session *se, struct fuse_loop_config *config);
2257*9e564957SAndroid Build Coastguard Worker 		#define fuse_session_loop_mt(se, config) fuse_session_loop_mt_312(se, config)
2258*9e564957SAndroid Build Coastguard Worker 	#endif
2259*9e564957SAndroid Build Coastguard Worker #endif
2260*9e564957SAndroid Build Coastguard Worker 
2261*9e564957SAndroid Build Coastguard Worker /**
2262*9e564957SAndroid Build Coastguard Worker  * Flag a session as terminated.
2263*9e564957SAndroid Build Coastguard Worker  *
2264*9e564957SAndroid Build Coastguard Worker  * This will cause any running event loops to terminate on the next opportunity. If this function is
2265*9e564957SAndroid Build Coastguard Worker  * called by a thread that is not a FUSE worker thread, the next
2266*9e564957SAndroid Build Coastguard Worker  * opportunity will be when FUSE a request is received (which may be far in the future if the
2267*9e564957SAndroid Build Coastguard Worker  * filesystem is not currently being used by any clients). One way to avoid this delay is to
2268*9e564957SAndroid Build Coastguard Worker  * afterwards sent a signal to the main thread (if fuse_set_signal_handlers() is used, SIGPIPE
2269*9e564957SAndroid Build Coastguard Worker  * will cause the main thread to wake-up but otherwise be ignored).
2270*9e564957SAndroid Build Coastguard Worker  *
2271*9e564957SAndroid Build Coastguard Worker  * @param se the session
2272*9e564957SAndroid Build Coastguard Worker  */
2273*9e564957SAndroid Build Coastguard Worker void fuse_session_exit(struct fuse_session *se);
2274*9e564957SAndroid Build Coastguard Worker 
2275*9e564957SAndroid Build Coastguard Worker /**
2276*9e564957SAndroid Build Coastguard Worker  * Reset the terminated flag of a session
2277*9e564957SAndroid Build Coastguard Worker  *
2278*9e564957SAndroid Build Coastguard Worker  * @param se the session
2279*9e564957SAndroid Build Coastguard Worker  */
2280*9e564957SAndroid Build Coastguard Worker void fuse_session_reset(struct fuse_session *se);
2281*9e564957SAndroid Build Coastguard Worker 
2282*9e564957SAndroid Build Coastguard Worker /**
2283*9e564957SAndroid Build Coastguard Worker  * Query the terminated flag of a session
2284*9e564957SAndroid Build Coastguard Worker  *
2285*9e564957SAndroid Build Coastguard Worker  * @param se the session
2286*9e564957SAndroid Build Coastguard Worker  * @return 1 if exited, 0 if not exited
2287*9e564957SAndroid Build Coastguard Worker  */
2288*9e564957SAndroid Build Coastguard Worker int fuse_session_exited(struct fuse_session *se);
2289*9e564957SAndroid Build Coastguard Worker 
2290*9e564957SAndroid Build Coastguard Worker /**
2291*9e564957SAndroid Build Coastguard Worker  * Ensure that file system is unmounted.
2292*9e564957SAndroid Build Coastguard Worker  *
2293*9e564957SAndroid Build Coastguard Worker  * In regular operation, the file system is typically unmounted by the
2294*9e564957SAndroid Build Coastguard Worker  * user calling umount(8) or fusermount(1), which then terminates the
2295*9e564957SAndroid Build Coastguard Worker  * FUSE session loop. However, the session loop may also terminate as
2296*9e564957SAndroid Build Coastguard Worker  * a result of an explicit call to fuse_session_exit() (e.g. by a
2297*9e564957SAndroid Build Coastguard Worker  * signal handler installed by fuse_set_signal_handler()). In this
2298*9e564957SAndroid Build Coastguard Worker  * case the filesystem remains mounted, but any attempt to access it
2299*9e564957SAndroid Build Coastguard Worker  * will block (while the filesystem process is still running) or give
2300*9e564957SAndroid Build Coastguard Worker  * an ESHUTDOWN error (after the filesystem process has terminated).
2301*9e564957SAndroid Build Coastguard Worker  *
2302*9e564957SAndroid Build Coastguard Worker  * If the communication channel with the FUSE kernel module is still
2303*9e564957SAndroid Build Coastguard Worker  * open (i.e., if the session loop was terminated by an explicit call
2304*9e564957SAndroid Build Coastguard Worker  * to fuse_session_exit()), this function will close it and unmount
2305*9e564957SAndroid Build Coastguard Worker  * the filesystem. If the communication channel has been closed by the
2306*9e564957SAndroid Build Coastguard Worker  * kernel, this method will do (almost) nothing.
2307*9e564957SAndroid Build Coastguard Worker  *
2308*9e564957SAndroid Build Coastguard Worker  * NOTE: The above semantics mean that if the connection to the kernel
2309*9e564957SAndroid Build Coastguard Worker  * is terminated via the ``/sys/fs/fuse/connections/NNN/abort`` file,
2310*9e564957SAndroid Build Coastguard Worker  * this method will *not* unmount the filesystem.
2311*9e564957SAndroid Build Coastguard Worker  *
2312*9e564957SAndroid Build Coastguard Worker  * @param se the session
2313*9e564957SAndroid Build Coastguard Worker  */
2314*9e564957SAndroid Build Coastguard Worker void fuse_session_unmount(struct fuse_session *se);
2315*9e564957SAndroid Build Coastguard Worker 
2316*9e564957SAndroid Build Coastguard Worker /**
2317*9e564957SAndroid Build Coastguard Worker  * Destroy a session
2318*9e564957SAndroid Build Coastguard Worker  *
2319*9e564957SAndroid Build Coastguard Worker  * @param se the session
2320*9e564957SAndroid Build Coastguard Worker  */
2321*9e564957SAndroid Build Coastguard Worker void fuse_session_destroy(struct fuse_session *se);
2322*9e564957SAndroid Build Coastguard Worker 
2323*9e564957SAndroid Build Coastguard Worker /* ----------------------------------------------------------- *
2324*9e564957SAndroid Build Coastguard Worker  * Custom event loop support                                   *
2325*9e564957SAndroid Build Coastguard Worker  * ----------------------------------------------------------- */
2326*9e564957SAndroid Build Coastguard Worker 
2327*9e564957SAndroid Build Coastguard Worker /**
2328*9e564957SAndroid Build Coastguard Worker  * Return file descriptor for communication with kernel.
2329*9e564957SAndroid Build Coastguard Worker  *
2330*9e564957SAndroid Build Coastguard Worker  * The file selector can be used to integrate FUSE with a custom event
2331*9e564957SAndroid Build Coastguard Worker  * loop. Whenever data is available for reading on the provided fd,
2332*9e564957SAndroid Build Coastguard Worker  * the event loop should call `fuse_session_receive_buf` followed by
2333*9e564957SAndroid Build Coastguard Worker  * `fuse_session_process_buf` to process the request.
2334*9e564957SAndroid Build Coastguard Worker  *
2335*9e564957SAndroid Build Coastguard Worker  * The returned file descriptor is valid until `fuse_session_unmount`
2336*9e564957SAndroid Build Coastguard Worker  * is called.
2337*9e564957SAndroid Build Coastguard Worker  *
2338*9e564957SAndroid Build Coastguard Worker  * @param se the session
2339*9e564957SAndroid Build Coastguard Worker  * @return a file descriptor
2340*9e564957SAndroid Build Coastguard Worker  */
2341*9e564957SAndroid Build Coastguard Worker int fuse_session_fd(struct fuse_session *se);
2342*9e564957SAndroid Build Coastguard Worker 
2343*9e564957SAndroid Build Coastguard Worker /**
2344*9e564957SAndroid Build Coastguard Worker  * Process a raw request supplied in a generic buffer
2345*9e564957SAndroid Build Coastguard Worker  *
2346*9e564957SAndroid Build Coastguard Worker  * The fuse_buf may contain a memory buffer or a pipe file descriptor.
2347*9e564957SAndroid Build Coastguard Worker  *
2348*9e564957SAndroid Build Coastguard Worker  * @param se the session
2349*9e564957SAndroid Build Coastguard Worker  * @param buf the fuse_buf containing the request
2350*9e564957SAndroid Build Coastguard Worker  */
2351*9e564957SAndroid Build Coastguard Worker void fuse_session_process_buf(struct fuse_session *se,
2352*9e564957SAndroid Build Coastguard Worker 			      const struct fuse_buf *buf);
2353*9e564957SAndroid Build Coastguard Worker 
2354*9e564957SAndroid Build Coastguard Worker /**
2355*9e564957SAndroid Build Coastguard Worker  * Read a raw request from the kernel into the supplied buffer.
2356*9e564957SAndroid Build Coastguard Worker  *
2357*9e564957SAndroid Build Coastguard Worker  * Depending on file system options, system capabilities, and request
2358*9e564957SAndroid Build Coastguard Worker  * size the request is either read into a memory buffer or spliced
2359*9e564957SAndroid Build Coastguard Worker  * into a temporary pipe.
2360*9e564957SAndroid Build Coastguard Worker  *
2361*9e564957SAndroid Build Coastguard Worker  * @param se the session
2362*9e564957SAndroid Build Coastguard Worker  * @param buf the fuse_buf to store the request in
2363*9e564957SAndroid Build Coastguard Worker  * @return the actual size of the raw request, or -errno on error
2364*9e564957SAndroid Build Coastguard Worker  */
2365*9e564957SAndroid Build Coastguard Worker int fuse_session_receive_buf(struct fuse_session *se, struct fuse_buf *buf);
2366*9e564957SAndroid Build Coastguard Worker 
2367*9e564957SAndroid Build Coastguard Worker #ifdef __cplusplus
2368*9e564957SAndroid Build Coastguard Worker }
2369*9e564957SAndroid Build Coastguard Worker #endif
2370*9e564957SAndroid Build Coastguard Worker 
2371*9e564957SAndroid Build Coastguard Worker #endif /* FUSE_LOWLEVEL_H_ */
2372