diff options
author | Aaron LI <aly@aaronly.me> | 2019-01-09 11:45:53 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2019-01-09 11:52:17 +0800 |
commit | 5fcbbae9bb60647ad30c7de8855932c7d6988789 (patch) | |
tree | 1a3961d60d380e126eefe34593fb9e05a082d6ac | |
parent | 81a13cd6e9c3cbe5806549df8747b12d0f7def49 (diff) | |
download | dfly-update-5fcbbae9bb60647ad30c7de8855932c7d6988789.tar.bz2 |
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.
-rwxr-xr-x | dfly-update | 9 |
1 files 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} |