Various fixes.
authorRichard W.M. Jones <rjones@redhat.com>
Thu, 9 Jan 2014 14:03:45 +0000 (14:03 +0000)
committerRichard W.M. Jones <rjones@redhat.com>
Thu, 9 Jan 2014 14:05:17 +0000 (14:05 +0000)
Makefile
README
watchdog-test.c

index acc7597..f221823 100644 (file)
--- a/Makefile
+++ b/Makefile
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
+CC = gcc
+CFLAGS = -Wall
+
 all: watchdog-test
 
 clean:
        rm -f watchdog-test *~
 
 watchdog-test: watchdog-test.o
-       $(CC) -static $< -o $@
+       $(CC) $(CFLAGS) -static $< -o $@
+
+.c.o:
+       $(CC) $(CFLAGS) -c $< -o $@
diff --git a/README b/README
index 629257c..62e1c1d 100644 (file)
--- a/README
+++ b/README
@@ -29,8 +29,14 @@ model can be either 'i6300esb' or 'ib700'.
 action can be: 'reset', 'shutdown', 'poweroff', 'pause',
 'none' or 'dump'
 
-(4) Install the statically linked watchdog-test binary in a Linux
+(4) Install the statically linked watchdog-test binary in the Linux
 guest.
 
-(5) Boot up the guest.  Log into the guest, run the watchdog-test
-binary (as root), and follow instructions.
+(5) Boot up the guest.  Log into the guest.
+
+(6) [ib700 only] You have to load the ib700wdt kernel module manually
+since it's an ISA device:
+
+  sudo modprobe ib700wdt
+
+(7) Run the watchdog-test binary (as root), and follow instructions.
index de855a8..d4e6305 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <unistd.h>
 #include <time.h>
 #include <fcntl.h>
@@ -30,7 +31,7 @@
 int
 main ()
 {
-  int fd, i;
+  int fd;
   int timeout;
   char input[256];
   time_t start_t, t;
@@ -56,7 +57,7 @@ main ()
   printf ("Do you want to start the test?  Type \"yes\" without quotes:\n");
 
   if (fgets (input, sizeof input, stdin) == NULL ||
-      strcmp (input, "yes") != 0) {
+      strncmp (input, "yes", 3) != 0) {
     printf ("Exiting the program.\n");
     exit (EXIT_SUCCESS);
   }
@@ -81,7 +82,7 @@ main ()
   if (ioctl (fd, WDIOC_GETTIMEOUT, &timeout) == -1)
     perror ("ioctl: WDIOC_GETTIMEOUT");
   else {
-    printf ("Timeout is set to %d seconds.\n");
+    printf ("Timeout is set to %d seconds.\n", timeout);
     if (timeout != WATCHDOG_TIMEOUT)
       printf ("Note: some watchdog devices don't support setting exact timeout values.\n");
   }
@@ -101,14 +102,16 @@ main ()
 
     sleep (3);
 
+    printf ("ping ");
     if (ioctl (fd, WDIOC_KEEPALIVE, 0) == -1)
-      perror ("ioctl: WDIOC_KEEPALIVE");
-    printf ("* ");
+      perror ("\nioctl: WDIOC_KEEPALIVE");
   }
 
   printf ("\n");
+  printf ("\n");
   printf ("Stopping pings.\n");
-  printf ("The watchdog action should happen at around %d mark.\n");
+  printf ("The watchdog action should happen at approximately %d second mark.\n",
+          WATCHDOG_TIMEOUT);
   printf ("\n");
 
   time (&start_t);