This improves compatibility with non-gnu userspaces.
On systems where the libc provides posix getopt instead of gnu getopt,
mount helpers which use getopt to parse arguments will not parse
options which appear after non-option arguments. This patch ensures
mount/unmount work as expected in this situation.
mount: fix expected argument order for mount helpers in tests
type = mnt_fs_get_fstype(cxt->fs);
args[i++] = cxt->helper; /* 1 */
- args[i++] = mnt_fs_get_srcpath(cxt->fs);/* 2 */
- args[i++] = mnt_fs_get_target(cxt->fs); /* 3 */
if (mnt_context_is_sloppy(cxt))
- args[i++] = "-s"; /* 4 */
+ args[i++] = "-s"; /* 2 */
if (mnt_context_is_fake(cxt))
- args[i++] = "-f"; /* 5 */
+ args[i++] = "-f"; /* 3 */
if (mnt_context_is_nomtab(cxt))
- args[i++] = "-n"; /* 6 */
+ args[i++] = "-n"; /* 4 */
if (mnt_context_is_verbose(cxt))
- args[i++] = "-v"; /* 7 */
+ args[i++] = "-v"; /* 5 */
if (o) {
- args[i++] = "-o"; /* 8 */
- args[i++] = o; /* 9 */
+ args[i++] = "-o"; /* 6 */
+ args[i++] = o; /* 7 */
}
if (type
&& strchr(type, '.')
&& !endswith(cxt->helper, type)) {
- args[i++] = "-t"; /* 10 */
- args[i++] = type; /* 11 */
+ args[i++] = "-t"; /* 8 */
+ args[i++] = type; /* 9 */
}
if (namespace) {
- args[i++] = "-N"; /* 12 */
- args[i++] = namespace; /* 13 */
+ args[i++] = "-N"; /* 10 */
+ args[i++] = namespace; /* 11 */
}
+
+ args[i++] = mnt_fs_get_srcpath(cxt->fs);/* 12 */
+ args[i++] = mnt_fs_get_target(cxt->fs); /* 13 */
+
args[i] = NULL; /* 14 */
for (i = 0; args[i]; i++)
DBG(CXT, ul_debugobj(cxt, "argv[%d] = \"%s\"",
type = mnt_fs_get_fstype(cxt->fs);
args[i++] = cxt->helper; /* 1 */
- args[i++] = mnt_fs_get_target(cxt->fs); /* 2 */
if (mnt_context_is_nomtab(cxt))
- args[i++] = "-n"; /* 3 */
+ args[i++] = "-n"; /* 2 */
if (mnt_context_is_lazy(cxt))
- args[i++] = "-l"; /* 4 */
+ args[i++] = "-l"; /* 3 */
if (mnt_context_is_force(cxt))
- args[i++] = "-f"; /* 5 */
+ args[i++] = "-f"; /* 4 */
if (mnt_context_is_verbose(cxt))
- args[i++] = "-v"; /* 6 */
+ args[i++] = "-v"; /* 5 */
if (mnt_context_is_rdonly_umount(cxt))
- args[i++] = "-r"; /* 7 */
+ args[i++] = "-r"; /* 6 */
if (type
&& strchr(type, '.')
&& !endswith(cxt->helper, type)) {
- args[i++] = "-t"; /* 8 */
- args[i++] = type; /* 9 */
+ args[i++] = "-t"; /* 7 */
+ args[i++] = type; /* 8 */
}
if (namespace) {
- args[i++] = "-N"; /* 10 */
- args[i++] = namespace; /* 11 */
+ args[i++] = "-N"; /* 9 */
+ args[i++] = namespace; /* 10 */
}
+ args[i++] = mnt_fs_get_target(cxt->fs); /* 11 */
+
args[i] = NULL; /* 12 */
for (i = 0; args[i]; i++)
DBG(CXT, ul_debugobj(cxt, "argv[%d] = \"%s\"",
-/sbin/mount.mytest called with "/foo /bar -o rw"
+/sbin/mount.mytest called with "-o rw /foo /bar"
-/sbin/mount.mytest called with "/foo /bar -o rw"
+/sbin/mount.mytest called with "-o rw /foo /bar"
-/sbin/mount.mytest called with "/foo /bar -o rw,foo"
+/sbin/mount.mytest called with "-o rw,foo /foo /bar"
-/sbin/mount.mytest called with "/foo /bar -o rw,user,noexec,nosuid,nodev,abc"
+/sbin/mount.mytest called with "-o rw,user,noexec,nosuid,nodev,abc /foo /bar"
-/sbin/mount.mytest called with "/foo /bar -o rw,user=name,abc"
+/sbin/mount.mytest called with "-o rw,user=name,abc /foo /bar"