Install kernel module for active watchdog
master
Harald Hoyer 2016-04-15 10:56:31 +02:00
commit ad438af207
1 changed files with 38 additions and 0 deletions

View File

@ -12,6 +12,11 @@ depends() {

# called by dracut
install() {
# Do not add watchdog hooks if systemd module is included
# In that case, systemd will manage watchdog kick
if dracut_module_included "systemd"; then
return
fi
inst_hook cmdline 00 "$moddir/watchdog.sh"
inst_hook cmdline 50 "$moddir/watchdog.sh"
inst_hook pre-trigger 00 "$moddir/watchdog.sh"
@ -27,3 +32,36 @@ install() {
inst_multiple -o wdctl
}

installkernel() {
[[ -d /sys/class/watchdog/ ]] || return
wdtcmdline=""
for dir in /sys/class/watchdog/*; do
[[ -d "$dir" ]] || continue
[[ -f "$dir/state" ]] || continue
active=$(< "$dir/state")
! [[ $hostonly ]] || [[ "$active" = "active" ]] || continue
# device/modalias will return driver of this device
wdtdrv=$(< "$dir/device/modalias")
# There can be more than one module represented by same
# modalias. Currently load all of them.
# TODO: Need to find a way to avoid any unwanted module
# represented by modalias
wdtdrv=$(modprobe -R $wdtdrv)
instmods $wdtdrv
wdtcmdline="$wdtcmdline$(echo $wdtdrv | tr " " ","),"
# however in some cases, we also need to check that if there is
# a specific driver for the parent bus/device. In such cases
# we also need to enable driver for parent bus/device.
wdtppath=$(readlink -f "$dir/device/..")
while [ -f "$wdtppath/modalias" ]
do
wdtpdrv=$(< "$wdtppath/modalias")
wdtpdrv=$(modprobe -R $wdtpdrv)
instmods $wdtpdrv
wdtcmdline="$wdtcmdline$(echo $wdtpdrv | tr " " ","),"
wdtppath=$(readlink -f "$wdtppath/..")
done
done
# ensure that watchdog module is loaded as early as possible
[[ $wdtcmdline = "" ]] || echo "rd.driver.pre=$wdtcmdline" > ${initdir}/etc/cmdline.d/00-watchdog.conf
}