cdown / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone

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

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