From df72339dbe0d4ae72f70773ea4a86c9220cad37b Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Thu, 10 Jan 2019 09:55:18 +0800 Subject: Split out function get_mount_dev() --- dfly-update | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'dfly-update') diff --git a/dfly-update b/dfly-update index 4b8e11e..8d37772 100755 --- a/dfly-update +++ b/dfly-update @@ -121,6 +121,13 @@ error() { exit ${ec} } +# Get the device mounted at the given directory +get_mount_dev() { + local mntpnt="$1" + local dev=$(df | awk '$NF == "'${mntpnt}'" { print $1 }') + echo "${dev}" +} + # Mount the specified system image file # # mount_image(imgfile, mntpnt) @@ -130,7 +137,7 @@ mount_image() { local mntpnt="$2" local dev vn - dev=$(df | awk '$NF == "'${mntpnt}'" { print $1 }') + dev=$(get_mount_dev ${mntpnt}) [ -z "${dev}" ] || error ${EC_MOUNT} "${dev} already mounted at ${mntpnt}" @@ -146,7 +153,7 @@ mount_image() { umount_image() { local mntpnt="$1" local dev vn - dev=$(df | awk '$NF == "'${mntpnt}'" { print $1 }') + dev=$(get_mount_dev ${mntpnt}) vn=${dev#/dev/} umount ${mntpnt} || exit ${EC_UMOUNT} echo "Unconfigure ${vn} ..." -- cgit v1.2.2