diff options
author | Filipe Brandenburger | 2016-08-10 22:27:07 +0200 |
---|---|---|
committer | Filipe Brandenburger | 2016-08-10 22:59:52 +0200 |
commit | 727c689908c5e68c92aa1dd65e0d3bdb6d91c1e5 (patch) | |
tree | 377e3b204c3878bfe6e1b76210a87a2ea87228e4 /tests/expected/libmount | |
parent | tests: Allow running a single test case from tests/run.sh (diff) | |
download | kernel-qcow2-util-linux-727c689908c5e68c92aa1dd65e0d3bdb6d91c1e5.tar.gz kernel-qcow2-util-linux-727c689908c5e68c92aa1dd65e0d3bdb6d91c1e5.tar.xz kernel-qcow2-util-linux-727c689908c5e68c92aa1dd65e0d3bdb6d91c1e5.zip |
libmount: Preserve empty string value in optstr parsing
Recent mount (since the switch to libmount in v2.22) drops the '=' in
mount options that are set to an empty value. For example, the command
line below will be affected:
# mount -o rw,myopt='' -t tmpfs tmpfs /mnt/tmp
Fix that by preserving an empty string in the options passed to the
mount(2) syscall when they are present on the command line.
Add test cases to ensure empty string handling is working as expected
and in order to prevent regressions in the future.
Also tested manually by stracing mount commands (on a kernel which
accepts a special extra option, for testing purposes.)
Before this commit:
# strace -e mount ./mount -t tmpfs -o rw,myopt='' tmpfs /mnt/tmp
mount("tmpfs", "/mnt/tmp", "tmpfs", MS_MGC_VAL, "myarg") = -1 EINVAL (Invalid argument)
After this commit:
# strace -e mount ./mount -t tmpfs -o rw,myopt='' tmpfs /mnt/tmp
mount("tmpfs", "/mnt/tmp", "tmpfs", MS_MGC_VAL, "myopt=") = 0
All test cases pass, including newly added test cases. Also checked
them with valgrind using:
$ tests/run.sh --memcheck libmount/optstr
Fixes #332.
Signed-off-by: Filipe Brandenburger <filbranden@google.com>
Diffstat (limited to 'tests/expected/libmount')
-rw-r--r-- | tests/expected/libmount/optstr-append-empty-value | 1 | ||||
-rw-r--r-- | tests/expected/libmount/optstr-deduplicate-empty | 1 | ||||
-rw-r--r-- | tests/expected/libmount/optstr-prepend-empty-value | 1 | ||||
-rw-r--r-- | tests/expected/libmount/optstr-remove-empty-value | 1 | ||||
-rw-r--r-- | tests/expected/libmount/optstr-set-empty | 1 | ||||
-rw-r--r-- | tests/expected/libmount/optstr-set-new-empty | 1 | ||||
-rw-r--r-- | tests/expected/libmount/optstr-set-new-end-empty | 1 |
7 files changed, 7 insertions, 0 deletions
diff --git a/tests/expected/libmount/optstr-append-empty-value b/tests/expected/libmount/optstr-append-empty-value new file mode 100644 index 000000000..35adf5c72 --- /dev/null +++ b/tests/expected/libmount/optstr-append-empty-value @@ -0,0 +1 @@ +result: >aaa,bbb=BBB,ccc,ddd=< diff --git a/tests/expected/libmount/optstr-deduplicate-empty b/tests/expected/libmount/optstr-deduplicate-empty new file mode 100644 index 000000000..63b74f678 --- /dev/null +++ b/tests/expected/libmount/optstr-deduplicate-empty @@ -0,0 +1 @@ +result: >bbb,ccc,xxx,ddd,AAA=,fff=eee< diff --git a/tests/expected/libmount/optstr-prepend-empty-value b/tests/expected/libmount/optstr-prepend-empty-value new file mode 100644 index 000000000..4cea63527 --- /dev/null +++ b/tests/expected/libmount/optstr-prepend-empty-value @@ -0,0 +1 @@ +result: >ddd=,aaa,bbb=BBB,ccc< diff --git a/tests/expected/libmount/optstr-remove-empty-value b/tests/expected/libmount/optstr-remove-empty-value new file mode 100644 index 000000000..eee5c95b9 --- /dev/null +++ b/tests/expected/libmount/optstr-remove-empty-value @@ -0,0 +1 @@ +result: >aaa,ccc< diff --git a/tests/expected/libmount/optstr-set-empty b/tests/expected/libmount/optstr-set-empty new file mode 100644 index 000000000..e0a3300f9 --- /dev/null +++ b/tests/expected/libmount/optstr-set-empty @@ -0,0 +1 @@ +result: >aaa,bbb=,ccc< diff --git a/tests/expected/libmount/optstr-set-new-empty b/tests/expected/libmount/optstr-set-new-empty new file mode 100644 index 000000000..a1cfb3721 --- /dev/null +++ b/tests/expected/libmount/optstr-set-new-empty @@ -0,0 +1 @@ +result: >aaa=,bbb=BBB,ccc< diff --git a/tests/expected/libmount/optstr-set-new-end-empty b/tests/expected/libmount/optstr-set-new-end-empty new file mode 100644 index 000000000..d0e9880f3 --- /dev/null +++ b/tests/expected/libmount/optstr-set-new-end-empty @@ -0,0 +1 @@ +result: >aaa,bbb=BBB,ccc=< |