Improve documentation of argument parsing.
authorNikolaus Rath <Nikolaus@rath.org>
Sat, 1 Oct 2016 18:24:46 +0000 (11:24 -0700)
committerNikolaus Rath <Nikolaus@rath.org>
Sat, 1 Oct 2016 18:24:46 +0000 (11:24 -0700)
include/fuse.h
include/fuse_common.h
include/fuse_lowlevel.h
lib/fuse.c
lib/fuse_lowlevel.c
lib/helper.c
lib/mount.c
lib/mount_bsd.c

index c70d2fee2a0765e8d4961ed484665c573861219c..5721caa9a0a25b83e57019a74aabb0e31dc51405 100644 (file)
@@ -640,6 +640,13 @@ struct fuse_context {
 /**
  * Create a new FUSE filesystem.
  *
+ * Known parameters in `args` are removed. If there are any unknown
+ * arguments, an error is printed 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.
+ *
  * @param ch the communication channel
  * @param args argument vector
  * @param op the filesystem operations
index 2fa99625425ae2a2f65b832a420f211e1d356a8d..df92e8e7e97aba23469ddca225ae1e2e571b058f 100644 (file)
@@ -213,7 +213,13 @@ struct fuse_pollhandle;
  * Create a FUSE mountpoint
  *
  * Returns a control file descriptor suitable for passing to
- * fuse_new()
+ * fuse_new(). Unknown parameters in `args` are passed through
+ * unchanged. Known parameters (with the exception of --help and
+ * --version) are removed from `args`.
+ *
+ * If the --help or --version parameters are specified, the function
+ * prints the requested information to stdout and returns a valid
+ * pointer. However, it does not actually perform the mount.
  *
  * @param mountpoint the mount point path
  * @param args argument vector
@@ -230,7 +236,7 @@ struct fuse_chan *fuse_mount(const char *mountpoint, struct fuse_args *args);
 void fuse_unmount(const char *mountpoint, struct fuse_chan *ch);
 
 /**
- * Parse common options
+ * Utility functions for simple file systems to parse common options.
  *
  * The following options are parsed:
  *
@@ -242,7 +248,11 @@ void fuse_unmount(const char *mountpoint, struct fuse_chan *ch);
  *   '-ofsname=..'   file system name, if not present, then set to the program
  *                  name
  *
- * All parameters may be NULL
+ * 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
index 2022cc6f7adc2ddeb30a6826b46d696a6befd775..ce3990602c09105fd03d4d34f3189a7962fb6e26 100644 (file)
@@ -1575,6 +1575,13 @@ int fuse_req_interrupted(fuse_req_t req);
 /**
  * Create a low level session
  *
+ * Known parameters in `args` are removed. If there are any unknown
+ * arguments, an error is printed 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)
index a879ffabaf3bbcbf9ccdc154697d22a4f930021e..cd254f9f9f62488e9cb874fd84e7f6b03ccba44d 100644 (file)
@@ -4684,6 +4684,9 @@ struct fuse *fuse_new(struct fuse_chan *ch, struct fuse_args *args,
        init_list_head(&f->full_slabs);
        init_list_head(&f->lru_table);
 
+       /* When --help or --version are specified, we print messages
+          to stderr but continue for now (and keep the arguments in
+          `args` for use below */
        if (fuse_opt_parse(args, &f->conf, fuse_lib_opts,
                           fuse_lib_opt_proc) == -1)
                goto out_free_fs;
@@ -4714,6 +4717,8 @@ struct fuse *fuse_new(struct fuse_chan *ch, struct fuse_args *args,
        f->conf.readdir_ino = 1;
 #endif
 
+       /* This function will return NULL if there is an --help
+          or --version argument in `args` */
        f->se = fuse_lowlevel_new(args, &llop, sizeof(llop), f);
        if (f->se == NULL) {
                if (f->conf.help)
index 9b595158ad0d21b4a9eb1ed30469ffd8a777fd6a..31714ddf40c01fd6acf0c3c399ba0a29486ec421 100755 (executable)
@@ -2674,6 +2674,7 @@ static int fuse_ll_opt_proc(void *data, const char *arg, int key,
                fprintf(stderr, "fuse: unknown option `%s'\n", arg);
        }
 
+       /* Fail */
        return -1;
 }
 
index 97577c2a6eefa3e30da34a13873098c0db4a3c06..6a55269ff450ad2f6c70e67b9f68f2d7598a2fe8 100644 (file)
@@ -114,6 +114,7 @@ static int fuse_helper_opt_proc(void *data, const char *arg, int key,
                }
 
        default:
+               /* Pass through unknown options */
                return 1;
        }
 }
index 7be7b25e46dc28b54cb77222bd199d514827672c..b2b841d65b265e6c52cb8166300fcafdcfbcb14e 100644 (file)
@@ -241,6 +241,8 @@ static int fuse_mount_opt_proc(void *data, const char *arg, int key,
                mo->ishelp = 1;
                break;
        }
+
+       /* Pass through unknown options */
        return 1;
 }
 
index 3d6b12f4a868e4ef5e399b8ea0b5371df28c3452..40ef93f25f2cccd40dc903bd72f6fefab14a4068 100644 (file)
@@ -141,6 +141,8 @@ static int fuse_mount_opt_proc(void *data, const char *arg, int key,
                mo->ishelp = 1;
                break;
        }
+
+       /* Pass through unknown options */
        return 1;
 }