summarylogtreecommitdiffstats
path: root/os-prober-fix-btrfs-subvol-mounted-tests.patch
blob: 0b87a30f041662208610abae85cdd89502ddce35 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
Index: os-prober-1.76/os-probes/common/50mounted-tests
===================================================================
--- os-prober-1.76.orig/os-probes/common/50mounted-tests
+++ os-prober-1.76/os-probes/common/50mounted-tests
@@ -65,10 +65,40 @@ fi

 mounted=

+if [ "$types" = btrfs ]; then
+	partition="$BTRFSDEV"
+fi
+
+if type grub2-mount >/dev/null 2>&1 && \
+   type grub2-probe >/dev/null 2>&1 && \
+   grub2-mount "$partition" "$tmpmnt" 2>/dev/null; then
+	mounted=1
+	type="$(grub2-probe -d "$partition" -t fs)" || true
+	if [ "$type" ]; then
+		debug "mounted using GRUB $type filesystem driver"
+	else
+		debug "mounted using GRUB, but unknown filesystem?"
+		type=fuseblk
+	fi
+fi
+
+if [ "$mounted" ]; then
+	for test in /usr/lib/os-probes/mounted/*; do
+		debug "running subtest $test"
+		if [ -f "$test" ] && [ -x "$test" ]; then
+			if "$test" "$partition" "$tmpmnt" "$type"; then
+				debug "os found by subtest $test"
+				do_unmount
+				exit 0
+			fi
+		fi
+	done
+fi
+do_unmount
+
 # all btrfs processing here.  Handle both unmounted and
 # mounted subvolumes.
 if [ "$types" = btrfs ]; then
-	partition="$BTRFSDEV"
 	debug "begin btrfs processing for $UUID"
 	# note that the btrfs volume must not be mounted ro
 	if mount -t btrfs -U "$UUID" "$tmpmnt"  2>/dev/null; then
@@ -129,37 +159,8 @@ if [ "$types" = btrfs ]; then
 	rmdir "$tmpmnt" || true
 	if [ "$found" ]; then
 		exit 0
-	else
-		exit 1
-	fi
-fi
-
-if type grub2-mount >/dev/null 2>&1 && \
-   type grub2-probe >/dev/null 2>&1 && \
-   grub2-mount "$partition" "$tmpmnt" 2>/dev/null; then
-	mounted=1
-	type="$(grub2-probe -d "$partition" -t fs)" || true
-	if [ "$type" ]; then
-		debug "mounted using GRUB $type filesystem driver"
-	else
-		debug "mounted using GRUB, but unknown filesystem?"
-		type=fuseblk
 	fi
 fi

-if [ "$mounted" ]; then
-	for test in /usr/lib/os-probes/mounted/*; do
-		debug "running subtest $test"
-		if [ -f "$test" ] && [ -x "$test" ]; then
-			if "$test" "$partition" "$tmpmnt" "$type"; then
-				debug "os found by subtest $test"
-				do_unmount
-				exit 0
-			fi
-		fi
-	done
-fi
-do_unmount
-
 # No tests found anything.
 exit 1