aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorGravatar Nikolaus Rath <Nikolaus@rath.org>2016-10-02 20:52:33 -0700
committerGravatar Nikolaus Rath <Nikolaus@rath.org>2016-10-02 21:09:37 -0700
commit425db842ff1155fcd3b40439fcd88248d45a5db7 (patch)
tree96615a1328c7a19b9c8c4c18d42fd6464cebe7f2 /include
parenta10ee045e76cec75f9d8c08f78f0acc994302305 (diff)
Don't handle --help and --version in fuse_session_new().
Help and version messages can be generated using the new fuse_lowlevel_help(), fuse_lowlevel_version(), fuse_mount_help(), and fuse_mount_version() functions. The fuse_parse_cmdline() function has been made more powerful to do this automatically, and is now explicitly intended only for low-level API users. This is a code simplication patch. We don't have to parse for --help and --version in quite as many places, and we no longer have a low-level initialization function be responsible for the (super-high level) task of printing a program usage message. In the high-level API, we can now handle the command line parsing earlier and avoid running other initialization code if we're just going to abort later on.
Diffstat (limited to 'include')
-rw-r--r--include/fuse_common.h28
-rw-r--r--include/fuse_lowlevel.h65
2 files changed, 62 insertions, 31 deletions
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 f90a052..0822e51 100644
--- a/include/fuse_lowlevel.h
+++ b/include/fuse_lowlevel.h
@@ -1560,10 +1560,72 @@ 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.
*
@@ -1574,9 +1636,6 @@ int fuse_req_interrupted(fuse_req_t req);
* `struct fuse_opt fuse_mount_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 requsted information to stdout and returns NULL.
- *
* @param args argument vector
* @param op the (low-level) filesystem operations
* @param op_size sizeof(struct fuse_lowlevel_ops)