aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/fuse.h14
-rw-r--r--include/fuse_common.h28
-rw-r--r--include/fuse_lowlevel.h108
3 files changed, 101 insertions, 49 deletions
diff --git a/include/fuse.h b/include/fuse.h
index c3fea2d..719623a 100644
--- a/include/fuse.h
+++ b/include/fuse.h
@@ -608,8 +608,7 @@ struct fuse_context {
* main() function.
*
* This function does the following:
- * - parses command line options (-d -s and -h)
- * - passes relevant mount options to the fuse_mount()
+ * - parses command line options
* - installs signal handlers for INT, HUP, TERM and PIPE
* - registers an exit handler to unmount the filesystem on program exit
* - creates a fuse handle
@@ -640,14 +639,13 @@ struct fuse_context {
/**
* Create a new FUSE filesystem.
*
- * Known arguments are defined in `struct fuse_opt fuse_lib_opts[]`,
+ * Known options are defined in `struct fuse_opt fuse_lib_opts[]`,
* `struct fuse_opt fuse_mount_opts[]`, and `struct fuse_opt
- * fuse_ll_opts[]`. If there are any unknown arguments, an error
- * message will be printed to stderr and the function will return
- * NULL.
+ * fuse_ll_opts[]`. If not all options are known, an error message is
+ * written to stderr and the function returns NULL.
*
- * If the --help or --version parameters are specified, the function
- * prints the requested information to stdout and returns NULL.
+ * If the --help option is specified, the function writes a help text
+ * to stdout and returns NULL.
*
* @param args argument vector
* @param op the filesystem operations
diff --git a/include/fuse_common.h b/include/fuse_common.h
index f39dab3..f32c872 100644
--- a/include/fuse_common.h
+++ b/include/fuse_common.h
@@ -209,34 +209,6 @@ struct fuse_session;
struct fuse_pollhandle;
/**
- * Utility functions for simple file systems to parse common options.
- *
- * The following options are parsed:
- *
- * '-f' foreground
- * '-d' '-odebug' foreground, but keep the debug option
- * '-s' single threaded
- * '-h' '--help' help
- * '-ho' help without header
- * '-ofsname=..' file system name, if not present, then set to the program
- * name
- *
- * Unknown parameters in `args` are passed through unchanged. Known
- * parameters (with the exception of --help and --version) are removed.
- *
- * All parameters may be NULL (in which case they may still
- * be specified on the command line, but will not be set).
- *
- * @param args argument vector
- * @param mountpoint the returned mountpoint, should be freed after use
- * @param multithreaded set to 1 unless the '-s' option is present
- * @param foreground set to 1 if one of the relevant options is present
- * @return 0 on success, -1 on failure
- */
-int fuse_parse_cmdline(struct fuse_args *args, char **mountpoint,
- int *multithreaded, int *foreground);
-
-/**
* Go into the background
*
* @param foreground if true, stay in the foreground
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