On Fri, Jun 20, 2014 at 03:49:31PM +0200, Sylvestre Gallon wrote:
> On Fri, Jun 20, 2014 at 01:12:01PM +0100, Stuart Henderson wrote:
> > On 2014/06/20 14:03, Gregor Best wrote:
> > > Hi Sylvestre,
> > >
> > > I've noticed that sysutils/sshfs-fuse does not seem to accept all
> > > options advertised in the manpage and available on e.g. Linux. The most
> > > notable example is -p, which sets the target SSH port. I have a machine
> > > where SSH listens on port 22022. On Linux and the like, I can do
> > > something like
> > >
> > > $ sshfs neon:/home/gbe /mnt/tmp -p 22022
> > >
> > > whereas on OpenBSD, I get
> > >
> > > $ sshfs neon:/home/gbe /mnt/tmp -p 22022
> > > fuse: unknown option -p
> > >
> > > On the other hand, I _can_ use -o to set options like sshfs_debug, but
> > > not things like Port (e.g. via -o Port=22022).
> > >
> > > Is there anything I can do to further debug this, or maybe a little hit
> > > with the clue stick you could give me so maybe I can fix it?
> > >
> > > --
> > > Gregor Best
> > >
> >
> > I think this is related to options handling in libfuse. I don't know
> > how to fix it, but as a workaround you can add a Host section to
> > .ssh/config which specifies the port.
> >
> > Host somehost
> > HostName 192.0.2.23
> > Port 2022
> >
>
> The problem with fuse_opt is that it is specified by the
> Linux fuse spec which is a real pain in the ass...
>
> sshfs use '-p ' option and not '-p'. As I understand there is
> a space at the end of the option. It means we need to get
> the next arg and give it as an argument to -p.
>
> Here is an attempt to do that...
>
> Does it fix the -p issue for you ?
>
> Cheers,
>
Please forget last diff and use this one instead...
Index: fuse_opt.c
===================================================================
RCS file: /cvs/src/lib/libfuse/fuse_opt.c,v
retrieving revision 1.10
diff -u -p -u -p -r1.10 fuse_opt.c
--- fuse_opt.c 20 May 2014 13:22:06 -0000 1.10
+++ fuse_opt.c 20 Jun 2014 14:02:36 -0000
@@ -218,8 +218,8 @@ fuse_opt_add_arg(struct fuse_args *args,
}
static int
-parse_opt(const struct fuse_opt *o, const char *val, void *data,
- fuse_opt_proc_t f, struct fuse_args *arg)
+parse_opt(const struct fuse_opt *o, const char *val, const char *val2,
+ void *data, fuse_opt_proc_t f, struct fuse_args *arg, int *i)
{
int found, ret, keyval;
size_t idx;
@@ -236,6 +236,13 @@ parse_opt(const struct fuse_opt *o, cons
}
for(; o->templ; o++) {
+ if (val2 && o->templ[strlen(o->templ) -1] == ' ') {
+ idx--;
+ keyval = 1;
+ val = val2;
+ (*i)++;
+ }
+
if ((keyval && strncmp(val, o->templ, idx) == 0) ||
(!keyval && strcmp(val, o->templ) == 0)) {
if (o->val == FUSE_OPT_KEY_DISCARD)
@@ -278,6 +285,7 @@ fuse_opt_parse(struct fuse_args *args, v
{
struct fuse_args outargs;
const char *arg;
+ char *arg2 = NULL;
int ret = 0;
int i;
@@ -289,6 +297,10 @@ fuse_opt_parse(struct fuse_args *args, v
for (i = 1; i < args->argc; i++) {
arg = args->argv[i];
+ if (i < args->argc - 1)
+ if (asprintf(&arg2, "%s %s\n", arg,
+ args->argv[i + 1]) == -1)
+ return (-1);
/* not - and not -- */
if (arg[0] != '-') {
@@ -304,20 +316,24 @@ fuse_opt_parse(struct fuse_args *args, v
else
arg = args->argv[++i];
- ret = parse_opt(opt, arg, data, f, &outargs);
+ ret = parse_opt(opt, arg, arg2, data, f, &outargs, &i);
if (ret == -1)
goto err;
} else {
- ret = parse_opt(opt, arg, data, f, &outargs);
+ ret = parse_opt(opt, arg, arg2, data, f, &outargs, &i);
if (ret == -1)
goto err;
}
+
+ free(arg2);
+ arg2 = NULL;
}
ret = 0;
err:
+ free(arg2);
/* Update args */
fuse_opt_free_args(args);
args->allocated = outargs.allocated;