]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: (optlist) correctly detect ro status
authorThomas Weißschuh <thomas@t-8ch.de>
Sun, 11 Jun 2023 09:49:54 +0000 (11:49 +0200)
committerThomas Weißschuh <thomas@t-8ch.de>
Sun, 11 Jun 2023 09:52:08 +0000 (11:52 +0200)
Fixes #2305

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
libmount/src/optlist.c
tests/expected/libmount/loop-explicit-rw [new file with mode: 0644]
tests/ts/libmount/loop

index f74e759287e7c2deab621f0fa97ce02ed951efe0..1e962ec6d89140c2a56781acd57e36095768f456 100644 (file)
@@ -463,7 +463,7 @@ static struct libmnt_opt *optlist_new_opt(struct libmnt_optlist *ls,
                else if (opt->ent->id == MS_BIND)
                        ls->is_bind = 1;
                else if (opt->ent->id == MS_RDONLY)
-                       ls->is_rdonly = 1;
+                       ls->is_rdonly = opt->ent->mask & MNT_INVERT ? 0 : 1;
                else if (opt->ent->id == MS_MOVE)
                        ls->is_move = 1;
                else if (opt->ent->id == MS_SILENT)
diff --git a/tests/expected/libmount/loop-explicit-rw b/tests/expected/libmount/loop-explicit-rw
new file mode 100644 (file)
index 0000000..e7787c0
--- /dev/null
@@ -0,0 +1,2 @@
+rw
+Success
index e45336cbd35149e754f65f720924269f1f66a2b8..db807bd44ad7c22e660de53561fe508a0cb430a9 100755 (executable)
@@ -139,5 +139,14 @@ udevadm settle
 ts_log "Success"
 ts_finalize_subtest
 
+ts_init_subtest "explicit-rw"
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+$TS_CMD_MOUNT -o rw "$BACKFILE" "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_FINDMNT -no FS-OPTIONS --mountpoint "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_UMOUNT "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG
+udevadm settle
+ts_log "Success"
+ts_finalize_subtest
+
 ts_log "Success"
 ts_finalize