Fix loop0p2 does not exist on F19

On Fedora 19, there is a delay between the time loop0p2
is created to the time it is ready to be mounted.

This patches waits for 5 seconds for /dev/mapper/loop0p2
to be accessible. If it is not ready then the script
exits with status 1.

Fixes: bug #1197340

Change-Id: Iff0cfd0566673799a77500e0e24954f5f3743a17
This commit is contained in:
Richard Su 2013-07-05 12:38:24 -07:00
parent 57a1304df9
commit 9a81644d65

View File

@ -38,6 +38,10 @@ if [ ! -f $IMG_PATH/$BASE_IMAGE_TAR -o \
# /dev/loop0 does not create /dev/loop0p2, while kpartx at # /dev/loop0 does not create /dev/loop0p2, while kpartx at
# least creates /dev/mapper/loop0p2. # least creates /dev/mapper/loop0p2.
LOOPDEV=$(sudo kpartx -avr $WORKING/$RAW_FILE | awk "/loop[0-9]+$MAGIC_BIT/ {print \$3}") LOOPDEV=$(sudo kpartx -avr $WORKING/$RAW_FILE | awk "/loop[0-9]+$MAGIC_BIT/ {print \$3}")
if ! timeout 5 sh -c "while ! [ -e /dev/mapper/$LOOPDEV ]; do sleep 1; done"; then
echo "Error: Could not find /dev/mapper/$LOOPDEV"
exit 1
fi
EACTION="sudo kpartx -d $WORKING/$RAW_FILE;$EACTION" EACTION="sudo kpartx -d $WORKING/$RAW_FILE;$EACTION"
trap "$EACTION" EXIT trap "$EACTION" EXIT
mkdir $WORKING/mnt mkdir $WORKING/mnt