aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2018-03-10 20:45:32 +0800
committerAaron LI <aly@aaronly.me>2018-03-10 20:46:37 +0800
commitd322f373e798c4329c4008086a7e11b28487d643 (patch)
tree29a7c8f41637afc8ec187ce0453c1680e08dba25
parentf32935551dbd0bdecefa166044659f76b76e7591 (diff)
downloaddfly-update-d322f373e798c4329c4008086a7e11b28487d643.tar.bz2
Add umount_image() function with get_vn_devname() and get_vn_filename()
-rwxr-xr-xdfly-update33
1 files changed, 33 insertions, 0 deletions
diff --git a/dfly-update b/dfly-update
index 0a438a7..facdbea 100755
--- a/dfly-update
+++ b/dfly-update
@@ -27,6 +27,8 @@ EC_MD5=12
EC_ARGS=13
EC_FETCH=14
EC_MOUNT=15
+EC_UMOUNT=16
+EC_VN=17
#
@@ -270,6 +272,37 @@ mount_image() {
|| exit ${EC_MOUNT}
}
+# Get the vn device name of the mounted image
+get_vn_devname() {
+ [ $# -eq 1 ] || exit ${EC_ARGS}
+ local mntpnt="$1"
+ local dev=$(mount | fgrep "${mntpnt}" | cut -d' ' -f 1 | cut -d'/' -f 3)
+ echo ${dev%s??}
+}
+
+# Get the filename configured for the vn device
+get_vn_filename() {
+ [ $# -eq 1 ] || exit ${EC_ARGS}
+ local vn="$1"
+ echo $(vnconfig -l ${vn} | awk '{ print $3 }')
+}
+
+# Umount the image
+#
+# umount_image(mntpnt)
+#
+umount_image() {
+ [ $# -eq 1 ] || exit ${EC_ARGS}
+ local mntpnt="$1"
+ local vn=$(get_vn_devname ${mntpnt})
+ echo -n "Umounting image from ${mntpnt} ... "
+ umount ${mntpnt} && echo "DONE" || exit ${EC_UMOUNT}
+ echo "Disable and unconfigure VN device ${vn} ... "
+ vnconfig -v -u ${vn} \
+ && echo "DONE" \
+ || exit ${EC_VN}
+}
+
}