chiark / gitweb /
watchdog: Don't require WDIOC_SETOPTIONS/WDIOS_ENABLECARD
authorJean Delvare <jdelvare@suse.de>
Wed, 17 Jun 2015 16:57:39 +0000 (18:57 +0200)
committerSven Eden <yamakuzure@gmx.net>
Tue, 14 Mar 2017 09:03:48 +0000 (10:03 +0100)
Not all watchdog drivers implement WDIOC_SETOPTIONS. Drivers which do
not implement it have their device always enabled. So it's fine to
report an error if WDIOS_DISABLECARD is passed and the ioctl is not
implemented, however failing when WDIOS_ENABLECARD is passed and the
ioctl is not implemented is not good: if the device was already
enabled then WDIOS_ENABLECARD was a no-op and wasn't needed in the
first place. So we can just ignore the error and continue.

src/shared/watchdog.c

index 2fe4eb81cfbeb6afcbf4dce27e5eba5cbef19f27..9d39beb3404deee679733c33f1d14ea43da890bc 100644 (file)
@@ -60,8 +60,13 @@ static int update_timeout(void) {
 
                 flags = WDIOS_ENABLECARD;
                 r = ioctl(watchdog_fd, WDIOC_SETOPTIONS, &flags);
-                if (r < 0)
-                        return log_warning_errno(errno, "Failed to enable hardware watchdog: %m");
+                if (r < 0) {
+                        /* ENOTTY means the watchdog is always enabled so we're fine */
+                        log_full(errno == ENOTTY ? LOG_DEBUG : LOG_WARNING,
+                                 "Failed to enable hardware watchdog: %m");
+                        if (errno != ENOTTY)
+                                return -errno;
+                }
 
                 r = ioctl(watchdog_fd, WDIOC_KEEPALIVE, 0);
                 if (r < 0)