diff options
author | Miklos Szeredi <miklos@szeredi.hu> | 2006-01-20 16:29:23 +0000 |
---|---|---|
committer | Miklos Szeredi <miklos@szeredi.hu> | 2006-01-20 16:29:23 +0000 |
commit | d2a3ed327ecd71bedf9918f729c068b11d81fdc1 (patch) | |
tree | 95899a77bc0cbf0f3c8418a8e2bb3dbb03732934 | |
parent | cd6a924cdc482fec10e4f5fa3d889d12e8e2169e (diff) | |
download | sshfs-d2a3ed327ecd71bedf9918f729c068b11d81fdc1.tar sshfs-d2a3ed327ecd71bedf9918f729c068b11d81fdc1.tar.gz sshfs-d2a3ed327ecd71bedf9918f729c068b11d81fdc1.tar.bz2 sshfs-d2a3ed327ecd71bedf9918f729c068b11d81fdc1.zip |
fix
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | compat/fuse_opt.c | 55 | ||||
-rw-r--r-- | compat/fuse_opt.h | 41 | ||||
-rw-r--r-- | sshfs.c | 14 |
5 files changed, 85 insertions, 33 deletions
@@ -1,3 +1,9 @@ +2006-01-20 Miklos Szeredi <miklos@szeredi.hu> + + * Update to fuse API 2.7 + + * Don't do readahead in sshfs if it's done in kernel + 2006-01-14 Miklos Szeredi <miklos@szeredi.hu> * Released 1.4 diff --git a/Makefile.am b/Makefile.am index 56a57bf..8109161 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,4 +7,4 @@ compat_sources = compat/fuse_opt.c compat/fuse_opt.h endif sshfs_SOURCES = sshfs.c cache.c cache.h $(compat_sources) -sshfs_CPPFLAGS = -DFUSE_USE_VERSION=25 +sshfs_CPPFLAGS = -DFUSE_USE_VERSION=27 diff --git a/compat/fuse_opt.c b/compat/fuse_opt.c index 2ac499c..582c6ad 100644 --- a/compat/fuse_opt.c +++ b/compat/fuse_opt.c @@ -62,6 +62,21 @@ int fuse_opt_add_arg(struct fuse_args *args, const char *arg) return 0; } +int fuse_opt_insert_arg(struct fuse_args *args, int pos, const char *arg) +{ + assert(pos <= args->argc); + if (fuse_opt_add_arg(args, arg) == -1) + return -1; + + if (pos != args->argc - 1) { + char *newarg = args->argv[args->argc - 1]; + memmove(&args->argv[pos + 1], &args->argv[pos], + sizeof(char *) * (args->argc - pos - 1)); + args->argv[pos] = newarg; + } + return 0; +} + static int next_arg(struct fuse_opt_context *ctx, const char *opt) { if (ctx->argctr + 1 >= ctx->argc) { @@ -102,25 +117,13 @@ static int add_opt(struct fuse_opt_context *ctx, const char *opt) return fuse_opt_add_opt(&ctx->opts, opt); } -static int insert_arg(struct fuse_opt_context *ctx, int pos, const char *arg) -{ - assert(pos <= ctx->outargs.argc); - if (add_arg(ctx, arg) == -1) - return -1; - - if (pos != ctx->outargs.argc - 1) { - char *newarg = ctx->outargs.argv[ctx->outargs.argc - 1]; - memmove(&ctx->outargs.argv[pos + 1], &ctx->outargs.argv[pos], - sizeof(char *) * (ctx->outargs.argc - pos - 1)); - ctx->outargs.argv[pos] = newarg; - } - return 0; -} - 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; @@ -155,8 +158,8 @@ static int match_template(const char *t, const char *arg, unsigned *sepp) static const struct fuse_opt *find_opt(const struct fuse_opt *opt, const char *arg, unsigned *sepp) { - for (; opt && opt->template; opt++) - if (match_template(opt->template, arg, sepp)) + for (; opt && opt->templ; opt++) + if (match_template(opt->templ, arg, sepp)) return opt; return NULL; } @@ -195,11 +198,11 @@ static int process_opt(struct fuse_opt_context *ctx, return -1; } else { void *var = ctx->data + opt->offset; - if (sep && opt->template[sep + 1]) { + if (sep && opt->templ[sep + 1]) { const char *param = arg + sep; - if (opt->template[sep] == '=') + if (opt->templ[sep] == '=') param ++; - if (process_opt_param(var, opt->template + sep + 1, + if (process_opt_param(var, opt->templ + sep + 1, param, arg) == -1) return -1; } else @@ -239,7 +242,7 @@ static int process_gopt(struct fuse_opt_context *ctx, const char *arg, int iso) if (opt) { for (; opt; opt = find_opt(opt + 1, arg, &sep)) { int res; - if (sep && opt->template[sep] == ' ' && !arg[sep]) + if (sep && opt->templ[sep] == ' ' && !arg[sep]) res = process_opt_sep_arg(ctx, opt, sep, arg, iso); else res = process_opt(ctx, opt, sep, arg, iso); @@ -321,12 +324,14 @@ static int opt_parse(struct fuse_opt_context *ctx) return -1; if (ctx->opts) { - if (insert_arg(ctx, 1, "-o") == -1 || - insert_arg(ctx, 2, ctx->opts) == -1) + if (fuse_opt_insert_arg(&ctx->outargs, 1, "-o") == -1 || + fuse_opt_insert_arg(&ctx->outargs, 2, ctx->opts) == -1) return -1; } - if (ctx->nonopt && ctx->nonopt == ctx->outargs.argc) + if (ctx->nonopt && ctx->nonopt == ctx->outargs.argc) { + free(ctx->outargs.argv[ctx->outargs.argc - 1]); ctx->outargs.argv[--ctx->outargs.argc] = NULL; + } return 0; } diff --git a/compat/fuse_opt.h b/compat/fuse_opt.h index 2ef5d56..9e159d5 100644 --- a/compat/fuse_opt.h +++ b/compat/fuse_opt.h @@ -72,7 +72,7 @@ extern "C" { */ struct fuse_opt { /** Matching template and optional parameter formatting */ - const char *template; + const char *templ; /** * Offset of variable within 'data' parameter of fuse_opt_parse() @@ -82,7 +82,7 @@ struct fuse_opt { /** * Value to set the variable to, or to be passed as 'key' to the - * processing function. Ignored if template a format + * processing function. Ignored if template has a format */ int value; }; @@ -91,13 +91,13 @@ struct fuse_opt { * Key option. In case of a match, the processing function will be * called with the specified key. */ -#define FUSE_OPT_KEY(template, key) { template, -1U, key } +#define FUSE_OPT_KEY(templ, key) { templ, -1U, key } /** * Last option. An array of 'struct fuse_opt' must end with a NULL * template value */ -#define FUSE_OPT_END { .template = NULL } +#define FUSE_OPT_END { .templ = NULL } /** * Argument list @@ -120,7 +120,7 @@ struct fuse_args { /** * Key value passed to the processing function if an option did not - * match any templated + * match any template */ #define FUSE_OPT_KEY_OPT -1 @@ -133,6 +133,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 * * This function is called if @@ -202,6 +218,21 @@ int fuse_opt_add_opt(char **opts, const char *opt); int fuse_opt_add_arg(struct fuse_args *args, const char *arg); /** + * Add an argument at the specified position in a NULL terminated + * argument vector + * + * Adds the argument to the N-th position. This is useful for adding + * options at the beggining of the array which must not come after the + * special '--' option. + * + * @param args is the structure containing the current argument list + * @param pos is the position at which to add the argument + * @param arg is the new argument to add + * @return -1 on allocation error, 0 on success + */ +int fuse_opt_insert_arg(struct fuse_args *args, int pos, const char *arg); + +/** * Free the contents of argument list * * The structure itself is not freed @@ -1006,8 +1006,18 @@ static int start_processing_thread(void) } #ifdef SSHFS_USE_INIT +#if FUSE_VERSION >= 27 +static void *sshfs_init(struct fuse_conn_info *conn) +#else static void *sshfs_init(void) +#endif { +#if FUSE_VERSION >= 27 + /* Readahead should be done by kernel or sshfs but not both */ + if (conn->async_read) + sshfs.sync_read = 1; +#endif + if (sshfs.detect_uid) sftp_detect_uid(); @@ -2104,10 +2114,10 @@ int main(int argc, char *argv[]) } tmp = g_strdup_printf("-omax_read=%u", sshfs.max_read); - fuse_opt_add_arg(&args, tmp); + fuse_opt_insert_arg(&args, 1, tmp); g_free(tmp); tmp = g_strdup_printf("-ofsname=sshfs#%s", fsname); - fuse_opt_add_arg(&args, tmp); + fuse_opt_insert_arg(&args, 1, tmp); g_free(tmp); g_free(fsname); res = fuse_main(args.argc, args.argv, cache_init(&sshfs_oper)); |