diff options
author | Aaron LI <aly@aaronly.me> | 2019-01-10 09:55:18 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2019-01-10 09:55:18 +0800 |
commit | df72339dbe0d4ae72f70773ea4a86c9220cad37b (patch) | |
tree | 1056e9b3cf4a79b7990bab1f598d7d240fc6a4fa | |
parent | a779ceb1fd9eb71252ee7445fd9b63668f47d0cb (diff) | |
download | dfly-update-df72339dbe0d4ae72f70773ea4a86c9220cad37b.tar.bz2 |
Split out function get_mount_dev()
-rwxr-xr-x | dfly-update | 11 |
1 files changed, 9 insertions, 2 deletions
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} ..." |