Blob Blame History Raw
From 27790828d1d96eee7c77ac47047f0d57bb6c0f94 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Mon, 30 Jul 2012 17:04:55 +0200
Subject: [PATCH] base/dracut-lib.sh: fixed ismounted(<mountpoint>)

---
 modules.d/99base/dracut-lib.sh | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
index b4ef59a..b638bd6 100755
--- a/modules.d/99base/dracut-lib.sh
+++ b/modules.d/99base/dracut-lib.sh
@@ -453,15 +453,26 @@ udevproperty() {
 }
 
 find_mount() {
-    local dev mnt etc wanted_dev="$(readlink -e -q $1)"
+    local dev mnt etc wanted_dev
+    wanted_dev="$(readlink -e -q $1)"
     while read dev mnt etc; do
         [ "$dev" = "$wanted_dev" ] && echo "$dev" && return 0
     done < /proc/mounts
     return 1
 }
 
+# usage: ismounted <mountpoint>
+# usage: ismounted /dev/<device>
 ismounted() {
-    find_mount "$1" > /dev/null
+    if str_starts "$1" "/dev"; then
+        find_mount "$1" > /dev/null && return 0
+        return 1
+    fi
+
+    while read a m a; do
+        [ "$m" = "$1" ] && return 0
+    done < /proc/mounts
+    return 1
 }
 
 wait_for_if_up() {