watchdog adaptability

Rob Landley rob at landley.net
Mon Jan 9 00:50:24 UTC 2006


On Friday 06 January 2006 18:35, Rob Landley wrote:
> On Friday 06 January 2006 14:44, David Updegraff wrote:
> > Hi.
> >
> > wouldn't it be nice if 'watchdog' at least tried to figure out what the
> > period of the watchdog-o-the-day was instead of assuming 30 secs?
> >
> > For your consideration: enclosed.
> >
> > -dbu.
>
> Sounds reasonable.  Is there anything we're supposed to include other than
> linux/watchdog.h to get the ioctl timeout macro thing?
>
> Rob

Ok, the reason this isn't going into 1.1.0 is:

home/landley/busybox/busybox/miscutils/watchdog.c: In function 
`watchdog_main':
/home/landley/busybox/busybox/miscutils/watchdog.c:53: error: 
`WDIOC_GETTIMEOUT' undeclared (first use in this function)
/home/landley/busybox/busybox/miscutils/watchdog.c:53: error: (Each undeclared 
identifier is reported only once
/home/landley/busybox/busybox/miscutils/watchdog.c:53: error: for each 
function it appears in.)
make[1]: *** [/home/landley/busybox/busybox/miscutils/watchdog.o] Error 1

Ubuntu did a really crappy job of sanitizing that kernel header, and trying to 
#include it from userspace simply doesn't work.  Mazur did a much better job 
but A) not everybody uses his stuff, B) he seems to have been abducted by 
aliens recently and the last update was 2.6.12.

The #define we need is:

#define WDIOC_GETTIMEOUT        _IOR(WATCHDOG_IOCTL_BASE, 7, int)

And _IOR() is defined in asm/ioctl.h which means it's _platform_specific_.  
The i386 version is:

#define _IOR(type,nr,size)      _IOC(_IOC_READ,(type),(nr), \
 (_IOC_TYPECHECK(size)))

And _IOC is farther up in the same file:

#define _IOC(dir,type,nr,size) \
        (((dir)  << _IOC_DIRSHIFT) | \
         ((type) << _IOC_TYPESHIFT) | \
         ((nr)   << _IOC_NRSHIFT) | \
         ((size) << _IOC_SIZESHIFT))

And those constants are, of course, platform specific.

This is deep in the land of "not going there just now".

Rob
-- 
Steve Ballmer: Innovation!  Inigo Montoya: You keep using that word.
I do not think it means what you think it means.



More information about the busybox mailing list