kdump-lib.sh: remove useless echo and cat
upstream: fedora
resolves: bz2003832
conflict: none
commit 53813e8b9a
Author: Kairui Song <kasong@redhat.com>
Date: Wed Sep 8 02:48:17 2021 +0800
kdump-lib.sh: remove useless echo and cat
Replace echo "$(cmd)" and "var=$(cmd); echo $var" with just `cmd`.
And remove some useless cat.
Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Philipp Rudo <prudo@redhat.com>
Signed-off-by: Tao Liu <ltao@redhat.com>
This commit is contained in:
parent
c9f583baa4
commit
6dbf7c2e6c
34
kdump-lib.sh
34
kdump-lib.sh
@ -14,7 +14,7 @@ is_fadump_capable()
|
|||||||
# Check if firmware-assisted dump is enabled
|
# Check if firmware-assisted dump is enabled
|
||||||
# if no, fallback to kdump check
|
# if no, fallback to kdump check
|
||||||
if [[ -f $FADUMP_ENABLED_SYS_NODE ]]; then
|
if [[ -f $FADUMP_ENABLED_SYS_NODE ]]; then
|
||||||
rc=$(cat $FADUMP_ENABLED_SYS_NODE)
|
rc=$(<$FADUMP_ENABLED_SYS_NODE)
|
||||||
[[ $rc -eq 1 ]] && return 0
|
[[ $rc -eq 1 ]] && return 0
|
||||||
fi
|
fi
|
||||||
return 1
|
return 1
|
||||||
@ -59,13 +59,14 @@ to_dev_name() {
|
|||||||
|
|
||||||
case "$dev" in
|
case "$dev" in
|
||||||
UUID=*)
|
UUID=*)
|
||||||
dev=$(blkid -U "${dev#UUID=}")
|
blkid -U "${dev#UUID=}"
|
||||||
;;
|
;;
|
||||||
LABEL=*)
|
LABEL=*)
|
||||||
dev=$(blkid -L "${dev#LABEL=}")
|
blkid -L "${dev#LABEL=}"
|
||||||
;;
|
;;
|
||||||
|
*)
|
||||||
|
echo "$dev"
|
||||||
esac
|
esac
|
||||||
echo $dev
|
|
||||||
}
|
}
|
||||||
|
|
||||||
is_user_configured_dump_target()
|
is_user_configured_dump_target()
|
||||||
@ -93,12 +94,12 @@ get_block_dump_target()
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
_target=$(get_user_configured_dump_disk)
|
_target=$(get_user_configured_dump_disk)
|
||||||
[[ -n "$_target" ]] && echo $(to_dev_name $_target) && return
|
[[ -n "$_target" ]] && to_dev_name $_target && return
|
||||||
|
|
||||||
# Get block device name from local save path
|
# Get block device name from local save path
|
||||||
_path=$(get_save_path)
|
_path=$(get_save_path)
|
||||||
_target=$(get_target_from_path $_path)
|
_target=$(get_target_from_path $_path)
|
||||||
[[ -b "$_target" ]] && echo $(to_dev_name $_target)
|
[[ -b "$_target" ]] && to_dev_name $_target
|
||||||
}
|
}
|
||||||
|
|
||||||
is_dump_to_rootfs()
|
is_dump_to_rootfs()
|
||||||
@ -113,7 +114,7 @@ get_failure_action_target()
|
|||||||
if is_dump_to_rootfs; then
|
if is_dump_to_rootfs; then
|
||||||
# Get rootfs device name
|
# Get rootfs device name
|
||||||
_target=$(get_root_fs_device)
|
_target=$(get_root_fs_device)
|
||||||
[[ -b "$_target" ]] && echo $(to_dev_name $_target) && return
|
[[ -b "$_target" ]] && to_dev_name $_target && return
|
||||||
# Then, must be nfs root
|
# Then, must be nfs root
|
||||||
echo "nfs"
|
echo "nfs"
|
||||||
fi
|
fi
|
||||||
@ -441,7 +442,7 @@ check_crash_mem_reserved()
|
|||||||
{
|
{
|
||||||
local mem_reserved
|
local mem_reserved
|
||||||
|
|
||||||
mem_reserved=$(cat /sys/kernel/kexec_crash_size)
|
mem_reserved=$(</sys/kernel/kexec_crash_size)
|
||||||
if [[ $mem_reserved -eq 0 ]]; then
|
if [[ $mem_reserved -eq 0 ]]; then
|
||||||
derror "No memory reserved for crash kernel"
|
derror "No memory reserved for crash kernel"
|
||||||
return 1
|
return 1
|
||||||
@ -467,7 +468,7 @@ check_current_kdump_status()
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rc=$(cat /sys/kernel/kexec_crash_loaded)
|
rc=$(</sys/kernel/kexec_crash_loaded)
|
||||||
if [[ $rc == 1 ]]; then
|
if [[ $rc == 1 ]]; then
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
@ -566,7 +567,7 @@ is_secure_boot_enforced()
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Detect secure boot on s390x
|
# Detect secure boot on s390x
|
||||||
if [[ -e "/sys/firmware/ipl/secure" && "$(cat /sys/firmware/ipl/secure)" == "1" ]]; then
|
if [[ -e "/sys/firmware/ipl/secure" && "$(</sys/firmware/ipl/secure)" == "1" ]]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -627,7 +628,7 @@ prepare_kdump_bootinfo()
|
|||||||
boot_imglist="$KDUMP_IMG-$KDUMP_KERNELVER$KDUMP_IMG_EXT $machine_id/$KDUMP_KERNELVER/$KDUMP_IMG"
|
boot_imglist="$KDUMP_IMG-$KDUMP_KERNELVER$KDUMP_IMG_EXT $machine_id/$KDUMP_KERNELVER/$KDUMP_IMG"
|
||||||
|
|
||||||
# Use BOOT_IMAGE as reference if possible, strip the GRUB root device prefix in (hd0,gpt1) format
|
# Use BOOT_IMAGE as reference if possible, strip the GRUB root device prefix in (hd0,gpt1) format
|
||||||
local boot_img="$(cat /proc/cmdline | sed "s/^BOOT_IMAGE=\((\S*)\)\?\(\S*\) .*/\2/")"
|
local boot_img="$(sed "s/^BOOT_IMAGE=\((\S*)\)\?\(\S*\) .*/\2/" /proc/cmdline)"
|
||||||
if [[ -n "$boot_img" ]]; then
|
if [[ -n "$boot_img" ]]; then
|
||||||
boot_imglist="$boot_img $boot_imglist"
|
boot_imglist="$boot_img $boot_imglist"
|
||||||
fi
|
fi
|
||||||
@ -708,7 +709,7 @@ prepare_cmdline()
|
|||||||
local cmdline id
|
local cmdline id
|
||||||
|
|
||||||
if [[ -z "$1" ]]; then
|
if [[ -z "$1" ]]; then
|
||||||
cmdline=$(cat /proc/cmdline)
|
cmdline=$(</proc/cmdline)
|
||||||
else
|
else
|
||||||
cmdline="$1"
|
cmdline="$1"
|
||||||
fi
|
fi
|
||||||
@ -762,7 +763,7 @@ prepare_cmdline()
|
|||||||
#get system memory size in the unit of GB
|
#get system memory size in the unit of GB
|
||||||
get_system_size()
|
get_system_size()
|
||||||
{
|
{
|
||||||
result=$(cat /proc/iomem | grep "System RAM" | awk -F ":" '{ print $1 }' | tr [:lower:] [:upper:] | paste -sd+)
|
result=$(grep "System RAM" /proc/iomem | awk -F ":" '{ print $1 }' | tr [:lower:] [:upper:] | paste -sd+)
|
||||||
result="+$result"
|
result="+$result"
|
||||||
# replace '-' with '+0x' and '+' with '-0x'
|
# replace '-' with '+0x' and '+' with '-0x'
|
||||||
sum=$( echo $result | sed -e 's/-/K0x/g' | sed -e 's/+/-0x/g' | sed -e 's/K/+/g' )
|
sum=$( echo $result | sed -e 's/-/K0x/g' | sed -e 's/+/-0x/g' | sed -e 's/K/+/g' )
|
||||||
@ -871,11 +872,10 @@ kdump_get_maj_min() {
|
|||||||
|
|
||||||
get_all_kdump_crypt_dev()
|
get_all_kdump_crypt_dev()
|
||||||
{
|
{
|
||||||
local _dev _crypt
|
local _dev
|
||||||
|
|
||||||
for _dev in $(get_block_dump_target); do
|
for _dev in $(get_block_dump_target); do
|
||||||
_crypt=$(get_luks_crypt_dev $(kdump_get_maj_min "$_dev"))
|
get_luks_crypt_dev "$(kdump_get_maj_min "$_dev")"
|
||||||
[[ -n "$_crypt" ]] && echo $_crypt
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -944,7 +944,7 @@ get_kernel_size()
|
|||||||
|
|
||||||
# Fallback to use iomem
|
# Fallback to use iomem
|
||||||
local _size=0
|
local _size=0
|
||||||
for _seg in $(cat /proc/iomem | grep -E "Kernel (code|rodata|data|bss)" | cut -d ":" -f 1); do
|
for _seg in $(grep -E "Kernel (code|rodata|data|bss)" /proc/iomem | cut -d ":" -f 1); do
|
||||||
_size=$(( $_size + 0x${_seg#*-} - 0x${_seg%-*} ))
|
_size=$(( $_size + 0x${_seg#*-} - 0x${_seg%-*} ))
|
||||||
done
|
done
|
||||||
echo $_size
|
echo $_size
|
||||||
|
Loading…
Reference in New Issue
Block a user