diff options
author | Christian Neukirchen <[email protected]> | 2016-01-23 21:37:35 +0100 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2016-01-25 13:17:18 -0800 |
commit | d93b45aefc74b9c345ba3cdf3a227ee979a990cd (patch) | |
tree | d7f36bad12f4a2a6c3ba7b69d47ab1c60a0e691d /cmd | |
parent | 91d888437f729e0dce042d49b36063affb4f3af9 (diff) |
mount.zfs: use getopt_long instead of getopt to guarantee permutation of argv.
mount.zfs is called by convention (and util-linux) with arguments
last, i.e.
% mount.zfs <dataset> <mountpoint> -o <options>
This is not a problem on glibc since GNU getopt(3) will reorder the
arguments. However, alternative libc such as musl libc (or glibc with
$POSIXLY_CORRECT set) will not permute argv and fail to parse the -o
<options>. Use getopt_long so musl will permute arguments.
Signed-off-by: Christian Neukirchen <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #4222
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/mount_zfs/mount_zfs.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/cmd/mount_zfs/mount_zfs.c b/cmd/mount_zfs/mount_zfs.c index e3e8cfc22..2fb4d65e9 100644 --- a/cmd/mount_zfs/mount_zfs.c +++ b/cmd/mount_zfs/mount_zfs.c @@ -32,6 +32,7 @@ #include <sys/stat.h> #include <libzfs.h> #include <locale.h> +#include <getopt.h> #define ZS_COMMENT 0x00000000 /* comment */ #define ZS_ZFSUTIL 0x00000001 /* caller is zfs(8) */ @@ -387,7 +388,7 @@ main(int argc, char **argv) opterr = 0; /* check options */ - while ((c = getopt(argc, argv, "sfnvo:h?")) != -1) { + while ((c = getopt_long(argc, argv, "sfnvo:h?", 0, 0)) != -1) { switch (c) { case 's': sloppy = 1; |