use findmnt with "--source" or "--target"
authorHarald Hoyer <harald@redhat.com>
Mon, 24 Jun 2013 10:47:01 +0000 (12:47 +0200)
committerHarald Hoyer <harald@redhat.com>
Mon, 24 Jun 2013 10:47:53 +0000 (12:47 +0200)
This avoids hanging on stale NFS mounts, which are not part of the boot
process.

https://bugzilla.redhat.com/show_bug.cgi?id=975401

dracut-functions.sh
dracut.sh
modules.d/96securityfs/securityfs.sh

index 3d88c9d..7ecd551 100755 (executable)
@@ -340,7 +340,7 @@ find_block_device() {
                 echo $_dev
                 return 0
             fi
-        done < <(findmnt -e -v -n -o 'MAJ:MIN,SOURCE' "$_find_mpt")
+        done < <(findmnt -e -v -n -o 'MAJ:MIN,SOURCE' --target "$_find_mpt")
     fi
     # fall back to /etc/fstab
 
@@ -362,7 +362,7 @@ find_block_device() {
             echo $_dev
             return 0
         fi
-    done < <(findmnt -e --fstab -v -n -o 'MAJ:MIN,SOURCE' "$_find_mpt")
+    done < <(findmnt -e --fstab -v -n -o 'MAJ:MIN,SOURCE' --target "$_find_mpt")
 
     return 1
 }
@@ -384,7 +384,7 @@ find_mp_fstype() {
             [[ $_fs = "autofs" ]] && continue
             echo -n $_fs
             return 0
-        done < <(findmnt -e -v -n -o 'FSTYPE' "$1")
+        done < <(findmnt -e -v -n -o 'FSTYPE' --target "$1")
     fi
 
     while read _fs; do
@@ -392,7 +392,7 @@ find_mp_fstype() {
         [[ $_fs = "autofs" ]] && continue
         echo -n $_fs
         return 0
-    done < <(findmnt --fstab -e -v -n -o 'FSTYPE' "$1")
+    done < <(findmnt --fstab -e -v -n -o 'FSTYPE' --target "$1")
 
     return 1
 }
@@ -406,10 +406,28 @@ find_mp_fstype() {
 # $ find_dev_fstype /dev/sda2;echo
 # ext4
 find_dev_fstype() {
-    local _x _mpt _majmin _dev _fs _maj _min _find_dev
+    local _find_dev _fs
     _find_dev="$1"
     [[ "$_find_dev" = /dev* ]] || _find_dev="/dev/block/$_find_dev"
-    find_mp_fstype "$_find_dev"
+
+    if [[ $use_fstab != yes ]]; then
+        while read _fs; do
+            [[ $_fs ]] || continue
+            [[ $_fs = "autofs" ]] && continue
+            echo -n $_fs
+            return 0
+        done < <(findmnt -e -v -n -o 'FSTYPE' --source "$_find_dev")
+    fi
+
+    while read _fs; do
+        [[ $_fs ]] || continue
+        [[ $_fs = "autofs" ]] && continue
+        echo -n $_fs
+        return 0
+    done < <(findmnt --fstab -e -v -n -o 'FSTYPE' --source "$_find_dev")
+
+    return 1
+
 }
 
 # finds the major:minor of the block device backing the root filesystem.
index 7481ac0..42a261e 100755 (executable)
--- a/dracut.sh
+++ b/dracut.sh
@@ -789,7 +789,7 @@ chmod 755 "$initdir"
 
 if [[ $hostonly ]]; then
     for i in /sys /proc /run /dev; do
-        if ! findmnt "$i" &>/dev/null; then
+        if ! findmnt --target "$i" &>/dev/null; then
             dwarning "Turning off host-only mode: '$i' is not mounted!"
             unset hostonly
         fi
index f6f4b77..eb75599 100755 (executable)
@@ -5,6 +5,6 @@
 SECURITYFSDIR="/sys/kernel/security"
 export SECURITYFSDIR
 
-if ! findmnt "${SECURITYFSDIR}" >/dev/null 2>&1; then
+if ! findmnt --target "${SECURITYFSDIR}" >/dev/null 2>&1; then
    mount -t securityfs -o nosuid,noexec,nodev securityfs ${SECURITYFSDIR} >/dev/null 2>&1
 fi