tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: patch for fusermount: Not enough command line arguments
On Thu, Apr 16, 2009 at 09:53:23AM -0500, Jeremy C. Reed wrote:
> Trying to unmount a filesystem...
>
> $ mount | grep puffs
> /dev/puffs on /home/reed/hammer/fusehammer/mnt type
> puffs|refuse:hammerdisk.raw (nosuid, nodev, mounted by reed)
>
> $ fusermount -u /home/reed/hammer/fusehammer/mnt
> fusermount: Not enough command line arguments
> Usage: fusermount [-c] [-d name] [-h] [-p] [-u] [-x] mountpoint...
> -c use kernel cache
> -d name use name in mount information
> -h print help information
> -p check file permissions
> -u unmount mount point(s)
> -x allow access to mortal (non-root) users
>
> Even man page suggests is correct syntax:
>
> SYNOPSIS
> fusermount [-chpVx] [-d name] refuseoptions
> fusermount -u mountpoint(s)
>
> So I looked at code and added debugging:
>
> if (optind >= argc - 2) {
> printf("optind = %d, argc = %d\n", optind, argc);
>
> warnx("Not enough command line arguments");
> usage(*argv);
> exit(EXIT_FAILURE);
> }
>
> optind = 2, argc = 3
>
> optind is the index for next argument.
>
> So my workaround is to add two more junk arguments to the command line:
>
> $ fusermount -u /home/reed/hammer/fusehammer/mnt JUNK1 JUNK2
> fusermount: can't unmount `JUNK1': No such file or directory
> fusermount: can't unmount `JUNK2': No such file or directory
>
> Okay if I commit the following?
>
> Index: fusermount.c
> ===================================================================
> RCS file: /cvsroot/src/usr.sbin/fusermount/fusermount.c,v
> retrieving revision 1.3
> diff -u -r1.3 fusermount.c
> --- fusermount.c 21 Jul 2008 13:36:58 -0000 1.3
> +++ fusermount.c 16 Apr 2009 14:48:39 -0000
> @@ -134,7 +134,7 @@
> exit(EXIT_FAILURE);
> }
> }
> - if (optind >= argc - 2) {
> + if (action != ActionUnmount && optind >= argc - 2) {
> warnx("Not enough command line arguments");
> usage(*argv);
> exit(EXIT_FAILURE);
>
>
>
> (By the way if you attempt to unmount something already unmounted you get
> "Operation not permitted".)
>
It might be better to do something like:
if ((action == ActionMount && optind >= argc - 2) ||
(action == ActionUnmount && optind >= argc)) {
warn...
}
i.e. check for out of arguments in unmount case as well.
And, no, I have no idea why the fusermount arguments are so... esoteric.
Regards,
Alistair
Home |
Main Index |
Thread Index |
Old Index