From a5ab85824db433bf98eec830a9b06b13a94b8d8b Mon Sep 17 00:00:00 2001 From: Christian Neukirchen Date: Sat, 23 Jan 2016 21:37:35 +0100 Subject: [PATCH] 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 -o 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 . Use getopt_long so musl will permute arguments. Signed-off-by: Christian Neukirchen Signed-off-by: Brian Behlendorf Closes #4222 --- cmd/mount_zfs/mount_zfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/mount_zfs/mount_zfs.c b/cmd/mount_zfs/mount_zfs.c index af589bbc7c..bd860cb2e5 100644 --- a/cmd/mount_zfs/mount_zfs.c +++ b/cmd/mount_zfs/mount_zfs.c @@ -32,6 +32,7 @@ #include #include #include +#include #define ZS_COMMENT 0x00000000 /* comment */ #define ZS_ZFSUTIL 0x00000001 /* caller is zfs(8) */ @@ -389,7 +390,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;