[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[openap-cvs] : openap-main/config/wl11000 dog.c,NONE,1.1
From: |
David Kimdon <address@hidden> |
Subject: |
[openap-cvs] : openap-main/config/wl11000 dog.c,NONE,1.1 |
Date: |
Wed, 31 Jul 2002 21:54:28 -0400 |
Update of /cvsroot/openap/openap-main/config/wl11000
In directory subversions:/tmp/cvs-serv27056/config/wl11000
Added Files:
dog.c
Log Message:
notes on watchdog and untested daemon
--- NEW FILE ---
/*
Copyright (C) 2001-2002 Instant802 Networks Inc. , All Rights Reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This daemon opens /dev/watchdog (thus enabling the hardware
watchdog) and periodically writes bytes to it (thus preventing the
hardware watchdog from rebooting us). If we get SIGUSR1 (10,
probably) we disable the watchdog. Only after the watchdog is
disabled can this process be killed without the hardware rebooting
us.
We need to disable the watchdog when we reflash the unit. For some
reason the flash driver prevents the watchdog from being ack'ed
when it is doing a lot of work. If we are rebooted while flash is
in a inconsistent state the unit becomes a useless brick.
*/
#include <signal.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/types.h>
#include <linux/watchdog.h>
#define WATCHDOG_PERIOD 30 /* seconds between watchdog writes */
static int dog;
/* disable the watchdog */
static void sig_handler(int unused)
{
int arg = WDIOS_DISABLECARD;
if (ioctl(dog, WDIOC_SETOPTIONS, &arg) == -1) {
perror("ioctl(WDIOC_SETOPTIONS)");
}
}
int main(int argc, char *argv[])
{
signal(SIGUSR1, sig_handler);
if ((dog = open("/dev/watchdog", O_WRONLY)) == -1) {
perror("open /dev/watchdog");
exit(1);
}
while (1) {
sleep(WATCHDOG_PERIOD);
/* ack the watchdog */
write(dog, "\0", 1);
fsync(dog);
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [openap-cvs] : openap-main/config/wl11000 dog.c,NONE,1.1,
David Kimdon <address@hidden> <=