Source

vabs / var / vabs / os-prober / src / patches / mountfix.patch

Full commit
diff -Naur os-prober-1.63/linux-boot-probes/common/50mounted-tests os-prober-1.63.patched/linux-boot-probes/common/50mounted-tests
--- os-prober-1.63/linux-boot-probes/common/50mounted-tests	2012-03-27 19:01:05.000000000 -0600
+++ os-prober-1.63.patched/linux-boot-probes/common/50mounted-tests	2014-01-17 13:10:00.000000000 -0700
@@ -34,13 +34,19 @@
 fi
 
 mounted=
-if type grub-mount >/dev/null 2>&1 && \
-   type grub-probe >/dev/null 2>&1 && \
-   grub-mount "$partition" "$tmpmnt" 2>/dev/null; then
-	mounted=1
-	type="$(grub-probe -d "$partition" -t fs)"
-	[ "$type" ] || type=fuseblk
-else
+if type mount >/dev/null 2>&1; then
+	if mount -o ro "$partition" "$tmpmnt" 2>/dev/null; then
+		type="$(grub-probe -d "$partition" -t fs)" || true
+		if [ "$type" ]; then
+			debug "mounted using $type filesystem driver"
+		else
+			debug "mounted, but unknown filesystem?"
+			type=fuseblk
+		fi
+		debug "mounted as $type filesystem"
+		mounted=1
+		break
+	fi
 	ro_partition "$partition"
 	for type in $types; do
 		if mount -o ro -t "$type" "$partition" "$tmpmnt" 2>/dev/null; then
@@ -48,6 +54,12 @@
 			break
 		fi
 	done
+elif type grub-mount >/dev/null 2>&1 && \
+   type grub-probe >/dev/null 2>&1 && \
+   grub-mount "$partition" "$tmpmnt" 2>/dev/null; then
+	mounted=1
+	type="$(grub-probe -d "$partition" -t fs)"
+	[ "$type" ] || type=fuseblk
 fi
 
 if [ "$mounted" ]; then
@@ -63,6 +75,10 @@
 				umount "$tmpmnt/boot" 2>/dev/null || true 	
 				if ! umount "$tmpmnt"; then
 					warn "failed to umount $tmpmnt"
+					sleep 1
+					if ! umount "$tmpmnt"; then
+						warn "failed to umount $tmpmnt"
+					fi
 				fi
 				rmdir "$tmpmnt" || true
 				exit 0
@@ -73,6 +89,10 @@
 	umount "$tmpmnt/boot" 2>/dev/null || true 	
 	if ! umount "$tmpmnt"; then
 		warn "failed to umount $tmpmnt"
+		sleep 1
+		if ! umount "$tmpmnt"; then
+			warn "failed to umount $tmpmnt"
+		fi
 	fi
 fi
 
diff -Naur os-prober-1.63/os-probes/common/50mounted-tests os-prober-1.63.patched/os-probes/common/50mounted-tests
--- os-prober-1.63/os-probes/common/50mounted-tests	2012-11-03 20:01:55.000000000 -0600
+++ os-prober-1.63.patched/os-probes/common/50mounted-tests	2014-01-17 13:09:22.000000000 -0700
@@ -46,7 +46,28 @@
 fi
 
 mounted=
-if type grub-mount >/dev/null 2>&1 && \
+if type mount >/dev/null 2>&1;then
+	if mount -o ro "$partition" "$tmpmnt" 2>/dev/null; then
+		type="$(grub-probe -d "$partition" -t fs)" || true
+		if [ "$type" ]; then
+			debug "mounted using $type filesystem driver"
+		else
+			debug "mounted, but unknown filesystem?"
+			type=fuseblk
+		fi
+		debug "mounted as $type filesystem"
+		mounted=1
+		break
+	fi
+	ro_partition "$partition"
+	for type in $types $delaytypes; do
+		if mount -o ro -t "$type" "$partition" "$tmpmnt" 2>/dev/null; then
+			debug "mounted as $type filesystem"
+			mounted=1
+			break
+		fi
+	done
+elif type grub-mount >/dev/null 2>&1 && \
    type grub-probe >/dev/null 2>&1 && \
    grub-mount "$partition" "$tmpmnt" 2>/dev/null; then
 	mounted=1
@@ -57,15 +78,6 @@
 		debug "mounted using GRUB, but unknown filesystem?"
 		type=fuseblk
 	fi
-else
-	ro_partition "$partition"
-	for type in $types $delaytypes; do
-		if mount -o ro -t "$type" "$partition" "$tmpmnt" 2>/dev/null; then
-			debug "mounted as $type filesystem"
-			mounted=1
-			break
-		fi
-	done
 fi
 
 if [ "$mounted" ]; then
@@ -76,6 +88,10 @@
 				debug "os found by subtest $test"
 				if ! umount "$tmpmnt"; then
 					warn "failed to umount $tmpmnt"
+					sleep 1
+					if ! umount "$tmpmnt"; then
+						warn "failed to umount $tmpmnt"
+					fi
 				fi
 				rmdir "$tmpmnt" || true
 				exit 0
@@ -84,6 +100,10 @@
 	done
 	if ! umount "$tmpmnt"; then
 		warn "failed to umount $tmpmnt"
+		sleep 1
+		if ! umount "$tmpmnt"; then
+			warn "failed to umount $tmpmnt"
+		fi
 	fi
 fi