move get_persistent_dev to dracut-functions.sh

kdump module also need to convert dev name to udev symlinks.
So better to move function get_persistent_dev() to dracut-functions.sh

Also in this patch improvement and fix the original function:
a) use udevadm info --query=name to get the kernel name.
   This will fix the issue caused by passing symbolic link of a device.
b) fix a bug to compare $_tmp instead of $i with $_dev. Really sorry,
   should have tested more carefully.

Signed-off-by: Dave Young <dyoung@redhat.com>
master
Dave Young 2012-09-10 16:10:46 +08:00 committed by Harald Hoyer
parent ba111df2b9
commit ff0636635a
2 changed files with 15 additions and 13 deletions

View File

@ -239,6 +239,21 @@ else
}
fi

get_persistent_dev() {
local i _tmp _dev

_dev=$(udevadm info --query=name --name="$1" 2>/dev/null)
[ -z "$_dev" ] && return

for i in /dev/disk/by-id/*; do
_tmp=$(udevadm info --query=name --name="$i" 2>/dev/null)
if [ "$_tmp" = "$_dev" ]; then
echo $i
return
fi
done
}

# get_fs_env <device>
# Get and set the ID_FS_TYPE and ID_FS_UUID variable from udev for a device.
# Example:

View File

@ -11,19 +11,6 @@ depends() {
return 0
}

get_persistent_dev() {
local i _tmp
local _dev=${1##*/}

for i in /dev/disk/by-id/*; do
_tmp=$(readlink $i)
if [ "$i" = "$_dev" ]; then
echo $i
return
fi
done
}

install() {
local _d
dracut_install mount mknod mkdir pidof sleep chroot \