]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: fix umount --read-only
authorKarel Zak <kzak@redhat.com>
Tue, 23 Apr 2024 08:29:37 +0000 (10:29 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 23 Apr 2024 08:29:37 +0000 (10:29 +0200)
Reported-by: Krzysztof Olędzki <ole@ans.pl>
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/context_umount.c

index 79b62378d8d33957abac0b7b85208e2c68d6bf93..bf70ed2ee762fc5d067d67106e61245e0340d66d 100644 (file)
@@ -267,6 +267,9 @@ static int lookup_umount_fs_by_statfs(struct libmnt_context *cxt, const char *tg
         * So, let's use statfs() if possible (it's bad idea for --lazy/--force
         * umounts as target is probably unreachable NFS, also for --detach-loop
         * as this additionally needs to know the name of the loop device).
+        *
+        * For the "umount --read-only" command, we need to read the mountinfo
+        * to obtain the mount source.
         */
        if (mnt_context_is_restricted(cxt)
            || *tgt != '/'
@@ -275,6 +278,7 @@ static int lookup_umount_fs_by_statfs(struct libmnt_context *cxt, const char *tg
            || mnt_context_is_lazy(cxt)
            || mnt_context_is_nocanonicalize(cxt)
            || mnt_context_is_loopdel(cxt)
+           || mnt_context_is_rdonly_umount(cxt)
            || mnt_safe_stat(tgt, &st) != 0 || !S_ISDIR(st.st_mode)
            || has_utab_entry(cxt, tgt))
                return 1; /* not found */