From 320bd209fe2ffdd9649ce4e4e7b8d910dd29c297 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 19 Nov 2020 17:06:58 +0800 Subject: [PATCH] Add a helper for detecting watchdog drivers Signed-off-by: Kairui Song Acked-by: Lianbo Jiang --- kdump-lib.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/kdump-lib.sh b/kdump-lib.sh index 748419f..43116a9 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -744,6 +744,25 @@ prepare_kdump_bootinfo() fi } +get_watchdog_drvs() +{ + local _wdtdrvs _drv _dir + + for _dir in /sys/class/watchdog/*; do + # device/modalias will return driver of this device + [[ -f "$_dir/device/modalias" ]] || continue + _drv=$(< "$_dir/device/modalias") + _drv=$(modprobe --set-version "$KDUMP_KERNELVER" -R $_drv 2>/dev/null) + for i in $_drv; do + if ! [[ " $_wdtdrvs " == *" $i "* ]]; then + _wdtdrvs="$_wdtdrvs $i" + fi + done + done + + echo $_wdtdrvs +} + # # prepare_cmdline # This function performs a series of edits on the command line.