From 77e7c3d54385b83ecadceb74e5ed372339d80e10 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Fri, 20 Jan 2006 13:11:10 +0000 Subject: [PATCH] fix --- ChangeLog | 5 +++++ include/fuse_opt.h | 16 ++++++++++++++++ lib/fuse.c | 5 ++--- lib/fuse_opt.c | 6 ++++-- lib/helper.c | 8 +++----- 5 files changed, 30 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8d3723c..89fe386 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-01-20 Miklos Szeredi + + * fuse_opt: add new helper constants FUSE_OPT_KEY_KEEP and + FUSE_OPT_KEY_DISCARD + 2006-01-19 Miklos Szeredi * lib: if "fsname=" option was given, pass it to fusermount diff --git a/include/fuse_opt.h b/include/fuse_opt.h index a46b920..9e159d5 100644 --- a/include/fuse_opt.h +++ b/include/fuse_opt.h @@ -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 * diff --git a/lib/fuse.c b/lib/fuse.c index 7d66a7d..0488c9c 100644 --- a/lib/fuse.c +++ b/lib/fuse.c @@ -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), diff --git a/lib/fuse_opt.c b/lib/fuse_opt.c index 53511fc..582c6ad 100644 --- a/lib/fuse_opt.c +++ b/lib/fuse_opt.c @@ -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; diff --git a/lib/helper.c b/lib/helper.c index c4a7b3a..fcaaf36 100644 --- a/lib/helper.c +++ b/lib/helper.c @@ -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; } } -- 2.30.2