summaryrefslogtreecommitdiff
path: root/scripts/functions
diff options
context:
space:
mode:
authorrleigh@debian.org <rleigh@debian.org>2013-05-08 19:32:06 +0100
committerMichael Prokop <mika@debian.org>2014-09-25 08:36:58 +0200
commit8d63dd5e1e53a1a45e7efb6da8dd58d650cec4f3 (patch)
treee5d24904a05239ba3d1a125b1f8e5ee3a22ea54d /scripts/functions
parent2860ed1103623a634ead614e22af1c66d750d1d3 (diff)
functions: Add read_fstab_entry
Based upon the initscript equivalent.
Diffstat (limited to 'scripts/functions')
-rw-r--r--scripts/functions30
1 files changed, 30 insertions, 0 deletions
diff --git a/scripts/functions b/scripts/functions
index 38f3d8b..81946d0 100644
--- a/scripts/functions
+++ b/scripts/functions
@@ -427,3 +427,33 @@ wait_for_udev()
command -v udevadm >/dev/null 2>&1 || return 0
udevadm settle ${1:+--timeout=$1}
}
+
+# Find a specific fstab entry
+# $1=mountpoint
+# $2=fstype (optional)
+# returns 0 on success, 1 on failure (not found or no fstab)
+read_fstab_entry() {
+ # Not found by default.
+ found=1
+
+ for file in ${rootmnt}/etc/fstab; do
+ if [ -f "$file" ]; then
+ while read MNT_FSNAME MNT_DIR MNT_TYPE MNT_OPTS MNT_FREQ MNT_PASS MNT_JUNK; do
+ case "$MNT_FSNAME" in
+ ""|\#*)
+ continue;
+ ;;
+ esac
+ if [ "$MNT_DIR" = "$1" ]; then
+ if [ -n "$2" ]; then
+ [ "$MNT_TYPE" = "$2" ] || continue;
+ fi
+ found=0
+ break 2
+ fi
+ done < "$file"
+ fi
+ done
+
+ return $found
+}