image_to_usb: actually fail if umount fails

Unmount failures were being masked by the "| grep" for the chroot helper
message. Remove all of this, since it is critical that the umount
failure stop the script. Otherwise we'll end up with corrupted images
from situations like the Ubuntu automounter.

BUG=None
TEST=attempted image writing with an automounted drive

Change-Id: I171a0f298688f56df3a34384b0cc2052e97f8d85
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63377
Reviewed-by: Marc MERLIN <merlin@chromium.org>
diff --git a/image_to_usb.sh b/image_to_usb.sh
index a513b81..e98cd07 100755
--- a/image_to_usb.sh
+++ b/image_to_usb.sh
@@ -338,15 +338,14 @@
     are_you_sure
   fi
 
-  mount_list=$(mount | grep ^"${FLAGS_to}" | awk '{print $1}')
+  mount_list=$(grep ^"${FLAGS_to}" /proc/mounts | awk '{print $1}')
   if [ -n "${mount_list}" ]; then
     echo "Attempting to unmount any mounts on the target device..."
     for i in ${mount_list}; do
-      if safe_umount "$i" 2>&1 >/dev/null | grep "not found"; then
-        die_notrace "$i needs to be unmounted outside the chroot"
+      if ! safe_umount "$i" ; then
+        die_notrace "$i could not be unmounted; aborting."
       fi
     done
-    sleep 3
   fi
 
   if [ ${FLAGS_install} -ne ${FLAGS_TRUE} ]; then