---
 modules.d/99fs-lib/fs-lib.sh | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/modules.d/99fs-lib/fs-lib.sh b/modules.d/99fs-lib/fs-lib.sh
index 9e6abf6..15e2b91 100755
--- a/modules.d/99fs-lib/fs-lib.sh
+++ b/modules.d/99fs-lib/fs-lib.sh
@@ -287,3 +287,29 @@ fs_add_mount() {
        [ "${pass}" ] || pass=0
        echo "${fs} ${mountpoint} ${fstype} ${options} ${dump} ${pass}" >> 
/etc/fstab."${phase}"
 }
+
+# fs_mount_to_var MOUNTSPEC
+# use MOUNTSPEC to set $mountpoint, $fstype, $fs and $options.
+# MOUNTSPEC is something like: [<mountpoint>]:<fstype>:<fs>[,<options>]
+fs_mount_to_var() {
+       local arg="$1"
+
+       options="${arg#*,}"
+       [ "${options}" = "${arg}" ] && unset options
+       arg="${arg%%,${options}}"
+
+       mountpoint="${arg%%:*}"
+       [ "${mountpoint}" = "${arg}" ] && die "Unable to parse mountpoint out 
of $1"
+       arg="${arg##${mountpoint}:}"
+
+       if [ "${mountpoint}" = "${mountpoint#/}" ] ; then
+               fstype="${mountpoint}"
+               mountpoint=/
+       else
+               fstype="${arg%%:*}"
+               [ "${fstype}" = "${arg}" ] && die "Unable to parse fstype out 
of $1"
+               arg="${arg##${fstype}:}"
+       fi
+
+       fs="${arg}"
+}
-- 
1.8.1.5

--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to