[PATCH] dracut: use findmnt instead of find_mount

Will Woods wwoods at redhat.com
Tue Sep 18 16:56:44 UTC 2012


findmnt is better at this than we are - it handles NFS lookup
(host/path -> mount) correctly and gets the right canonical name
for LVM devices.

Since upstream is probably moving to using findmnt for this, we should
be probably be using it. Plus it means we don't need to maintain all the
logic ourselves.
---
 dracut/anaconda-lib.sh      | 8 --------
 dracut/fetch-kickstart-disk | 2 +-
 dracut/fetch-updates-disk   | 2 +-
 dracut/module-setup.sh      | 1 +
 4 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/dracut/anaconda-lib.sh b/dracut/anaconda-lib.sh
index 6b9a707..24a9643 100755
--- a/dracut/anaconda-lib.sh
+++ b/dracut/anaconda-lib.sh
@@ -125,14 +125,6 @@ disk_to_dev_path() {
     esac
 }
 
-find_mount() {
-    local dev mnt etc wanted_dev="$(readlink -e -q $1)"
-    while read dev mnt etc; do
-        [ "$dev" = "$wanted_dev" ] && echo $mnt && return 0
-    done < /proc/mounts
-    return 1
-}
-
 when_diskdev_appears() {
     local dev="${1#/dev/}" cmd=""; shift
     cmd="/sbin/initqueue --settled --onetime --name $1 $*"
diff --git a/dracut/fetch-kickstart-disk b/dracut/fetch-kickstart-disk
index 3172049..c81d072 100755
--- a/dracut/fetch-kickstart-disk
+++ b/dracut/fetch-kickstart-disk
@@ -11,7 +11,7 @@ path="${2:-/ks.cfg}"
 [ -b "$dev" ] || exit 1
 
 info "anaconda: fetching kickstart from $dev:$path"
-mnt="$(find_mount $dev)"
+mnt="$(findmnt -eno TARGET $dev)"
 
 if [ -n "$mnt" ]; then
     cp $mnt$path /tmp/ks.cfg
diff --git a/dracut/fetch-updates-disk b/dracut/fetch-updates-disk
index 168fe5d..e245027 100755
--- a/dracut/fetch-updates-disk
+++ b/dracut/fetch-updates-disk
@@ -12,7 +12,7 @@ path="${2:-/updates.img}"
 
 info "anaconda: fetching updates from $dev:$path"
 
-mnt="$(find_mount $dev)"
+mnt="$(findmnt -eno TARGET $dev)"
 if [ -n "$mnt" ]; then
     cp $mnt$path /tmp/updates.img
 else
diff --git a/dracut/module-setup.sh b/dracut/module-setup.sh
index 7705f1b..2e0c6e0 100755
--- a/dracut/module-setup.sh
+++ b/dracut/module-setup.sh
@@ -15,6 +15,7 @@ depends() {
 }
 
 install() {
+    dracut_install findmnt
     # anaconda
     inst "$moddir/anaconda-lib.sh" "/lib/anaconda-lib.sh"
     inst_hook cmdline 25 "$moddir/parse-anaconda-options.sh"
-- 
1.7.11.4



More information about the anaconda-patches mailing list