+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
*/
#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
*
enum {
KEY_HELP,
- KEY_KEEP
};
#define FUSE_LIB_OPT(t, p, v) { t, offsetof(struct fuse_config, p), v }
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),
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;
KEY_HELP,
KEY_HELP_NOHEADER,
KEY_VERSION,
- KEY_KEEP,
};
struct 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
};
}
default:
- case KEY_KEEP:
return 1;
}
}