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