aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2019-01-09 11:44:52 +0800
committerAaron LI <aly@aaronly.me>2019-01-09 11:51:49 +0800
commit81a13cd6e9c3cbe5806549df8747b12d0f7def49 (patch)
treec7ad3e21dd883082ef4d2e989236564f2f1039ba
parent6c54c80c53c817332773ac0f6f99e991b8f3419b (diff)
downloaddfly-update-81a13cd6e9c3cbe5806549df8747b12d0f7def49.tar.bz2
Fold get_vn_devname() into umount_image()
Improve the method to get the device name of the mounted image.
-rwxr-xr-xdfly-update17
1 files 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