-/* $OpenBSD: fuse.c,v 1.22 2014/05/19 13:43:30 tedu Exp $ */
+/* $OpenBSD: fuse.c,v 1.23 2014/05/20 13:22:06 syl Exp $ */
/*
* Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com>
*
static struct fuse_session *sigse;
static struct fuse_context *ictx = NULL;
+static int max_read = FUSEBUFMAXSIZE;
enum {
KEY_HELP,
KEY_HELP_WITHOUT_HEADER,
KEY_VERSION,
- KEY_DEBUG
+ KEY_MAXREAD,
+ KEY_STUB
};
static struct fuse_opt fuse_core_opts[] = {
- FUSE_OPT_KEY("-h", KEY_HELP),
- FUSE_OPT_KEY("--help", KEY_HELP),
- FUSE_OPT_KEY("-ho", KEY_HELP_WITHOUT_HEADER),
- FUSE_OPT_KEY("-V", KEY_VERSION),
- FUSE_OPT_KEY("--version", KEY_VERSION),
- FUSE_OPT_KEY("debug", KEY_DEBUG),
- FUSE_OPT_KEY("-d", KEY_DEBUG),
- FUSE_OPT_KEY("-f", KEY_DEBUG),
- FUSE_OPT_KEY("-s", KEY_DEBUG),
+ FUSE_OPT_KEY("-h", KEY_HELP),
+ FUSE_OPT_KEY("--help", KEY_HELP),
+ FUSE_OPT_KEY("-ho", KEY_HELP_WITHOUT_HEADER),
+ FUSE_OPT_KEY("-V", KEY_VERSION),
+ FUSE_OPT_KEY("--version", KEY_VERSION),
+ FUSE_OPT_KEY("max_read=", KEY_MAXREAD),
+ FUSE_OPT_KEY("debug", KEY_STUB),
+ FUSE_OPT_KEY("-d", KEY_STUB),
+ FUSE_OPT_KEY("-f", KEY_STUB),
+ FUSE_OPT_KEY("-s", KEY_STUB),
+ FUSE_OPT_KEY("use_ino", KEY_STUB),
+ FUSE_OPT_KEY("default_permissions", KEY_STUB),
+ FUSE_OPT_KEY("fsname=", KEY_STUB),
FUSE_OPT_END
};
{
struct fuse_core_opt *opt = data;
struct stat st;
+ const char *err;
int res;
switch (key) {
- case KEY_DEBUG:
+ case KEY_STUB:
return (0);
case KEY_HELP:
case KEY_HELP_WITHOUT_HEADER:
case KEY_VERSION:
dump_version();
return (1);
+ case KEY_MAXREAD:
+ res = strtonum(arg, 0, FUSEBUFMAXSIZE, &err);
+ if (err) {
+ fprintf(stderr, "fuse: max_read %s\n", err);
+ return (-1);
+ }
+ max_read = res;
+ break;
case FUSE_OPT_KEY_NONOPT:
if (opt->mp == NULL) {
opt->mp = realpath(arg, opt->mp);
-/* $OpenBSD: fuse_opt.c,v 1.9 2014/04/15 08:48:11 syl Exp $ */
+/* $OpenBSD: fuse_opt.c,v 1.10 2014/05/20 13:22:06 syl Exp $ */
/*
* Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com>
* Copyright (c) 2013 Stefan Sperling <stsp@openbsd.org>
parse_opt(const struct fuse_opt *o, const char *val, void *data,
fuse_opt_proc_t f, struct fuse_args *arg)
{
- int ret;
- int found = 0;
+ int found, ret, keyval;
+ size_t idx;
+
+ ret = 0;
+ found = 0;
+ keyval = 0;
+
+ /* check if it is a key=value entry */
+ idx = strcspn(val, "=");
+ if (idx != strlen(val)) {
+ idx++;
+ keyval = 1;
+ }
for(; o->templ; o++) {
- if (strcmp(val, o->templ) == 0) {
+ if ((keyval && strncmp(val, o->templ, idx) == 0) ||
+ (!keyval && strcmp(val, o->templ) == 0)) {
if (o->val == FUSE_OPT_KEY_DISCARD)
return (1);
- ret = f(data, val, o->val, arg);
+ if (FUSE_OPT_IS_OPT_KEY(o)) {
+ if (keyval)
+ ret = f(data, &val[idx], o->val, arg);
+ else
+ ret = f(data, val, o->val, arg);
+ }
if (ret == -1)
return (ret);
return (-1);
}
- return (0);
+ return (ret);
}
/*
if (arg[2])
arg += 2; /* -ofoo,bar */
else
- i++; /* -o foo,bar*/
- if (ret != 0)
- return (ret);
+ arg = args->argv[++i];
+
+ ret = parse_opt(opt, arg, data, f, &outargs);
+
+ if (ret == -1)
+ goto err;
} else {
ret = parse_opt(opt, arg, data, f, &outargs);
-/* $OpenBSD: fuse_opt.h,v 1.3 2014/01/21 22:26:11 jca Exp $ */
+/* $OpenBSD: fuse_opt.h,v 1.4 2014/05/20 13:22:06 syl Exp $ */
/*
* Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com>
*
#define FUSE_ARGS_INIT(ac, av) { ac, av, 0 }
+#define FUSE_OPT_IS_OPT_KEY(t) (t->off == (unsigned long)-1)
+
#define FUSE_OPT_KEY(t, k) { t, -1, k }
#define FUSE_OPT_END { NULL, 0, 0 }
#define FUSE_OPT_KEY_OPT -1