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 <jrbarnette@chromium.org>
Tested-by: Richard Barnette <jrbarnette@chromium.org>
Reviewed-by: David James <davidjames@chromium.org>
This commit is contained in:
J. Richard Barnette 2012-01-18 15:40:10 -08:00 committed by Gerrit
parent 3e7245a788
commit 25d540d75d

View File

@ -129,19 +129,31 @@ function get_gpt_partitions() {
enable_rw_mount "${FLAGS_from}/${filename}" "$(( offset * 512 ))" enable_rw_mount "${FLAGS_from}/${filename}" "$(( offset * 512 ))"
fi fi
sudo mount ${safe_flag} -o loop,offset=$(( offset * 512 )) \ if ! sudo mount ${safe_flag} -o loop,offset=$(( offset * 512 )) \
"${FLAGS_from}/${filename}" "${FLAGS_rootfs_mountpt}" "${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. # Mount the stateful partition using a loopback device.
offset=$(partoffset "${FLAGS_from}/${filename}" 1) offset=$(partoffset "${FLAGS_from}/${filename}" 1)
sudo mount ${ro_flag} -o loop,offset=$(( offset * 512 )) \ if ! sudo mount ${ro_flag} -o loop,offset=$(( offset * 512 )) \
"${FLAGS_from}/${filename}" "${FLAGS_stateful_mountpt}" "${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. # Mount the stateful partition using a loopback device.
if [[ -n "${FLAGS_esp_mountpt}" ]]; then if [[ -n "${FLAGS_esp_mountpt}" ]]; then
offset=$(partoffset "${FLAGS_from}/${filename}" 12) offset=$(partoffset "${FLAGS_from}/${filename}" 12)
sudo mount ${ro_flag} -o loop,offset=$(( offset * 512 )) \ if ! sudo mount ${ro_flag} -o loop,offset=$(( offset * 512 )) \
"${FLAGS_from}/${filename}" "${FLAGS_esp_mountpt}" "${FLAGS_from}/${filename}" "${FLAGS_esp_mountpt}" ; then
error "mount failed: options=${ro_flag} offset=$(( offset * 512 ))" \
"target=${FLAGS_esp_mountpt}"
return 1
fi
fi fi
} }
@ -156,8 +168,10 @@ function mount_image() {
# Get the partitions for the image / device. # Get the partitions for the image / device.
if [ -b ${FLAGS_from} ] ; then if [ -b ${FLAGS_from} ] ; then
get_usb_partitions get_usb_partitions
else elif ! get_gpt_partitions ; then
get_gpt_partitions echo "Current loopback device status:"
sudo losetup --all | sed 's/^/ /'
die "Failed to mount all partitions in ${FLAGS_from}/${FLAGS_image}"
fi fi
# Mount directories and setup symlinks. # Mount directories and setup symlinks.