From 81a13cd6e9c3cbe5806549df8747b12d0f7def49 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Wed, 9 Jan 2019 11:44:52 +0800 Subject: Fold get_vn_devname() into umount_image() Improve the method to get the device name of the mounted image. --- dfly-update | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/dfly-update b/dfly-update index c6cfc2d..74bd11e 100755 --- a/dfly-update +++ b/dfly-update @@ -134,23 +134,18 @@ mount_image() { mount -r /dev/${vn}s2a ${mntpnt} || exit ${EC_MOUNT} } -# Get the vn device name of the mounted image -get_vn_devname() { - local mntpnt="$1" - local dev=$(mount | fgrep "${mntpnt}" | cut -d' ' -f 1 | cut -d'/' -f 3) - echo ${dev%s??} -} - -# Umount the image +# Umount the image and unconfigure the underlying VN device # # umount_image(mntpnt) # umount_image() { local mntpnt="$1" - local vn=$(get_vn_devname ${mntpnt}) + local dev vn + dev=$(df | awk '$NF == "'${mntpnt}'" { print $1 }') + vn=${dev#/dev/} umount ${mntpnt} || exit ${EC_UMOUNT} - echo "Disable and unconfigure VN device ${vn} ..." - vnconfig -u ${vn} || exit ${EC_VN} + echo "Unconfigure ${vn} ..." + vnconfig -u "${vn%s??}" || exit ${EC_VN} } # Backup the old kernel -- cgit v1.2.2