mkdumprd: move to_dev_name() & get_persistent_dev() to kdump-lib.sh

to_dev_name() and get_persistent_dev() can be used by function in kdumpctl.
Therefore moving them to kdump-lib.sh.

No functional changes.

Signed-off-by: Pratyush Anand <panand@redhat.com>
Acked-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Baoquan He <xlpang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
This commit is contained in:
Pratyush Anand 2016-05-09 13:47:54 +05:30 committed by Dave Young
parent 28e8c4b5ac
commit d1424f3f66
2 changed files with 49 additions and 49 deletions

View File

@ -7,6 +7,15 @@ DEFAULT_PATH="/var/crash/"
FENCE_KDUMP_CONFIG_FILE="/etc/sysconfig/fence_kdump"
FENCE_KDUMP_SEND="/usr/libexec/fence_kdump_send"
perror_exit() {
echo $@ >&2
exit 1
}
perror() {
echo $@ >&2
}
is_ssh_dump_target()
{
grep -q "^ssh[[:blank:]].*@" /etc/kdump.conf
@ -63,6 +72,46 @@ is_generic_fence_kdump()
grep -q "^fence_kdump_nodes" /etc/kdump.conf
}
to_dev_name() {
local dev="${1//\"/}"
case "$dev" in
UUID=*)
dev=`blkid -U "${dev#UUID=}"`
;;
LABEL=*)
dev=`blkid -L "${dev#LABEL=}"`
;;
esac
echo $dev
}
get_persistent_dev() {
local i _tmp _dev _lookup_dirs
_dev=$(udevadm info --query=name --name="$1" 2>/dev/null)
[ -z "$_dev" ] && {
perror_exit "Kernel dev name of $1 is not found."
}
if [[ $2 = "raw" ]];then
_lookup_dirs="/dev/mapper/* /dev/disk/by-id/*"
else
_lookup_dirs="/dev/mapper/* /dev/disk/by-uuid/* /dev/disk/by-id/*"
fi
for i in $_lookup_dirs; do
_tmp=$(udevadm info --query=name --name="$i" 2>/dev/null)
if [ "$_tmp" = "$_dev" ]; then
echo $i
return
fi
done
perror "WARNING: Persistent device name of $1 not found. Using $1 as dump target name"
echo $1
}
get_user_configured_dump_disk()
{
local _target

View File

@ -20,41 +20,6 @@ extra_modules=""
dracut_args=("--hostonly" "-o" "plymouth dash resume ifcfg")
OVERRIDE_RESETTABLE=0
perror_exit() {
echo $@ >&2
exit 1
}
perror() {
echo $@ >&2
}
get_persistent_dev() {
local i _tmp _dev _lookup_dirs
_dev=$(udevadm info --query=name --name="$1" 2>/dev/null)
[ -z "$_dev" ] && {
perror_exit "Kernel dev name of $1 is not found."
}
if [[ $2 = "raw" ]];then
_lookup_dirs="/dev/mapper/* /dev/disk/by-id/*"
else
_lookup_dirs="/dev/mapper/* /dev/disk/by-uuid/* /dev/disk/by-id/*"
fi
for i in $_lookup_dirs; do
_tmp=$(udevadm info --query=name --name="$i" 2>/dev/null)
if [ "$_tmp" = "$_dev" ]; then
echo $i
return
fi
done
perror "WARNING: Persistent device name of $1 not found. Using $1 as dump target name"
echo $1
}
add_dracut_arg() {
local arg qarg is_quoted=0
while [ $# -gt 0 ];
@ -331,20 +296,6 @@ check_block_and_slaves() {
return 1
}
to_dev_name() {
local dev="${1//\"/}"
case "$dev" in
UUID=*)
dev=`blkid -U "${dev#UUID=}"`
;;
LABEL=*)
dev=`blkid -L "${dev#LABEL=}"`
;;
esac
echo $dev
}
get_block_dump_target()
{
local _target