fix
authorMiklos Szeredi <miklos@szeredi.hu>
Fri, 20 Jan 2006 13:11:10 +0000 (13:11 +0000)
committerMiklos Szeredi <miklos@szeredi.hu>
Fri, 20 Jan 2006 13:11:10 +0000 (13:11 +0000)
ChangeLog
include/fuse_opt.h
lib/fuse.c
lib/fuse_opt.c
lib/helper.c

index 8d3723cb09fdeed953fd9ebdd5c0bb8391880556..89fe3860111d58890cc8e47af7b44586fd185f2f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-01-20  Miklos Szeredi <miklos@szeredi.hu>
+
+       * fuse_opt: add new helper constants FUSE_OPT_KEY_KEEP and
+       FUSE_OPT_KEY_DISCARD
+
 2006-01-19  Miklos Szeredi <miklos@szeredi.hu>
 
        * lib: if "fsname=" option was given, pass it to fusermount
index a46b9206dbb0326a1efc0ccd18751a05f191b757..9e159d5aa8741e1e575af8cc2f4d057732917d3c 100644 (file)
@@ -132,6 +132,22 @@ struct fuse_args {
  */
 #define FUSE_OPT_KEY_NONOPT  -2
 
+/**
+ * Special key value for options to keep
+ *
+ * Argument is not passed to processing function, but behave as if the
+ * processing function returned 1
+ */
+#define FUSE_OPT_KEY_KEEP -3
+
+/**
+ * Special key value for options to discard
+ *
+ * Argument is not passed to processing function, but behave as if the
+ * processing function returned zero
+ */
+#define FUSE_OPT_KEY_DISCARD -4
+
 /**
  * Processing function
  *
index 7d66a7d689b6510f5e34432dc20fa84bf8165488..0488c9c962655342d106ad602129a5604020fb71 100644 (file)
@@ -1808,7 +1808,6 @@ void fuse_set_getcontext_func(struct fuse_context *(*func)(void))
 
 enum {
     KEY_HELP,
-    KEY_KEEP
 };
 
 #define FUSE_LIB_OPT(t, p, v) { t, offsetof(struct fuse_config, p), v }
@@ -1816,8 +1815,8 @@ enum {
 static const struct fuse_opt fuse_lib_opts[] = {
     FUSE_OPT_KEY("-h",                    KEY_HELP),
     FUSE_OPT_KEY("--help",                KEY_HELP),
-    FUSE_OPT_KEY("debug",                 KEY_KEEP),
-    FUSE_OPT_KEY("-d",                    KEY_KEEP),
+    FUSE_OPT_KEY("debug",                 FUSE_OPT_KEY_KEEP),
+    FUSE_OPT_KEY("-d",                    FUSE_OPT_KEY_KEEP),
     FUSE_LIB_OPT("debug",                 debug, 1),
     FUSE_LIB_OPT("-d",                    debug, 1),
     FUSE_LIB_OPT("hard_remove",           hard_remove, 1),
index 53511fcb7d8630326562f3ec1a4bf7a2eb7e3c38..582c6ad348a89a4f3b8428c177e48b24e02f4cab 100644 (file)
@@ -117,11 +117,13 @@ static int add_opt(struct fuse_opt_context *ctx, const char *opt)
     return fuse_opt_add_opt(&ctx->opts, opt);
 }
 
-
 static int call_proc(struct fuse_opt_context *ctx, const char *arg, int key,
                      int iso)
 {
-    if (ctx->proc) {
+    if (key == FUSE_OPT_KEY_DISCARD)
+        return 0;
+
+    if (key != FUSE_OPT_KEY_KEEP && ctx->proc) {
         int res = ctx->proc(ctx->data, arg, key, &ctx->outargs);
         if (res == -1 || !res)
             return res;
index c4a7b3a1eef2d5f8fde1c492e0859ab9473a96a4..fcaaf36fe98a3eb8bf2570ac3023878d9eee9f8b 100644 (file)
@@ -22,7 +22,6 @@ enum  {
     KEY_HELP,
     KEY_HELP_NOHEADER,
     KEY_VERSION,
-    KEY_KEEP,
 };
 
 struct helper_opts {
@@ -46,9 +45,9 @@ static const struct fuse_opt fuse_helper_opts[] = {
     FUSE_OPT_KEY("-ho",         KEY_HELP_NOHEADER),
     FUSE_OPT_KEY("-V",          KEY_VERSION),
     FUSE_OPT_KEY("--version",   KEY_VERSION),
-    FUSE_OPT_KEY("-d",          KEY_KEEP),
-    FUSE_OPT_KEY("debug",       KEY_KEEP),
-    FUSE_OPT_KEY("fsname=",     KEY_KEEP),
+    FUSE_OPT_KEY("-d",          FUSE_OPT_KEY_KEEP),
+    FUSE_OPT_KEY("debug",       FUSE_OPT_KEY_KEEP),
+    FUSE_OPT_KEY("fsname=",     FUSE_OPT_KEY_KEEP),
     FUSE_OPT_END
 };
 
@@ -107,7 +106,6 @@ static int fuse_helper_opt_proc(void *data, const char *arg, int key,
         }
 
     default:
-    case KEY_KEEP:
         return 1;
     }
 }