summaryrefslogtreecommitdiff
blob: 57c8903348af3a159c4d8ecb2517d05a25b8ae8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
https://github.com/util-linux/util-linux/commit/9ba8eb5d89f0ebba8b3a542c041a5838e10a0d75
https://bugs.gentoo.org/573760#c11

From 9ba8eb5d89f0ebba8b3a542c041a5838e10a0d75 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 23 Apr 2024 10:29:37 +0200
Subject: [PATCH] libmount: fix umount --read-only
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Reported-by: Krzysztof Olędzki <ole@ans.pl>
Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit a20e7e23a8565e01b1c84de6924d1fbbdb1cfccc)
--- a/libmount/src/context_umount.c
+++ b/libmount/src/context_umount.c
@@ -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 */