Patch: softdog and WDIOS_DISABLECARD

From: Shane Wegner (shane@cm.nu)
Date: Wed May 02 2001 - 02:33:59 EST


Hi,

I have found a potential problem with the current
implementation of the software watchdog. I have
CONFIG_WATCHDOG_NOWAYOUT set for a reliable watchdog.
However, there are instances where I want to explicitly
shut it down. The problem with disabling
CONFIG_WATCHDOG_NOWAYOUT is that events other than an
explicit shutdown can disable the timer. A SIGSEGV
perhaps or the daemon being killed by the OOM handler. In
cases like this, the system should reboot IMO.

This small patch adds the appropriate options to enable and
disable the timer explicitly.

--- softdog.c.orig Wed May 2 00:15:56 2001
+++ softdog.c Wed May 2 00:15:19 2001
@@ -130,6 +130,7 @@
         static struct watchdog_info ident = {
                 identity: "Software Watchdog",
         };
+ int rv;
         switch (cmd) {
                 default:
                         return -ENOIOCTLCMD;
@@ -140,6 +141,25 @@
                 case WDIOC_GETSTATUS:
                 case WDIOC_GETBOOTSTATUS:
                         return put_user(0,(int *)arg);
+ case WDIOC_SETOPTIONS:
+ if(copy_from_user(&rv, (int*) arg, sizeof(int)))
+ return -EFAULT;
+
+ if (rv & WDIOS_DISABLECARD) {
+ lock_kernel();
+ del_timer(&watchdog_ticktock);
+ unlock_kernel();
+ return 0;
+ }
+
+ if (rv & WDIOS_ENABLECARD) {
+ lock_kernel();
+ mod_timer(&watchdog_ticktock, jiffies +
+ (soft_margin * HZ));
+ unlock_kernel();
+ return 0;
+ }
+
                 case WDIOC_KEEPALIVE:
                         mod_timer(&watchdog_ticktock, jiffies+(soft_margin*HZ));
                         return 0;

-- 
Shane Wegner: shane@cm.nu
              http://www.cm.nu/~shane/
PGP:          1024D/FFE3035D
              A0ED DAC4 77EC D674 5487
              5B5C 4F89 9A4E FFE3 035D
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon May 07 2001 - 21:00:12 EST