dracut/0047-dracut-functions.sh-add-find_mp_fstype.patch
Harald Hoyer 12f6cc01aa dracut-022-63.git20120727
- fixed dracut-install bug if /var/tmp contains a symlink
- fixed some partx issues
2012-07-27 06:28:40 +02:00

48 lines
1.3 KiB
Diff

From 81672479afb4806568f1dea7fac9b8d7271c71f6 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Thu, 26 Jul 2012 17:00:07 +0200
Subject: [PATCH] dracut-functions.sh: add find_mp_fstype()
---
dracut-functions.sh | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/dracut-functions.sh b/dracut-functions.sh
index 14c100d..0332351 100755
--- a/dracut-functions.sh
+++ b/dracut-functions.sh
@@ -357,6 +357,33 @@ find_dev_fstype() {
return 1
}
+# find_dev_fstype <device>
+# Echo the filesystem type for a given device.
+# /proc/self/mountinfo is taken as the primary source of information
+# and /etc/fstab is used as a fallback.
+# No newline is appended!
+# Example:
+# $ find_dev_fstype /dev/sda2;echo
+# ext4
+find_mp_fstype() {
+ local _x _mpt _majmin _dev _fs _maj _min
+ while read _x _x _majmin _x _mpt _x _x _fs _dev _x; do
+ [[ $_mpt = $1 ]] || continue
+ echo -n $_fs;
+ return 0;
+ done < /proc/self/mountinfo
+
+ # fall back to /etc/fstab
+ while read _dev _mpt _fs _x; do
+ [[ $_mpt = $1 ]] || continue
+ echo -n $_fs;
+ return 0;
+ done < /etc/fstab
+
+ return 1
+}
+
+
# finds the major:minor of the block device backing the root filesystem.
find_root_block_device() { find_block_device /; }