Blame SOURCES/0009-wdctl-Workaround-reported-boot-status-bits-not-being.patch

87ca29
From 006aca565d4c8565baf05296b8e65ca4d5f203d3 Mon Sep 17 00:00:00 2001
87ca29
From: Hans de Goede <hdegoede@redhat.com>
87ca29
Date: Fri, 30 Jul 2021 13:22:54 +0200
87ca29
Subject: wdctl: Workaround reported boot-status bits not being present in
87ca29
 wd->ident.options
87ca29
87ca29
Some watchdog drivers are capable of reporting WDIOF_CARDRESET in their
87ca29
bootstatus, but they do not advertise this in the options field
87ca29
returned by the WDIOC_GETSUPPORT ioctl.
87ca29
87ca29
This causes wdctl to not print the CARDRESET flag on these devices,
87ca29
even when the reset was caused by the watchdog and this is being
87ca29
reported in the WDIOC_GETBOOTSTATUS return.
87ca29
87ca29
Add a workaround by or-ing any bits which are set in the status and
87ca29
bstatus returns into wd->ident.options so that reported flags will
87ca29
get printend independent of them being advertised as supported in
87ca29
wd->ident.options.
87ca29
87ca29
This will make wdctl print a CARDRESET line when the system was
87ca29
actually reset by the watchdog while omitting it when it was not
87ca29
reset by the watchdog.  At least on drivers which have the
87ca29
CARDRESET is missing from info.options problem.  On other drivers
87ca29
the CARDRESET line will always be printend, but the actual reported
87ca29
value will change.
87ca29
87ca29
Upstream: http://github.com/util-linux/util-linux/commit/b1b0259fe42aad1bf0997ce1c03a020ce59e38ab
87ca29
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2057046
87ca29
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
87ca29
---
87ca29
 sys-utils/wdctl.c | 7 +++++++
87ca29
 1 file changed, 7 insertions(+)
87ca29
87ca29
diff --git a/sys-utils/wdctl.c b/sys-utils/wdctl.c
87ca29
index 8de5d5a2d..6b9affa0a 100644
87ca29
--- a/sys-utils/wdctl.c
87ca29
+++ b/sys-utils/wdctl.c
87ca29
@@ -419,6 +419,13 @@ static int read_watchdog_from_device(struct wd_device *wd)
87ca29
 		ioctl(fd, WDIOC_GETSTATUS, &wd->status);
87ca29
 		ioctl(fd, WDIOC_GETBOOTSTATUS, &wd->bstatus);
87ca29
 
87ca29
+		/*
87ca29
+		 * Sometimes supported options like WDIOF_CARDRESET are missing from
87ca29
+		 * ident.options, add anything set in status/bstatus to ident.options.
87ca29
+		 */
87ca29
+		wd->ident.options |= wd->status;
87ca29
+		wd->ident.options |= wd->bstatus;
87ca29
+
87ca29
 		if (ioctl(fd, WDIOC_GETTIMEOUT, &wd->timeout) >= 0)
87ca29
 			wd->has_timeout = 1;
87ca29
 		if (ioctl(fd, WDIOC_GETPRETIMEOUT, &wd->pretimeout) >= 0)
87ca29
-- 
87ca29
2.34.1
87ca29