* lib: if "fsname=" option was given, pass it to fusermount
+ * fuse_opt: add new fuse_opt_insert_arg() function, which is
+ needed by filesystems to implement some argument manipulations
+ correctly
+
2006-01-18 Miklos Szeredi <miklos@szeredi.hu>
* kernel: fix detection of case when fuse is not configured into
*/
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
*
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) {
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)
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)