From 5fcbbae9bb60647ad30c7de8855932c7d6988789 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Wed, 9 Jan 2019 11:45:53 +0800 Subject: Check whether the mount point is already mounted If the target mount point is already mounted (e.g., legacy from previous incomplete dfly-update run), just exit with an error. --- dfly-update | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dfly-update b/dfly-update index 74bd11e..9233f1c 100755 --- a/dfly-update +++ b/dfly-update @@ -121,14 +121,19 @@ error() { exit ${ec} } -# Mount the downloaded image (IMG file) +# Mount the specified system image file # # mount_image(imgfile, mntpnt) # mount_image() { local imgfile="$1" local mntpnt="$2" - local vn + local dev vn + + dev=$(df | awk '$NF == "'${mntpnt}'" { print $1 }') + [ -z "${dev}" ] || + error ${EC_MOUNT} "${dev} already mounted at ${mntpnt}" + [ -d "${mntpnt}" ] || mkdir "${mntpnt}" vn=$(vnconfig -c vn ${imgfile}) || exit ${EC_VN} mount -r /dev/${vn}s2a ${mntpnt} || exit ${EC_MOUNT} -- cgit v1.2.2