From 25d540d75dddd7b029faa148d6c84a586b764be4 Mon Sep 17 00:00:00 2001 From: "J. Richard Barnette" Date: Wed, 18 Jan 2012 15:40:10 -0800 Subject: [PATCH] Add more information to loopback mount failures. Buildbots are periodically failing to build images; the evidence points to failures in mount_gpt_image.sh, but it's inconclusive. Add detailed error messages to mount failures so as to be able to debug more the next time it happens. BUG=chromium-os:24975 TEST=build_image, to see that successful cases still work TEST=repeatedly mount new images with mount_gpt_image until it fails Change-Id: I711fb0dec62dbab3817a62895b53e14376702544 Reviewed-on: https://gerrit.chromium.org/gerrit/14410 Commit-Ready: Richard Barnette Tested-by: Richard Barnette Reviewed-by: David James --- mount_gpt_image.sh | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/mount_gpt_image.sh b/mount_gpt_image.sh index 368af5c7e1..3ab2e99a6d 100755 --- a/mount_gpt_image.sh +++ b/mount_gpt_image.sh @@ -129,19 +129,31 @@ function get_gpt_partitions() { enable_rw_mount "${FLAGS_from}/${filename}" "$(( offset * 512 ))" fi - sudo mount ${safe_flag} -o loop,offset=$(( offset * 512 )) \ - "${FLAGS_from}/${filename}" "${FLAGS_rootfs_mountpt}" + if ! sudo mount ${safe_flag} -o loop,offset=$(( offset * 512 )) \ + "${FLAGS_from}/${filename}" "${FLAGS_rootfs_mountpt}" ; then + error "mount failed: options=${safe_flag} offset=$(( offset * 512 ))" \ + "target=${FLAGS_rootfs_mountpt}" + return 1 + fi # Mount the stateful partition using a loopback device. offset=$(partoffset "${FLAGS_from}/${filename}" 1) - sudo mount ${ro_flag} -o loop,offset=$(( offset * 512 )) \ - "${FLAGS_from}/${filename}" "${FLAGS_stateful_mountpt}" + if ! sudo mount ${ro_flag} -o loop,offset=$(( offset * 512 )) \ + "${FLAGS_from}/${filename}" "${FLAGS_stateful_mountpt}" ; then + error "mount failed: options=${ro_flag} offset=$(( offset * 512 ))" \ + "target=${FLAGS_stateful_mountpt}" + return 1 + fi # Mount the stateful partition using a loopback device. if [[ -n "${FLAGS_esp_mountpt}" ]]; then offset=$(partoffset "${FLAGS_from}/${filename}" 12) - sudo mount ${ro_flag} -o loop,offset=$(( offset * 512 )) \ - "${FLAGS_from}/${filename}" "${FLAGS_esp_mountpt}" + if ! sudo mount ${ro_flag} -o loop,offset=$(( offset * 512 )) \ + "${FLAGS_from}/${filename}" "${FLAGS_esp_mountpt}" ; then + error "mount failed: options=${ro_flag} offset=$(( offset * 512 ))" \ + "target=${FLAGS_esp_mountpt}" + return 1 + fi fi } @@ -156,8 +168,10 @@ function mount_image() { # Get the partitions for the image / device. if [ -b ${FLAGS_from} ] ; then get_usb_partitions - else - get_gpt_partitions + elif ! get_gpt_partitions ; then + echo "Current loopback device status:" + sudo losetup --all | sed 's/^/ /' + die "Failed to mount all partitions in ${FLAGS_from}/${FLAGS_image}" fi # Mount directories and setup symlinks.