Skip to content

Commit

Permalink
wdctl: Workaround reported boot-status bits not being present in wd->…
Browse files Browse the repository at this point in the history
…ident.options

Some watchdog drivers are capable of reporting WDIOF_CARDRESET in their
bootstatus, but they do not advertise this in the options field
returned by the WDIOC_GETSUPPORT ioctl.

This causes wdctl to not print the CARDRESET flag on these devices,
even when the reset was caused by the watchdog and this is being
reported in the WDIOC_GETBOOTSTATUS return.

Add a workaround by or-ing any bits which are set in the status and
bstatus returns into wd->ident.options so that reported flags will
get printend independent of them being advertised as supported in
wd->ident.options.

This will make wdctl print a CARDRESET line when the system was
actually reset by the watchdog while omitting it when it was not
reset by the watchdog.  At least on drivers which have the
CARDRESET is missing from info.options problem.  On other drivers
the CARDRESET line will always be printend, but the actual reported
value will change.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  • Loading branch information
jwrdegoede authored and karelzak committed Aug 18, 2021
1 parent e826aa3 commit b1b0259
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sys-utils/wdctl.c
Expand Up @@ -419,6 +419,13 @@ static int read_watchdog_from_device(struct wd_device *wd)
ioctl(fd, WDIOC_GETSTATUS, &wd->status);
ioctl(fd, WDIOC_GETBOOTSTATUS, &wd->bstatus);

/*
* Sometimes supported options like WDIOF_CARDRESET are missing from
* ident.options, add anything set in status/bstatus to ident.options.
*/
wd->ident.options |= wd->status;
wd->ident.options |= wd->bstatus;

if (ioctl(fd, WDIOC_GETTIMEOUT, &wd->timeout) >= 0)
wd->has_timeout = 1;
if (ioctl(fd, WDIOC_GETPRETIMEOUT, &wd->pretimeout) >= 0)
Expand Down

0 comments on commit b1b0259

Please sign in to comment.