diff options
Diffstat (limited to 'include/fuse_lowlevel.h')
-rw-r--r-- | include/fuse_lowlevel.h | 108 |
1 files changed, 95 insertions, 13 deletions
diff --git a/include/fuse_lowlevel.h b/include/fuse_lowlevel.h index f0f0e0b..f2d9caa 100644 --- a/include/fuse_lowlevel.h +++ b/include/fuse_lowlevel.h @@ -98,7 +98,14 @@ struct fuse_entry_param { double entry_timeout; }; -/** Additional context associated with requests */ +/** + * Additional context associated with requests. + * + * Note that the reported client uid, gid and pid may be zero in some + * situations. For example, if the FUSE file system is running in a + * PID or user namespace but then accessed from outside the namespace, + * there is no valid uid/pid/gid that could be reported. + */ struct fuse_ctx { /** User ID of the calling process */ uid_t uid; @@ -109,7 +116,7 @@ struct fuse_ctx { /** Thread ID of the calling process */ pid_t pid; - /** Umask of the calling process (introduced in version 2.8) */ + /** Umask of the calling process */ mode_t umask; }; @@ -1560,23 +1567,81 @@ void fuse_req_interrupt_func(fuse_req_t req, fuse_interrupt_func_t func, */ int fuse_req_interrupted(fuse_req_t req); + +/* ----------------------------------------------------------- * + * Inquiry functions * + * ----------------------------------------------------------- */ + +/** + * Print FUSE library version to stdout. + */ +void fuse_lowlevel_version(void); + +/** + * Print FUSE mount (fusermount) version stdout. + */ +void fuse_mount_version(void); + +/** + * Print available low-level options to stdout. + * These options may be passed to `fuse_session_new()` + */ +void fuse_lowlevel_help(void); + +/** + * Print available mount options to stdout. + * These options may be passed to `fuse_session_new()` + */ +void fuse_mount_help(void); + /* ----------------------------------------------------------- * * Filesystem setup & teardown * * ----------------------------------------------------------- */ +struct fuse_cmdline_opts { + int singlethread; + int foreground; + int debug; + int nodefault_subtype; + char *mountpoint; + int show_version; + int show_help; +}; + +/** + * Utility function to parse common options for simple file systems + * using the low-level API. Available options are listed in `struct + * fuse_opt fuse_helper_opts[]`. A single non-option argument is + * treated as the mountpoint. Multiple (or no) non-option arguments + * will result in an error. + * + * Unknown options are passed through unchanged. Known options (other + * than --debug, which is preserved) and the mountpoint argument are + * removed from *args*. + * + * If --help or --version is specified, the appropriate information is + * printed to stdout and the function proceeds normally. + * + * If neither -o subtype= or -o fsname= options are given, the subtype + * is set to the basename of the program (the fsname defaults to + * "fuse"). + * + * @param args argument vector (input+output) + * @param opts output argument for parsed options + * @return 0 on success, -1 on failure + */ +int fuse_parse_cmdline(struct fuse_args *args, + struct fuse_cmdline_opts *opts); + /** * Create a low level session. * * Returns a session structure suitable for passing to * fuse_session_mount() and fuse_session_loop(). * - * Known arguments are defined in `struct fuse_opt fuse_ll_opts[]` and - * `struct fuse_opt fuse_mount_opts[]`. If there are any unknown - * arguments, an error message will be printed to stderr and the - * function will return NULL. - * - * If the --help or --version parameters are specified, the function - * prints the requsted information to stdout and returns NULL. + * Known options are defined in `struct fuse_opt fuse_ll_opts[]` and + * `struct fuse_opt fuse_mount_opts[]`. If not all options are known, + * an error message is written to stderr and the function returns NULL. * * @param args argument vector * @param op the (low-level) filesystem operations @@ -1663,10 +1728,26 @@ void fuse_session_unmount(struct fuse_session *se); void fuse_session_destroy(struct fuse_session *se); /* ----------------------------------------------------------- * - * Request processing (for custom event loops) * + * Custom event loop support * * ----------------------------------------------------------- */ /** + * Return file descriptor for communication with kernel. + * + * The file selector can be used to integrate FUSE with a custom event + * loop. Whenever data is available for reading on the provided fd, + * the event loop should call `fuse_session_receive_buf` followed by + * `fuse_session_process_buf` to process the request. + * + * The returned file descriptor is valid until `fuse_session_unmount` + * is called. + * + * @param se the session + * @return a file descriptor + */ +int fuse_session_fd(struct fuse_session *se); + +/** * Process a raw request supplied in a generic buffer * * The fuse_buf may contain a memory buffer or a pipe file descriptor. @@ -1679,10 +1760,11 @@ void fuse_session_process_buf(struct fuse_session *se, const struct fuse_buf *buf); /** - * Receive a raw request supplied in a generic buffer + * Read a raw request from the kernel into the supplied buffer. * - * The fuse_buf supplied to this function contains a suitably allocated memory - * buffer. This may be overwritten with a file descriptor buffer. + * Depending on file system options, system capabilities, and request + * size the request is either read into a memory buffer or spliced + * into a temporary pipe. * * @param se the session * @param buf the fuse_buf to store the request in |