summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarald Hoyer <harald@redhat.com>2013-08-15 11:14:14 +0200
committerHarald Hoyer <harald@redhat.com>2013-08-15 11:14:46 +0200
commit97af51db9d167a3ab48fc24628dafb34ce2505aa (patch)
tree39175dbb0846918ae0fe5ae9b7a51dbfd4802013
parent69f7ed96109095c8d3c39c1f741598119b602936 (diff)
downloaddracut-97af51db9d167a3ab48fc24628dafb34ce2505aa.tar.gz
dracut-97af51db9d167a3ab48fc24628dafb34ce2505aa.tar.bz2
dracut-97af51db9d167a3ab48fc24628dafb34ce2505aa.zip
dracut-functions.sh: add find_dev_fsopts()
-rwxr-xr-xdracut-functions.sh25
1 files changed, 23 insertions, 2 deletions
diff --git a/dracut-functions.sh b/dracut-functions.sh
index 9a12eb45..3bec116c 100755
--- a/dracut-functions.sh
+++ b/dracut-functions.sh
@@ -261,9 +261,9 @@ else
fi
# get_fs_env <device>
-# Get and set the ID_FS_TYPE variable from udev for a device.
+# Get and the ID_FS_TYPE variable from udev for a device.
# Example:
-# $ get_fs_env /dev/sda2; echo $ID_FS_TYPE
+# $ get_fs_env /dev/sda2
# ext4
get_fs_env() {
local evalstr
@@ -439,9 +439,30 @@ find_dev_fstype() {
done; return 1; } && return 0
return 1
+}
+# find_dev_fsopts <device>
+# Echo the filesystem options for a given device.
+# /proc/self/mountinfo is taken as the primary source of information
+# and /etc/fstab is used as a fallback.
+# Example:
+# $ find_dev_fsopts /dev/sda2
+# rw,relatime,discard,data=ordered
+find_dev_fsopts() {
+ local _find_dev _opts
+ _find_dev="$1"
+ if ! [[ "$_find_dev" = /dev* ]]; then
+ [[ -b "/dev/block/$_find_dev" ]] && _find_dev="/dev/block/$_find_dev"
+ fi
+
+ if [[ $use_fstab != yes ]]; then
+ findmnt -e -v -n -o 'OPTIONS' --source "$_find_dev" 2>/dev/null && return 0
+ fi
+
+ findmnt --fstab -e -v -n -o 'OPTIONS' --source "$_find_dev"
}
+
# finds the major:minor of the block device backing the root filesystem.
find_root_block_device() { find_block_device /; }