Merge "Fixed device or resource busy issue in EXIT trap"

This commit is contained in:
Jenkins 2014-01-03 10:17:11 +00:00 committed by Gerrit Code Review
commit c79c05910c
2 changed files with 17 additions and 1 deletions

View File

@ -275,3 +275,12 @@ function mount_proc_dev_sys () {
sudo mount -t sysfs none $TMP_MOUNT_PATH/sys
}
function unmount_dir () {
local pattern="$1" mnts=""
if [ -n "$pattern" ]; then
mnts=`awk '{print $2}' < /proc/mounts | grep "^$pattern" | sort -r`
fi
if [ -n "$mnts" ]; then
sudo umount -fl $mnts || true
fi
}

View File

@ -25,7 +25,14 @@ function fullpath() {
}
function cleanup () {
sudo umount -f $TMP_BUILD_DIR || true
unmount_dir "$TMP_BUILD_DIR/mnt"
if [ -f "$TMP_IMAGE_PATH" ]; then
loopdev=`sudo losetup -j "$TMP_IMAGE_PATH" | cut -d: -f1`
if [ -n "$loopdev" ]; then
detach_loopback "$loopdev"
fi
fi
unmount_dir "$TMP_BUILD_DIR"
rm -rf --one-file-system "$TMP_BUILD_DIR"
}