[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#476184: os-prober: Mounted partitions after running update-grub



Am Dienstag, den 18.08.2009, 06:27 -0300 schrieb Otavio Salvador:
> Hello Felix,
> 
> On Fri, Jul 31, 2009 at 4:33 PM, Felix Zielcke<fzielcke@z-51.de> wrote:
> > Any chance that the Ubuntu patch gets included in Debian's os-prober?
> > On Launchpad there aren't any reports open related to this.
> 
> I think it would be nice if you could prepare the patch and post on
> this bug report so we could review it.
> 

Here it is.

-- 
Felix Zielcke
Proud Debian Maintainer
Index: common.sh
===================================================================
--- common.sh	(revision 60239)
+++ common.sh	(working copy)
@@ -175,3 +175,20 @@ linux_mount_boot () {
 
 	echo "$bootpart $mounted"
 }
+# Unmount a file system. If this fails, wait for a bit and try again, to
+# cope with crazy automounting systems opportunistically opening it.
+repeat_umount() {
+	local i=3
+	while [ "$i" != 0 ]; do
+		if umount "$1"; then
+			break
+		fi
+		i="$(($i - 1))"
+		if [ "$i" = 0 ]; then
+			warn "failed to unmount $1; things may go wrong"
+		else
+			warn "failed to unmount $1; trying again ($i)"
+			sleep 5
+		fi
+	done
+}
Index: linux-boot-prober
===================================================================
--- linux-boot-prober	(revision 60239)
+++ linux-boot-prober	(working copy)
@@ -45,9 +45,7 @@ else
 			fi
 		done
 		if [ "$bootmounted" = 1 ]; then
-			if ! umount "$mpoint/boot"; then
-				warn "failed to umount $mpoint/boot"
-			fi
+			repeat_umount "$mpoint/boot" || true
 		fi
 	fi
 fi
Index: linux-boot-probes/common/50mounted-tests
===================================================================
--- linux-boot-probes/common/50mounted-tests	(revision 60239)
+++ linux-boot-probes/common/50mounted-tests	(working copy)
@@ -21,20 +21,16 @@ for type in $(grep -v nodev /proc/filesy
 				debug "running $test $partition $bootpart $tmpmnt $type"
 				if $test "$partition" "$bootpart" "$tmpmnt" "$type"; then
 					debug "$test succeeded"
-					umount $tmpmnt/boot 2>/dev/null || true 	
-					if ! umount $tmpmnt; then
-						warn "failed to umount $tmpmnt"
-					fi
+					repeat_umount $tmpmnt/boot 2>/dev/null || true 	
+					repeat_umount $tmpmnt
 					rmdir $tmpmnt || true
 					exit 0
 				fi
 			fi
 		done
 		
-		umount $tmpmnt/boot 2>/dev/null || true 	
-		if ! umount $tmpmnt; then
-			warn "failed to umount $tmpmnt"
-		fi
+		repeat_umount $tmpmnt/boot 2>/dev/null || true 	
+		repeat_umount $tmpmnt
 
 		break
 	fi
Index: os-probes/common/50mounted-tests
===================================================================
--- os-probes/common/50mounted-tests	(revision 60239)
+++ os-probes/common/50mounted-tests	(working copy)
@@ -32,17 +32,13 @@ for type in $types $delaytypes; do
 			if [ -f $test ] && [ -x $test ]; then
 				if $test "$partition" "$tmpmnt" "$type"; then
 					debug "os found by subtest $test"
-					if ! umount $tmpmnt; then
-						warn "failed to umount $tmpmnt"
-					fi
+					repeat_umount $tmpmnt
 					rmdir $tmpmnt || true
 					exit 0
 				fi
 			fi
 		done
-		if ! umount $tmpmnt; then
-			warn "failed to umount $tmpmnt"
-		fi
+		repeat_umount $tmpmnt
 		break
 	fi
 done

Reply to: