mkefidisk: Attempt to automatically unmount target device
authorDarren Hart <dvhart@linux.intel.com>
Thu, 25 Apr 2013 17:23:51 +0000 (10:23 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 29 Apr 2013 13:45:06 +0000 (14:45 +0100)
With automounters abounding it makes more sense to attempt to unmount
the device rather than abort, just like ddimage does.

(From OE-Core rev: f522ff19ba4b80788d66a2c58ee50b86fdfea15f)

Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/contrib/mkefidisk.sh

index acadd49..741c3ab 100755 (executable)
@@ -102,10 +102,14 @@ fi
 #
 grep -q $DEVICE /proc/mounts
 if [ $? -eq 0 ]; then
-       echo "ERROR: $DEVICE partitions mounted:"
-       grep $DEVICE /proc/mounts | cut -f 1 -d " "
-       echo "Unmount the partitions listed and try again."
-       exit 1
+       echo -n "$DEVICE listed in /proc/mounts, attempting to unmount..."
+       umount $DEVICE* 2>/dev/null
+       grep -q $DEVICE /proc/mounts
+       if [ $? -eq 0 ]; then
+               echo "FAILED"
+               exit 1
+       fi
+       echo "OK"
 fi
 
 
@@ -153,6 +157,7 @@ echo "Boot partition size:   $BOOT_SIZE MB ($BOOTFS)"
 echo "ROOTFS partition size: $ROOTFS_SIZE MB ($ROOTFS)"
 echo "Swap partition size:   $SWAP_SIZE MB ($SWAP)"
 echo "*****************"
+
 echo "Deleting partition table on $DEVICE ..."
 dd if=/dev/zero of=$DEVICE bs=512 count=2