watchdog-5.15/0000755000175000017500000000000012664037572013046 5ustar michaelmichaelwatchdog-5.15/ChangeLog0000644000175000017500000003375212664037554014632 0ustar michaelmichaelFri Feb 23 13:26:14 MET 1996 - Watchdog 1.0 released. Tue Mar 5 09:11:34 MET 1996 - Fixed two bugs in watchdog.c reported (and patched) by Johannes Kroeger : Watchdog now tries to open /dev/watchdog before tugging its process ID away. - Released version 1.1 Thu May 23 14:20:59 MET DST 1996 - Added process table watch routine. - Process filemode before sleeping. - Released version 1.2 Thu May 30 13:00:44 MET DST 1996 - Watchdog now correctly shuts down the system if the process table is full Mon Jul 29 13:51:42 MET DST 1996 - Finally watchdog is able to shut down the system even if the process table remains full after killing all processes. - Released version 2.0 (this was a major overhaul) Fri Jan 31 13:39:43 MET 1997 - Disconnect deamon from console. - Close file descriptors 0, 1, 2 when compiled with USE_SYSLOG. - Cleaned up source code. - Write the softdog device between each check, since the increasing number of checks might cause problems otherise. - Test the system load average and reboot if it is too high. Thu Apr 3 11:14:07 MET DST 1997 - Fixed that nasty bug that caused the root partion to stay mounted during a soft reboot. - Fixed another bug that caused watchdog to kill itself during reboot before all the work was done. Wed Jun 4 20:16:23 CEST 1997 - Finally soft reboot works as advertised. - Tested NFS access in filemode. Fri Jun 6 22:55:16 CEST 1997 - Added ping mode: soft reboot is initiated if a given network/host does not answer. Wen Jun 11 09:25:36 CEST 1997 - Added file table check: reboot if file table overflow occurs. Mon Jun 16 12:10:55 CEST 1997 - Upgraded to mount 2.6g. - Compile and link with glibc. - Implemented call to user provides test binary. Tue Jun 17 13:35:15 CEST 1997 - Added examples for test scripts. Wed Jun 18 15:51:10 CEST 1997 - Default sleep interval now configurable via Makefile. Fri Jun 20 10:51:56 CEST 1997 - Added call to repair script. Tue Jun 24 15:31:03 CEST 1997 - Repair script now calls logger to create a syslog entry. Thu Jun 26 21:40:37 CEST 1997 - Fixed call of repair script. - Let watchdog sleep five seconds before closelog() to make sure everything is written to the logs. Mon Jun 30 13:48:08 CEST 1997 - Make sure files are only opened once. - Work even if there is no /dev/watchdog. Mon Jun 30 21:07:39 CEST 1997 - Implemented temperature test. - Added double fork() to inherit rights from init. Now watchdog will unmount all partitions correctly regardless what your current working directory is when you start it. My thanks go to Peter Tobias for pointing me into the right direction. Wed Jul 2 11:00:49 CEST 1997 - Halt the system if temperature is too high, but send mail to the sysadmin prior doing that. Thu Jul 3 16:22:47 CEST 1997 - Include fully quantified hostname in Subject: line for mail. Fri Jul 11 10:38:39 CEST 1997 - Released version 3.0. Fri Jul 11 10:49:31 CEST 1997 - Fixed small typo in Makefile. Wed Sep 3 12:33:32 CEST 1997 - Corrected temperature reading code. - Include patch to mount.c for sparcs. - Write warning to log file when temperature start climbing to high. Sun Oct 19 11:22:26 CEST 1997 - No more warnings about unused variables if compiled without USE_SYSLOG. - Some more glibc adjustments for glibc 2.0.5. Fri Oct 24 11:40:07 CEST 1997 - Released version 3.1. Fri Nov 28 11:10:26 CET 1997 - Changed handling of return value of repair script to take care of negative return value. - Stop init before going down. Fri Nov 28 11:26:50 CET 1997 - Released version 3.2. Tue Dec 2 10:02:43 CET 1997 - Stupid me! Somehow I managed to release my test version without removing the call to halt the system regardless of the temperature that I used for my last test. I'm sorry. Hope it didn't cause too much problems. - Released version 3.3. Tue Dez 30 11:35:03 CET 1997 - Reorganized watchdog source files. - Implemented no-action option. Fri Jan 2 16:30:56 CET 1998 - Made watchdog a real-time application. - To enable this I had to change the process-table check code so no hang can occur there. Thu Sep 10 17:22:32 CEST 1998 - Updated mount code to version 2.8 something. Thanks to the one who send me the patches. Unfortunately I lost his email-address. Fri Sep 11 16:22:28 CEST 1998 - Updated test binary stuff to make sure it won't reboot the system if binary runs for too long. Tue Sep 15 13:28:35 CEST 1998 - Allow multiple filenames resp. ip-addresses. Fri Sep 18 16:10:56 CEST 1998 - Move all options with arguments to watchdog.conf and added long options for the remaining ones. - Added option -c to add config file name. Mon Sep 21 13:16:15 CEST 1998 - Output file modification time in verbose mode. - Added check for constant changing of a file. Mon Sep 21 15:23:54 CEST 1998 - Updated man pages. Thu Oct 15 18:21:57 CEST 1998 - Released version 4.0. Fri Oct 16 14:22:15 CEST 1998 - Received patches for RedHat. Argh, should have waited with releasing 4.0. - Some more modifications to repair.sh. Wed Okt 21 13:33:21 CEST 1998 - Moved configuration to config.h. Tue Okt 27 20:49:23 MEZ 1998 - Released 4.1. Mon Nov 23 09:33:20 MEZ 1998 - Changed union name in extern.h from options to wdog_options to be able to compile on libc5 systems. Tue Nov 24 14:32:41 MEZ 1998 - Added patches by Sascha Schumann for libc5 compatibility. Thu Jan 14 13:43:53 CET 1999 - Fixed the bug in read_config that caused the max-load-15 line to be read as max-load-1 = 5. Thu Jan 14 14:17:35 CET 1999 - And fixed another silly bug that caused ping mode to not work anymore. Wed Jan 20 21:03:30 CET 1999 - Switched to GNU autoconf, work done by Sascha Schumann . Fri Jan 22 17:30:41 CET 1999 - Restructured the configuration management. No need to specify compile time defaults for parameters changeable via /etc/watchdog.conf. Sat Jan 30 08:58:47 CET 1999 - Released 4.2. Mon Feb 1 18:16:04 CET 1999 - Fixed autoconf bug so CONFIG_FILENAME default is correct. - Added info about zombie process to docs. Fri Feb 5 07:33:47 CET 1999 - Removed remount call so the one reported hang cannot happen anymore. This call wasn't really needed anyway. - Released 4.3. Thu Feb 18 08:02:01 CET 1999 - Fixed typo in manpage. Fri Feb 19 07:49:51 CET 1999 - Send mail even in case of reboot. - Close log only after the last write. - Fixed getopt_long handling. Fri Feb 19 21:33:26 CET 1999 - Create directory before installing CONFIG_FILENAME. Sun Feb 28 13:05:11 CET 1999 - Released 4.4. Sat Apr 10 14:30:59 CEST 1999 - Added RedHat patches by Marc Merlin. - Made ret an int variable. - Include stdio.h in src/umount.c. - Released 4.5. Mon May 3 19:49:45 CEST 1999 - Corrected INSTALL file to explicitely state that the .spec file is not distributed together with watchdog. Fri Sep 3 11:21:11 CEST 1999 - Change compile time maxload defaults to 24/18/12. Fre Sep 3 14:23:58 CEST 1999 - Add test for free memory. Mon Sep 6 07:40:07 CEST 1999 - Added simple test script that tests whether /bin/sh can be started. - Made load average check disabled by default. Don Sep 9 19:56:06 CEST 1999 - Added passive network test and server pinging test. Sun Dec 19 13:18:35 CET 1999 - Fixed big in test_binary.c that caused not existing errors to be logged. - Add red label in watchdog.8 to not use broadcast ping without explicit permission. Mon Dec 20 14:54:58 CET 1999 - Released 5.0. Mon Dec 27 17:07:51 CET 1999 - Fixed silly calculation bug in memory check. - Disable memory check for default setup. - Released 5.1. Sat May 6 17:01:37 MEST 2000 - added /etc/sysconfig/watchdog to the rc.watchdog.redhat script - added some ifdefs to include/mount_constants.h for compilation on RedHat 6.2 without some warnings about redefined symbols - added "logtick" option to the watchdog binary (I wanted to do this for a very long time -- hps) Mon Jul 24 16:49:11 PDT 2000 - added patch by Hisaaki Shibata to add number of times a ping is tried to config file Son Mar 25 14:18:45 CEST 2001 - Made watchdog work with kernel 2.4. - Send a more verbose email. - Made watchdog compile with latest libc6. Thu May 10 14:19:57 CEST 2001 - Finally released 5.2. Thu May 10 15:11:45 CEST 2001 - Started to integrate stuff written by Marcel Jansen . - Decided to move to version 6.0. Fre Jan 3 14:47:46 CET 2003 - Added patch by Patrick Higgins to catch test programs running for too long and react to that fact. - Fixed pidfile check. A missing file usually means the server exited and thus watchdog needs to take action. - Finally really started adding Marcel's patches: * Redirection of stdout/stderr for test and repair binary. * Write timestamps to heartbeat file. * Add wd_keepalive program that uses the same config file, but only updates the watchdog device. - Fixed shutdown with missing sendmail program. - Added two bug fixes by Stephane List . - Added patch by Jos Vos for a "write-magic" config parameter. - Use unsigned ints for free memory check. Mo Apr 17 14:35:29 CEST 2006 - Fixed some bugs: * unsigned int is too small for free memory check * Man page still referencing options that are no longer available. - Logtick option is used for verbose output in all tests We Jun 21 15:42:28 CEST 2006 - Added patch by Thomas Glanzmann for correct parsing of ping-count option. - Added a patch by James Harper to fix that nasty ping problem. Thanks a lot. - Applied some bug fix patches by Christoph Probst . - Changed interface check to use unsigned long. - Some more small fixes. Mo Jul 31 11:13:04 CEST 2006 - Added patch by Richard Hansen to fix intervals being 50% too long. Mon Feb 12 10:45:21 CET 2007 - Hopefully fixed outstanding problems with wd_keepalive. - Added some documentation about return values of the test binary. - Released 5.3. Wed Feb 21 17:33:30 CET 2007 - Removed superfluous quotation from wd_keepalive.c. - Added sourceforge as new primary archive site. Thu Feb 22 11:48:57 CET 2007 - Released 5.3.1. Thu, 26 Apr 2007 15:08:07 +0200 - Added "another-chance" repair script written by Erik Rossen . Tue, 29 May 2007 16:34:34 +0200 - Applied some changes to RedHat init script. - Added sysconf script for RedHat. Fri, 17 Aug 2007 11:15:08 +0200 - Made wd_keepalive honor config file option. - Added wd_keealive manpage. - Made wd_keepalive not start without a watchdog device. - Fixed some typos in watchdog manpage. - Updated Debian files. - Released 5.4 Mon, 14 Jan 2008 13:57:34 +0100 - Check for existance before usage of sendmail. Wed, 11 Feb 2009 15:00:48 +0100 - Added patch by Jan Rouš to prevent rare segfault on shutdown. Wed, 25 Feb 2009 10:27:35 +0100 - Added patch by Enrique Zanardi to let repair binary know more about the failing test. - Expanded that patch to work for more tests. - Released version 5.5 Tue, 3 Mar 2009 14:59:55 +0100 - Added patch by Enrique Zanardi to check for the source of the ping reply packets. Thu, 12 Mar 2009 14:36:01 +0100 - Added patch by Lon Hohberger to allow configuration of timeouts. - Added another patch by Lon Hohberger to make sure signal handler does not call not-signal safe functions. - Made wd_keepalive accept all options watchdog accepts and not throw errors on those it does not use itself. Fri, 13 Mar 2009 12:26:40 +0100 - Made watchdog not close the watchdog device so early when trying a normal shutdown. This ensures a reset even if the system hangs while doing this. - Applied patch by Richard W.M. Jones to cleanup code base for gcc-4.4. Sun, 22 Mar 2009 14:33:21 +0100 - Some more bugfixes by me and Lon. - Released 5.6 Mon, 25 May 2009 02:46:32 +0200 - Allow config lines with arbitrary length. - Applied patch by Mike Frysinger to not use deprecated sys_siglist anymore. - Also removed configure test for sys_siglist. - Cleaned up includes, also courtesy of Mike Frysinger. Sun, 22 Nov 2009 14:05:29 +0100 - Applied patch by Russell Coker to sets the socket handle for raw socket access to close on exec. Wed, 06 Jan 2010 13:36:37 +0100 - Applied patch by Russell Coker to give a better error message if no config file is found. - Released version 5.7. Fri, 08 Jan 2010 11:02:23 +0100 - Applied patch by Min Zhang to make logdir a configurable option. Tue, 09 Feb 2010 16:26:21 +0100 - Disable OOM killer for watchdog and wd_keepalive. In the process also make sure that the daemons do not allocate memory once they are in daemon mode as a safeguard for systems running out of memory. Thu, 11 Feb 2010 14:50:39 +0100 - Decreased default interval from 10 seconds to just 1 because 10 is too much for some hardware especially embedded systems. Sat Mar 6 22:07:15 2010 +0100 - Applied two patches by Jon Ringle : - uclibc does not have index(), but strchr() is equivalent to index() according to the index man page - Fix compile with USE_SYSLOG disabled Patch by Jon Ringle Mon, 22 Mar 2010 15:24:02 +0100 - Released 5.8 Mon May 10 15:48:35 2010 +0200 - Applied patches by Martin Koegler : - Implementing a timeout for repair scripts - Fixing a few bugs. Thu, 17 Jun 2010 16:59:53 +0200 - Added the ability to query the watchdog type based on work by Corey Minyard ChangeLog ends here. Please refer to git log for later changes. watchdog-5.15/README.watchdog.ipmi0000644000175000017500000001145312664037554016466 0ustar michaelmichaelThis is RedHat/Fedora specific, but can be used with other distros with minor adjustments. Instructions for how to set up the watchdog daemon to work with IPMI's hardware watchdog ---------------------------------------------------------------------------------------- First, verify that the ipmitool utility is present on the system to allow the watchdog timer to be turned off via the command line (which ipmitool). This will allow the hardware watchdog timer to be turned off gracefully should it ever become necessary. If ipmitool is not present, install it or download the latest version from http://ipmitool.sourceforge.net and build and install it on your system. Next, prior to starting up the watchdog daemon, the BMC BIOS should be set to enable the IPMI/BMC hardware watchdog timer, the OpenIPMI watchdog driver module should be inserted with the desired configuration/startup settings, and the watchdog daemon's configuration file should be modified to use /dev/watchdog: 1. To setup the IPMI/BMC BIOS to enable the hardware watchdog timer, see BMC documentation. The main settings in the BMC BIOS requiring modification to turn on the IPMI watchdog timer are: - Set the BMC POST Watchdog to "ENABLED". - Set the BMC POST Watchdog Timeout to "5 Minutes". 2. To insert the OpenIPMI watchdog driver module with the desired configuration settings, two steps are necessary: i.) Configure the OpenIPMI watchdog driver by editing the /etc/sysconfig/ipmi configuration file: - Set "IPMI_WATCHDOG=yes". - Set desired options via the IPMI_WATCHDOG_OPTIONS config entry. EXAMPLE: 'IPMI_WATCHDOG_OPTIONS="timeout=60 start_now=1 \ preop=preop_give_data action=power_cycle pretimeout=1" ' Execute "modinfo ipmi_watchdog" for more detailed information on the available ipmi watchdog timer options. - Execute "service ipmi start" (the watchdog driver starts automatically along with the other ipmi drivers). IMPORTANT: If "start_now=1" has been set as one of the configuration options, be sure to start up the watchdog daemon before the BMC timer expires! ii.) Set the OpenIPMI daemon and watchdog to start during bootup: - chkconfig ipmi on - chkconfig watchdog on 3. Configure the watchdog daemon by editing the /etc/watchdog.conf configuration file: - Uncomment the "watchdog-device = /dev/watchdog" line. - Ensure that "realtime = yes" and "priority = 1" are set and not commented-out. - Uncomment the "interval" line, and set the interval to be less than what you set the timeout option to be in the /etc/sysconfig/ipmi file (ex "timeout=60" so you might set interval to 50). So in the example described herein, the BMC BIOS setting is in minutes (5), and the "interval" and ipmi_watchdog "timeout" settings are both in seconds (50 and 60 respectively). Therefore, the BMC hardware watchdog timer is set to expire and trigger a system power cycle unless reset by the watchdog daemon within 5 minutes, and the watchdog daemon will reset the timer every 60 seconds. 4. Start the Watchdog daemon: - execute "service watchdog start" IMPORTANT: To gracefully stop/kill the watchdog daemon, be sure to use "service watchdog stop" (which executes "kill -s SIGTERM ") and do *not* use "kill -9 ". Using "kill -9 " will cause the daemon to be shut off without stopping the BMC's watchdog timer, thus a system reboot will be triggered when the BMC's watchdog timer expires. Alternately, or in case the watchdog daemon is killed "ungracefully", you can stop the BMC timer by executing the following ipmitool utility command before the watchdog timer expires: # ipmitool -v raw 0x06 0x24 0x04 0x01 0x00 0x10 0x00 0x0a ---------------------------------------------------------------------- To test the watchdog after system configuration and setup: . Use kill -9 on the watchdog daemon so it doesn't shut down the watchdog daemon gracefully. Verify that the system gets reset after the BMC timer expires. . Use "service watchdog stop" and verify that the watchdog daemon shuts off the BMC watchdog timer gracefully (the system doesn't get reset). . Set the timer on the watchdog daemon to be greater than the time set in the BMC BIOS for system reset and verify that the system is reset. . Set the timer on the daemon to be less than the time set in the BMC timer and verify that the BMC watchdog is poked regularly and the system is not reset. . Test some of the other actions the BMC can take when the watchdog timer goes off (see modinfo ipmi_watchdog for some other settings to try). watchdog-5.15/AUTHORS0000644000175000017500000000112412664037554014114 0ustar michaelmichaelWatchdog developer and credits list =================================== Michael Meskes - Maintainer and overall author - Original Debian patches Sascha Schumann - GNU automake/autoconf support - some compatibility patches Johnie Ingram - more Debian patches Marc Merlin - RedHat Patches Miquel van Smoorenburg - The stuff borrowed from sysvinit Marcel Jansen - Quite a lot of additions. Several people who worked on mount/umount and/or send me patches. watchdog-5.15/suse/0000755000175000017500000000000012664037554014025 5ustar michaelmichaelwatchdog-5.15/suse/rc.watchdog.suse0000644000175000017500000000471512664037554017140 0ustar michaelmichael#! /bin/sh # Copyright (c) 1995-1998 SuSE GmbH Nuernberg, Germany. # # Author: Thorsten Bonow (Toto) , 2000 # Based on example /sbin/init.d/skeleton=20 # # /sbin/init.d/ # # and symbolic its link # # /sbin/rc # . /etc/rc.config # Determine the base and follow a runlevel link name. base=${0##*/} link=${base#*[SK][0-9][0-9]} # Force execution if not called by a runlevel directory. test $link = $base && START_FOO=yes # # Up to now, there is no support for watchdog in the main SuSE=20 # configuration file /etc/rc.config, read by the YaST setup tool # # It would look that way in /etc/rc.config: # # START_WATCHDOG=yes=20 # # Then you could use here in this script: # test "$START_WATCHDOG" = yes || exit 0 # The echo return value for success (defined in /etc/rc.config). return=$rc_done case "$1" in start) echo -n "Starting watchdog daemon" ## Start daemon with startproc(8). If this fails ## the echo return value is set appropriate. startproc /usr/sbin/watchdog --softboot || return=$rc_failed echo -e "$return" ;; stop) echo -n "Shutting down watchdog daemon" ## Stop daemon with killproc(8) and if this fails ## set echo the echo return value. killproc -TERM /usr/sbin/watchdog || return=$rc_failed echo -e "$return" ;; restart) ## If first returns OK call the second, if first or ## second command fails, set echo return value. $0 stop && $0 start || return=$rc_failed ;; reload) ## Choose ONE of the following two cases: ## First possibility: A few services accepts a signal ## to reread the (changed) configuration. #echo -n "Reload watchdog daemon" #killproc -HUP /usr/sbin/watchdog || return=$rc_failed #echo -e "$return" ## Exclusive possibility: Some services must be stopped ## and started to force a new load of the configuration. $0 stop && $0 start || return=$rc_failed ;; status) echo -n "Checking for watchdog daemon: " ## Check status with checkproc(8), if process is running ## checkproc will return with exit status 0. checkproc /usr/sbin/watchdog && echo OK || echo No process ;; probe) ## Optional: Probe for the necessity of a reload, ## give out the argument which is required for a reload. #test /etc/foo.conf -nt /var/run/foo.pid && echo reload ;; *) echo "Usage: $0 {start|stop|status|restart|reload[|probe]}" exit 1 ;; esac # Inform the caller not only verbosely and set an exit status. test "$return" = "$rc_done" || exit 1 exit 0 watchdog-5.15/configure.ac0000644000175000017500000001135712664037554015343 0ustar michaelmichaeldnl Process this file with autoconf to produce a configure script. AC_INIT(include/extern.h) MAJOR_VERSION=5 MINOR_VERSION=15 AM_INIT_AUTOMAKE(watchdog, $MAJOR_VERSION.$MINOR_VERSION) AC_PREFIX_DEFAULT(/usr) AC_DEFINE_UNQUOTED(MAJOR_VERSION, $MAJOR_VERSION, "major version number") AC_DEFINE_UNQUOTED(MINOR_VERSION, $MINOR_VERSION, "minor version number") AM_CONFIG_HEADER(include/config.h) AM_SANITY_CHECK AM_MAINTAINER_MODE dnl Checks for programs. AC_PROG_AWK AC_PROG_CC AC_PROG_INSTALL AC_PATH_PROG(PATH_SENDMAIL, sendmail, /usr/lib/sendmail, $PATH /usr/bin /usr/sbin /usr/etc /etc /usr/ucblib) if test -n "$PATH_SENDMAIL"; then AC_DEFINE_UNQUOTED(PATH_SENDMAIL, "$PATH_SENDMAIL", "path to sendmail binary") fi dnl Checks for libraries. dnl Checks for header files. AC_HEADER_DIRENT AC_HEADER_STDC AC_HEADER_SYS_WAIT AC_CHECK_HEADERS(fcntl.h limits.h paths.h sys/ioctl.h sys/time.h syslog.h unistd.h) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_C_INLINE AC_TYPE_PID_T AC_TYPE_SIZE_T AC_STRUCT_ST_RDEV AC_HEADER_TIME dnl Checks for library functions. AC_FUNC_ALLOCA AC_PROG_GCC_TRADITIONAL AC_TYPE_SIGNAL AC_FUNC_VPRINTF AC_CHECK_FUNCS(gethostname select socket strcspn strdup strerror strstr strtoul uname) AC_MSG_CHECKING(whether to log via syslog) AC_ARG_ENABLE(syslog, [ --disable-syslog Disable logging by syslog (deprecated)],[ if test "$enableval" = "yes"; then AC_DEFINE(USE_SYSLOG, 1, "enable syslog") AC_MSG_RESULT(yes) else AC_DEFINE(USE_SYSLOG, 0, "enable syslog") AC_MSG_RESULT(no) fi ],[ AC_DEFINE(USE_SYSLOG, 1, "enable syslog") AC_MSG_RESULT(yes) ]) AC_MSG_CHECKING(whether to include NFS support) AC_ARG_ENABLE(nfs, [ --disable-nfs Disable NFS support],[ if test "$enableval" = "yes"; then AC_DEFINE(HAVE_NFS, 1, "enable NFS") AC_MSG_RESULT(yes) else AC_DEFINE(HAVE_NFS, 0, "enable NFS") AC_MSG_RESULT(no) fi ],[ AC_DEFINE(HAVE_NFS, 1, "enable NFS") AC_MSG_RESULT(yes) ]) AC_MSG_CHECKING(for minimum value accepted as reboot cause) AC_ARG_WITH(minload, [ --with-minload=int minimum value accepted as reboot cause (default 2)],[ AC_DEFINE_UNQUOTED(MINLOAD, $withval, "minimum value accepted as reboot cause") AC_MSG_RESULT($withval) ],[ AC_DEFINE(MINLOAD, 2, "minimum value accepted as reboot cause") AC_MSG_RESULT(2) ]) AC_MSG_CHECKING(for timer margin used by kernel) AC_ARG_WITH(timermargin, [ --with-timermargin=int timer margin used by kernel (default 60)],[ AC_DEFINE_UNQUOTED(TIMER_MARGIN, $withval, "timer margin used by kernel") AC_MSG_RESULT($withval) ],[ AC_DEFINE(TIMER_MARGIN, 60, "timer margin used by kernel") AC_MSG_RESULT(60) ]) AC_MSG_CHECKING(for config filename) AC_ARG_WITH(configfile, [ --with-configfile=filename name of config file (default /etc/watchdog.conf)],[ AC_DEFINE_UNQUOTED(CONFIG_FILENAME, "$withval", "name of config file") CONFIG_FILENAME="$withval" AC_MSG_RESULT($withval) ],[ CONFIG_FILENAME="/etc/watchdog.conf" AC_DEFINE_UNQUOTED(CONFIG_FILENAME, "$CONFIG_FILENAME", "name of config file") AC_MSG_RESULT($CONFIG_FILENAME) ]) AC_SUBST(CONFIG_FILENAME) AC_MSG_CHECKING(for test binary directory) AC_ARG_WITH(test-bin-path, [ --with-test-bin-path=directory path to test binaries (default /etc/watchdog.d)],[ AC_DEFINE_UNQUOTED(TESTBIN_PATH, "$withval", "path to test binaries") TESTBIN_PATH="$withval" AC_MSG_RESULT($withval) ],[ TESTBIN_PATH="/etc/watchdog.d" AC_DEFINE_UNQUOTED(TESTBIN_PATH, "$TESTBIN_PATH", "path to test binaries") AC_MSG_RESULT($TESTBIN_PATH) ]) AC_SUBST(TESTBIN_PATH) AC_MSG_CHECKING(for pid filename) AC_ARG_WITH(pidfile, [ --with-pidfile=filename name of pid file (default /var/run/watchdog.pid)],[ AC_DEFINE_UNQUOTED(PIDFILE, "$withval", "name of pid file") AC_MSG_RESULT($withval) ],[ AC_DEFINE(PIDFILE, "/var/run/watchdog.pid", "name of pid file") AC_MSG_RESULT("/var/run/watchdog.pid") ]) AC_MSG_CHECKING(for keepalive pid filename) AC_ARG_WITH(ka_pidfile, [ --with-ka_pidfile=filename name of keepalive pid file (default /var/run/wd_keepalive.pid)],[ AC_DEFINE_UNQUOTED(KA_PIDFILE, "$withval", "name of keepalive pid file") AC_MSG_RESULT($withval) ],[ AC_DEFINE(KA_PIDFILE, "/var/run/wd_keepalive.pid", "name of keepalive pid file") AC_MSG_RESULT("/var/run/wd_keepalive.pid") ]) AC_MSG_CHECKING(for random seed filename) AC_ARG_WITH(randomseed, [ --with-randomseed=filename filename for storing random seed (default /var/run/random-seed)],[ AC_DEFINE_UNQUOTED(RANDOM_SEED, "$withval", filename for storing random seed") AC_MSG_RESULT($withval) ],[ AC_DEFINE(RANDOM_SEED, "/var/run/random-seed", "filename for storing random seed") AC_MSG_RESULT("/var/run/random-seed") ]) AC_OUTPUT([Makefile src/Makefile]) watchdog-5.15/install-sh0000755000175000017500000003546312664037571015064 0ustar michaelmichael#!/bin/sh # install - install a program, script, or datafile scriptversion=2014-09-12.12; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # 'make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. tab=' ' nl=' ' IFS=" $tab$nl" # Set DOITPROG to "echo" to test this script. doit=${DOITPROG-} doit_exec=${doit:-exec} # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_mkdir= # Desired mode of installed file. mode=0755 chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false is_target_a_directory=possibly usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve the last data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -s) stripcmd=$stripprog;; -t) is_target_a_directory=always dst_arg=$2 # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac shift;; -T) is_target_a_directory=never;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done # We allow the use of options -d and -T together, by making -d # take the precedence; this is for compatibility with GNU install. if test -n "$dir_arg"; then if test -n "$dst_arg"; then echo "$0: target directory not allowed when installing a directory." >&2 exit 1 fi fi if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call 'install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then if test $# -gt 1 || test "$is_target_a_directory" = always; then if test ! -d "$dst_arg"; then echo "$0: $dst_arg: Is not a directory." >&2 exit 1 fi fi fi if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names problematic for 'test' and other utilities. case $src in -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test "$is_target_a_directory" = never; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else dstdir=`dirname "$dst"` test -d "$dstdir" dstdir_status=$? fi fi obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # Create intermediate dirs using mode 755 as modified by the umask. # This is like FreeBSD 'install' as of 1997-10-28. umask=`umask` case $stripcmd.$umask in # Optimize common cases. *[2367][2367]) mkdir_umask=$umask;; .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; *[0-7]) mkdir_umask=`expr $umask + 22 \ - $umask % 100 % 40 + $umask % 20 \ - $umask % 10 % 4 + $umask % 2 `;; *) mkdir_umask=$umask,go-w;; esac # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false case $umask in *[123567][0-7][0-7]) # POSIX mkdir -p sets u+wx bits regardless of umask, which # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) # $RANDOM is not portable (e.g. dash); use it when possible to # lower collision chance tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0 # As "mkdir -p" follows symlinks and we work in /tmp possibly; so # create the $tmpdir first (and fail if unsuccessful) to make sure # that nobody tries to guess the $tmpdir name. if (umask $mkdir_umask && $mkdirprog $mkdir_mode "$tmpdir" && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. test_tmpdir="$tmpdir/a" ls_ld_tmpdir=`ls -ld "$test_tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$test_tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null fi trap '' 0;; esac;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # The umask is ridiculous, or mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; [-=\(\)!]*) prefix='./';; *) prefix='';; esac oIFS=$IFS IFS=/ set -f set fnord $dstdir shift set +f IFS=$oIFS prefixes= for d do test X"$d" = X && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask=$mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd -f "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: watchdog-5.15/watchdog.conf0000644000175000017500000000263412664037554015522 0ustar michaelmichael#ping = 172.31.14.1 #ping = 172.26.1.255 #interface = eth0 #file = /var/log/messages #change = 1407 # Uncomment to enable test. Setting one of these values to '0' disables it. # These values will hopefully never reboot your machine during normal use # (if your machine is really hung, the loadavg will go much higher than 25) #max-load-1 = 24 #max-load-5 = 18 #max-load-15 = 12 # Note that this is the number of pages! # To get the real size, check how large the pagesize is on your machine. #min-memory = 1 #allocatable-memory = 1 #repair-binary = /usr/sbin/repair #repair-timeout = 60 #test-binary = #test-timeout = 60 # The retry-timeout and repair limit are used to handle errors in a more robust # manner. Errors must persist for longer than retry-timeout to action a repair # or reboot, and if repair-maximum attempts are made without the test passing a # reboot is initiated anyway. #retry-timeout = 60 #repair-maximum = 1 #watchdog-device = /dev/watchdog # Defaults compiled into the binary #temperature-sensor = #max-temperature = 90 # Defaults compiled into the binary #admin = root #interval = 1 #logtick = 1 #log-dir = /var/log/watchdog # This greatly decreases the chance that watchdog won't be scheduled before # your machine is really loaded realtime = yes priority = 1 # Check if rsyslogd is still running by enabling the following line #pidfile = /var/run/rsyslogd.pid watchdog-5.15/README0000644000175000017500000000366512664037554013740 0ustar michaelmichaelWatchdog is a daemon that checks if your system is still working. If programs in user space are not longer executed it will reboot the system. However, this will not always work. From the kernel: > Watchdog Timer Interfaces For The Linux Operating System > > Alan Cox > > Custom Linux Driver And Program Development > >[...] > >All four interfaces provide /dev/watchdog, which when open must be written >to within a minute or the machine will reboot. Each write delays the reboot >time another minute. In the case of the software watchdog the ability to >reboot will depend on the state of the machines and interrupts. The hardware >boards physically pull the machine down off their own onboard timers and >will reboot from almost anything. This tool proved very useful for me, because I always run the latest kernel and the latest libc release, but rely on the machine to be up and running for email. Note, that you have to enable the software watchdog driver in your kernel for the program to be able to hard reset the system unless you have a hardware watchdog of course. Make sure you don't compile watchdog with a different timer margin than the kernel driver. As of version 4.0 watchdog is able to make itself a real-time application. It will lock all its pages in memory and set its scheduler to round-robin. This will take up to 900 pages of memory but guarantees you that watchdog will get its share of processor time. If you ever experienced a hard reset just because watchdog wasnt scheduled for a minute, you will probably have no problem with the 900 pages which is not so much anyway. Of course this is not needed for machines running on low load. Don't be surprised if you see any zombie processes laying around. This is normal. They will be removed the next time watchdog wakes up. Of course a new zombie is created then, too. This zombie process is a result of the process table check. Michael meskes@debian.org watchdog-5.15/compile0000755000175000017500000001624512664037571014433 0ustar michaelmichael#! /bin/sh # Wrapper for compilers which do not understand '-c -o'. scriptversion=2012-10-14.11; # UTC # Copyright (C) 1999-2014 Free Software Foundation, Inc. # Written by Tom Tromey . # # 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, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . nl=' ' # We need space, tab and new line, in precisely that order. Quoting is # there to prevent tools from complaining about whitespace usage. IFS=" "" $nl" file_conv= # func_file_conv build_file lazy # Convert a $build file to $host form and store it in $file # Currently only supports Windows hosts. If the determined conversion # type is listed in (the comma separated) LAZY, no conversion will # take place. func_file_conv () { file=$1 case $file in / | /[!/]*) # absolute file, and not a UNC file if test -z "$file_conv"; then # lazily determine how to convert abs files case `uname -s` in MINGW*) file_conv=mingw ;; CYGWIN*) file_conv=cygwin ;; *) file_conv=wine ;; esac fi case $file_conv/,$2, in *,$file_conv,*) ;; mingw/*) file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` ;; cygwin/*) file=`cygpath -m "$file" || echo "$file"` ;; wine/*) file=`winepath -w "$file" || echo "$file"` ;; esac ;; esac } # func_cl_dashL linkdir # Make cl look for libraries in LINKDIR func_cl_dashL () { func_file_conv "$1" if test -z "$lib_path"; then lib_path=$file else lib_path="$lib_path;$file" fi linker_opts="$linker_opts -LIBPATH:$file" } # func_cl_dashl library # Do a library search-path lookup for cl func_cl_dashl () { lib=$1 found=no save_IFS=$IFS IFS=';' for dir in $lib_path $LIB do IFS=$save_IFS if $shared && test -f "$dir/$lib.dll.lib"; then found=yes lib=$dir/$lib.dll.lib break fi if test -f "$dir/$lib.lib"; then found=yes lib=$dir/$lib.lib break fi if test -f "$dir/lib$lib.a"; then found=yes lib=$dir/lib$lib.a break fi done IFS=$save_IFS if test "$found" != yes; then lib=$lib.lib fi } # func_cl_wrapper cl arg... # Adjust compile command to suit cl func_cl_wrapper () { # Assume a capable shell lib_path= shared=: linker_opts= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. eat=1 case $2 in *.o | *.[oO][bB][jJ]) func_file_conv "$2" set x "$@" -Fo"$file" shift ;; *) func_file_conv "$2" set x "$@" -Fe"$file" shift ;; esac ;; -I) eat=1 func_file_conv "$2" mingw set x "$@" -I"$file" shift ;; -I*) func_file_conv "${1#-I}" mingw set x "$@" -I"$file" shift ;; -l) eat=1 func_cl_dashl "$2" set x "$@" "$lib" shift ;; -l*) func_cl_dashl "${1#-l}" set x "$@" "$lib" shift ;; -L) eat=1 func_cl_dashL "$2" ;; -L*) func_cl_dashL "${1#-L}" ;; -static) shared=false ;; -Wl,*) arg=${1#-Wl,} save_ifs="$IFS"; IFS=',' for flag in $arg; do IFS="$save_ifs" linker_opts="$linker_opts $flag" done IFS="$save_ifs" ;; -Xlinker) eat=1 linker_opts="$linker_opts $2" ;; -*) set x "$@" "$1" shift ;; *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) func_file_conv "$1" set x "$@" -Tp"$file" shift ;; *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) func_file_conv "$1" mingw set x "$@" "$file" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -n "$linker_opts"; then linker_opts="-link$linker_opts" fi exec "$@" $linker_opts exit 1 } eat= case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: compile [--help] [--version] PROGRAM [ARGS] Wrapper for compilers which do not understand '-c -o'. Remove '-o dest.o' from ARGS, run PROGRAM with the remaining arguments, and rename the output as expected. If you are trying to build a whole package this is not the right script to run: please start by reading the file 'INSTALL'. Report bugs to . EOF exit $? ;; -v | --v*) echo "compile $scriptversion" exit $? ;; cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) func_cl_wrapper "$@" # Doesn't return... ;; esac ofile= cfile= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. # So we strip '-o arg' only if arg is an object. eat=1 case $2 in *.o | *.obj) ofile=$2 ;; *) set x "$@" -o "$2" shift ;; esac ;; *.c) cfile=$1 set x "$@" "$1" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -z "$ofile" || test -z "$cfile"; then # If no '-o' option was seen then we might have been invoked from a # pattern rule where we don't need one. That is ok -- this is a # normal compilation that the losing compiler can handle. If no # '.c' file was seen then we are probably linking. That is also # ok. exec "$@" fi # Name of file we expect compiler to create. cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` # Create the lock directory. # Note: use '[/\\:.-]' here to ensure that we don't use the same name # that we are using for the .o file. Also, base the name on the expected # object file name, since that is what matters with a parallel build. lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d while true; do if mkdir "$lockdir" >/dev/null 2>&1; then break fi sleep 1 done # FIXME: race condition here if user kills between mkdir and trap. trap "rmdir '$lockdir'; exit 1" 1 2 15 # Run the compile. "$@" ret=$? if test -f "$cofile"; then test "$cofile" = "$ofile" || mv "$cofile" "$ofile" elif test -f "${cofile}bj"; then test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" fi rmdir "$lockdir" exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: watchdog-5.15/depcomp0000755000175000017500000005601612664037571014432 0ustar michaelmichael#! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2013-05-30.07; # UTC # Copyright (C) 1999-2014 Free Software Foundation, Inc. # 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, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] Run PROGRAMS ARGS to compile a file, generating dependencies as side-effects. Environment variables: depmode Dependency tracking mode. source Source file read by 'PROGRAMS ARGS'. object Object file output by 'PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. tmpdepfile Temporary file to use when outputting dependencies. libtool Whether libtool is used (yes/no). Report bugs to . EOF exit $? ;; -v | --v*) echo "depcomp $scriptversion" exit $? ;; esac # Get the directory component of the given path, and save it in the # global variables '$dir'. Note that this directory component will # be either empty or ending with a '/' character. This is deliberate. set_dir_from () { case $1 in */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; *) dir=;; esac } # Get the suffix-stripped basename of the given path, and save it the # global variable '$base'. set_base_from () { base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` } # If no dependency file was actually created by the compiler invocation, # we still have to create a dummy depfile, to avoid errors with the # Makefile "include basename.Plo" scheme. make_dummy_depfile () { echo "#dummy" > "$depfile" } # Factor out some common post-processing of the generated depfile. # Requires the auxiliary global variable '$tmpdepfile' to be set. aix_post_process_depfile () { # If the compiler actually managed to produce a dependency file, # post-process it. if test -f "$tmpdepfile"; then # Each line is of the form 'foo.o: dependency.h'. # Do two passes, one to just change these to # $object: dependency.h # and one to simply output # dependency.h: # which is needed to avoid the deleted-header problem. { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" } > "$depfile" rm -f "$tmpdepfile" else make_dummy_depfile fi } # A tabulation character. tab=' ' # A newline character. nl=' ' # Character ranges might be problematic outside the C locale. # These definitions help. upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ lower=abcdefghijklmnopqrstuvwxyz digits=0123456789 alpha=${upper}${lower} if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. depfile=${depfile-`echo "$object" | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Avoid interferences from the environment. gccflag= dashmflag= # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi cygpath_u="cygpath -u -f -" if test "$depmode" = msvcmsys; then # This is just like msvisualcpp but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvisualcpp fi if test "$depmode" = msvc7msys; then # This is just like msvc7 but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvc7 fi if test "$depmode" = xlc; then # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. gccflag=-qmakedep=gcc,-MF depmode=gcc fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. ## Unfortunately, FreeBSD c89 acceptance of flags depends upon ## the command line argument order; so add the flags where they ## appear in depend2.am. Note that the slowdown incurred here ## affects only configure: in makefiles, %FASTDEP% shortcuts this. for arg do case $arg in -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; *) set fnord "$@" "$arg" ;; esac shift # fnord shift # $arg done "$@" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. ## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. ## (see the conditional assignment to $gccflag above). ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). Also, it might not be ## supported by the other compilers which use the 'gcc' depmode. ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The second -e expression handles DOS-style file names with drive # letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the "deleted header file" problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. ## Some versions of gcc put a space before the ':'. On the theory ## that the space means something, we add a space to the output as ## well. hp depmode also adds that space, but also prefixes the VPATH ## to the object. Take care to not repeat it in the output. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like '#:fec' to the end of the # dependency line. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ | tr "$nl" ' ' >> "$depfile" echo >> "$depfile" # The second pass generates a dummy entry for each header file. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> "$depfile" else make_dummy_depfile fi rm -f "$tmpdepfile" ;; xlc) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the # current directory. Also, the AIX compiler puts '$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then tmpdepfile1=$dir$base.u tmpdepfile2=$base.u tmpdepfile3=$dir.libs/$base.u "$@" -Wc,-M else tmpdepfile1=$dir$base.u tmpdepfile2=$dir$base.u tmpdepfile3=$dir$base.u "$@" -M fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done aix_post_process_depfile ;; tcc) # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 # FIXME: That version still under development at the moment of writing. # Make that this statement remains true also for stable, released # versions. # It will wrap lines (doesn't matter whether long or short) with a # trailing '\', as in: # # foo.o : \ # foo.c \ # foo.h \ # # It will put a trailing '\' even on the last line, and will use leading # spaces rather than leading tabs (at least since its commit 0394caf7 # "Emit spaces for -MD"). "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. # We have to change lines of the first kind to '$object: \'. sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" # And for each line of the second kind, we have to emit a 'dep.h:' # dummy dependency, to avoid the deleted-header problem. sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" rm -f "$tmpdepfile" ;; ## The order of this option in the case statement is important, since the ## shell code in configure will try each of these formats in the order ## listed in this file. A plain '-MD' option would be understood by many ## compilers, so we must ensure this comes after the gcc and icc options. pgcc) # Portland's C compiler understands '-MD'. # Will always output deps to 'file.d' where file is the root name of the # source file under compilation, even if file resides in a subdirectory. # The object file name does not affect the name of the '.d' file. # pgcc 10.2 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using '\' : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... set_dir_from "$object" # Use the source, not the object, to determine the base name, since # that's sadly what pgcc will do too. set_base_from "$source" tmpdepfile=$base.d # For projects that build the same source file twice into different object # files, the pgcc approach of using the *source* file root name can cause # problems in parallel builds. Use a locking strategy to avoid stomping on # the same $tmpdepfile. lockdir=$base.d-lock trap " echo '$0: caught signal, cleaning up...' >&2 rmdir '$lockdir' exit 1 " 1 2 13 15 numtries=100 i=$numtries while test $i -gt 0; do # mkdir is a portable test-and-set. if mkdir "$lockdir" 2>/dev/null; then # This process acquired the lock. "$@" -MD stat=$? # Release the lock. rmdir "$lockdir" break else # If the lock is being held by a different process, wait # until the winning process is done or we timeout. while test -d "$lockdir" && test $i -gt 0; do sleep 1 i=`expr $i - 1` done fi i=`expr $i - 1` done trap - 1 2 13 15 if test $i -le 0; then echo "$0: failed to acquire lock after $numtries attempts" >&2 echo "$0: check lockdir '$lockdir'" >&2 exit 1 fi if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form `foo.o: dependent.h', # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp2) # The "hp" stanza above does not work with aCC (C++) and HP's ia64 # compilers, which have integrated preprocessors. The correct option # to use with these is +Maked; it writes dependencies to a file named # 'foo.d', which lands next to the object file, wherever that # happens to be. # Much of this is similar to the tru64 case; see comments there. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then tmpdepfile1=$dir$base.d tmpdepfile2=$dir.libs/$base.d "$@" -Wc,+Maked else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d "$@" +Maked fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" # Add 'dependent.h:' lines. sed -ne '2,${ s/^ *// s/ \\*$// s/$/:/ p }' "$tmpdepfile" >> "$depfile" else make_dummy_depfile fi rm -f "$tmpdepfile" "$tmpdepfile2" ;; tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in 'foo.d' instead, so we check for that too. # Subdirectories are respected. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then # Libtool generates 2 separate objects for the 2 libraries. These # two compilations output dependencies in $dir.libs/$base.o.d and # in $dir$base.o.d. We have to check for both files, because # one of the two compilations can be disabled. We should prefer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is # automatically cleaned when .libs/ is deleted, while ignoring # the former would cause a distcleancheck panic. tmpdepfile1=$dir$base.o.d # libtool 1.5 tmpdepfile2=$dir.libs/$base.o.d # Likewise. tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d tmpdepfile3=$dir$base.d "$@" -MD fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done # Same post-processing that is required for AIX mode. aix_post_process_depfile ;; msvc7) if test "$libtool" = yes; then showIncludes=-Wc,-showIncludes else showIncludes=-showIncludes fi "$@" $showIncludes > "$tmpdepfile" stat=$? grep -v '^Note: including file: ' "$tmpdepfile" if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The first sed program below extracts the file names and escapes # backslashes for cygpath. The second sed program outputs the file # name when reading, but also accumulates all include files in the # hold buffer in order to output them again at the end. This only # works with sed implementations that can handle large buffers. sed < "$tmpdepfile" -n ' /^Note: including file: *\(.*\)/ { s//\1/ s/\\/\\\\/g p }' | $cygpath_u | sort -u | sed -n ' s/ /\\ /g s/\(.*\)/'"$tab"'\1 \\/p s/.\(.*\) \\/\1:/ H $ { s/.*/'"$tab"'/ G p }' >> "$depfile" echo >> "$depfile" # make sure the fragment doesn't end with a backslash rm -f "$tmpdepfile" ;; msvc7msys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove '-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for ':' # in the target name. This is to cope with DOS-style filenames: # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. "$@" $dashmflag | sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this sed invocation # correctly. Breaking it into two sed invocations is a workaround. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # X makedepend shift cleared=no eat=no for arg do case $cleared in no) set ""; shift cleared=yes ;; esac if test $eat = yes; then eat=no continue fi case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. -arch) eat=yes ;; -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done obj_suffix=`echo "$object" | sed 's/^.*\././'` touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" # makedepend may prepend the VPATH from the source file name to the object. # No need to regex-escape $object, excess matching of '.' is harmless. sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process the last invocation # correctly. Breaking it into two sed invocations is a workaround. sed '1,2d' "$tmpdepfile" \ | tr ' ' "$nl" \ | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove '-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -E \ | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi IFS=" " for arg do case "$arg" in -o) shift ;; $object) shift ;; "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; *) set fnord "$@" "$arg" shift shift ;; esac done "$@" -E 2>/dev/null | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" echo "$tab" >> "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; msvcmsys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: watchdog-5.15/include/0000755000175000017500000000000012664037571014470 5ustar michaelmichaelwatchdog-5.15/include/loop.h0000644000175000017500000000015612664037554015615 0ustar michaelmichael#include #undef dev_t #define dev_t __kernel_dev_t #include #undef dev_t watchdog-5.15/include/nfs_mountversion.h0000644000175000017500000000007012664037554020255 0ustar michaelmichael#define KERNEL_NFS_MOUNT_VERSION 1 /* mountd version */ watchdog-5.15/include/wd_mntent.h0000644000175000017500000000066712664037554016652 0ustar michaelmichael#ifndef WD_MNTENT_H #define WD_MNTENT_H #include /* for struct mntent */ #define ERR_MAX 5 typedef struct mntFILEstruct { FILE *mntent_fp; char *mntent_file; int mntent_lineno; int mntent_errs; int mntent_softerrs; } mntFILE; mntFILE *my_setmntent(const char *file, char *mode); void my_endmntent(mntFILE * mfp); int my_addmntent(mntFILE * mfp, struct mntent *mnt); struct mntent *my_getmntent(mntFILE * mfp); #endif watchdog-5.15/include/linux_fs.h0000644000175000017500000000400212664037554016465 0ustar michaelmichael/* Including became more and more painful. Below a very abbreviated version of some declarations, only designed to be able to check a magic number in case no filesystem type was given. */ #ifndef BLKGETSIZE #define BLKGETSIZE 0x1260 /* return device size */ #endif #define MINIX_SUPER_MAGIC 0x137F /* original minix fs */ #define MINIX_SUPER_MAGIC2 0x138F /* minix fs, 30 char names */ struct minix_super_block { u_char s_dummy[16]; u_char s_magic[2]; }; #define minixmagic(s) ((uint) s.s_magic[0] + (((uint) s.s_magic[1]) << 8)) #define ISODCL(from, to) (to - from + 1) #define ISO_STANDARD_ID "CD001" struct iso_volume_descriptor { char type[ISODCL(1, 1)]; /* 711 */ char id[ISODCL(2, 6)]; char version[ISODCL(7, 7)]; char data[ISODCL(8, 2048)]; }; #define HS_STANDARD_ID "CDROM" struct hs_volume_descriptor { char foo[ISODCL(1, 8)]; /* 733 */ char type[ISODCL(9, 9)]; /* 711 */ char id[ISODCL(10, 14)]; char version[ISODCL(15, 15)]; /* 711 */ char data[ISODCL(16, 2048)]; }; #define EXT_SUPER_MAGIC 0x137D struct ext_super_block { u_char s_dummy[56]; u_char s_magic[2]; }; #define extmagic(s) ((uint) s.s_magic[0] + (((uint) s.s_magic[1]) << 8)) #define EXT2_PRE_02B_MAGIC 0xEF51 #define EXT2_SUPER_MAGIC 0xEF53 struct ext2_super_block { u_char s_dummy[56]; u_char s_magic[2]; }; #define ext2magic(s) ((uint) s.s_magic[0] + (((uint) s.s_magic[1]) << 8)) #define _XIAFS_SUPER_MAGIC 0x012FD16D struct xiafs_super_block { u_char s_boot_segment[512]; /* 1st sector reserved for boot */ u_char s_dummy[60]; u_char s_magic[4]; }; #define xiafsmagic(s) ((uint) s.s_magic[0] + (((uint) s.s_magic[1]) << 8) + \ (((uint) s.s_magic[2]) << 16) + \ (((uint) s.s_magic[3]) << 24)) /* From jj@sunsite.ms.mff.cuni.cz Mon Mar 23 15:19:05 1998 */ #define UFS_SUPER_MAGIC 0x00011954 struct ufs_super_block { u_char s_dummy[0x55c]; u_char s_magic[4]; }; #define ufsmagic(s) ((uint) s.s_magic[0] + (((uint) s.s_magic[1]) << 8) + \ (((uint) s.s_magic[2]) << 16) + \ (((uint) s.s_magic[3]) << 24)) watchdog-5.15/include/stamp-h0000644000175000017500000000001212664037554015756 0ustar michaelmichaeltimestamp watchdog-5.15/include/config.h.in0000644000175000017500000001260712664037571016521 0ustar michaelmichael/* include/config.h.in. Generated from configure.ac by autoheader. */ /* "name of config file" */ #undef CONFIG_FILENAME /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP systems. This function is required for `alloca.c' support on those systems. */ #undef CRAY_STACKSEG_END /* Define to 1 if using `alloca.c'. */ #undef C_ALLOCA /* Define to 1 if you have `alloca', as a function or macro. */ #undef HAVE_ALLOCA /* Define to 1 if you have and it should be used (not on Ultrix). */ #undef HAVE_ALLOCA_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_DIRENT_H /* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ #undef HAVE_DOPRNT /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H /* Define to 1 if you have the `gethostname' function. */ #undef HAVE_GETHOSTNAME /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_LIMITS_H /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_NDIR_H /* "enable NFS" */ #undef HAVE_NFS /* Define to 1 if you have the header file. */ #undef HAVE_PATHS_H /* Define to 1 if you have the `select' function. */ #undef HAVE_SELECT /* Define to 1 if you have the `socket' function. */ #undef HAVE_SOCKET /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the `strcspn' function. */ #undef HAVE_STRCSPN /* Define to 1 if you have the `strdup' function. */ #undef HAVE_STRDUP /* Define to 1 if you have the `strerror' function. */ #undef HAVE_STRERROR /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the `strstr' function. */ #undef HAVE_STRSTR /* Define to 1 if you have the `strtoul' function. */ #undef HAVE_STRTOUL /* Define to 1 if `st_rdev' is a member of `struct stat'. */ #undef HAVE_STRUCT_STAT_ST_RDEV /* Define to 1 if your `struct stat' has `st_rdev'. Deprecated, use `HAVE_STRUCT_STAT_ST_RDEV' instead. */ #undef HAVE_ST_RDEV /* Define to 1 if you have the header file. */ #undef HAVE_SYSLOG_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_SYS_DIR_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_IOCTL_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_SYS_NDIR_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have that is POSIX.1 compatible. */ #undef HAVE_SYS_WAIT_H /* Define to 1 if you have the `uname' function. */ #undef HAVE_UNAME /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the `vprintf' function. */ #undef HAVE_VPRINTF /* "name of keepalive pid file" */ #undef KA_PIDFILE /* "major version number" */ #undef MAJOR_VERSION /* "minimum value accepted as reboot cause" */ #undef MINLOAD /* "minor version number" */ #undef MINOR_VERSION /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* "path to sendmail binary" */ #undef PATH_SENDMAIL /* "name of pid file" */ #undef PIDFILE /* "filename for storing random seed" */ #undef RANDOM_SEED /* Define as the return type of signal handlers (`int' or `void'). */ #undef RETSIGTYPE /* If using the C implementation of alloca, define if you know the direction of stack growth for your system; otherwise it will be automatically deduced at runtime. STACK_DIRECTION > 0 => grows toward higher addresses STACK_DIRECTION < 0 => grows toward lower addresses STACK_DIRECTION = 0 => direction of growth unknown */ #undef STACK_DIRECTION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* "path to test binaries" */ #undef TESTBIN_PATH /* "timer margin used by kernel" */ #undef TIMER_MARGIN /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* "enable syslog" */ #undef USE_SYSLOG /* Version number of package */ #undef VERSION /* Define to empty if `const' does not conform to ANSI C. */ #undef const /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ #ifndef __cplusplus #undef inline #endif /* Define to `int' if does not define. */ #undef pid_t /* Define to `unsigned int' if does not define. */ #undef size_t watchdog-5.15/include/sundries.h0000644000175000017500000000336412664037554016504 0ustar michaelmichael/* * sundries.h * Support function prototypes. Functions are in sundries.c. */ #include #include #include #include #include #include #if !defined(bool_t) && !defined(__GLIBC__) #include #endif extern int mount_mount_quiet; extern int mount_verbose; extern int sloppy; #define streq(s, t) (strcmp ((s), (t)) == 0) /* String list data structure. */ typedef struct string_list { char *hd; struct string_list *tl; } *string_list; #define car(p) ((p) -> hd) #define cdr(p) ((p) -> tl) string_list cons(char *a, const string_list); /* Functions in sundries.c that are used in mount.c and umount.c */ void block_signals(int how); char *canonicalize(const char *path); char *realpath(const char *path, char *resolved_path); void error(const char *fmt, ...); int matching_type(const char *type, string_list types); string_list parse_list(char *strings); char *xstrconcat2(const char *, const char *); char *xstrconcat3(const char *, const char *, const char *); char *xstrconcat4(const char *, const char *, const char *, const char *); /* Here is some serious cruft. */ #ifdef __GNUC__ #if defined(__GNUC_MINOR__) && __GNUC__ == 2 && __GNUC_MINOR__ >= 5 void die(int errcode, const char *fmt, ...) __attribute__ ((noreturn)); #else /* GNUC < 2.5 */ void die(int errcode, const char *fmt, ...); #endif /* GNUC < 2.5 */ #else /* !__GNUC__ */ void die(int errcode, const char *fmt, ...); #endif /* !__GNUC__ */ #ifdef HAVE_NFS int nfsmount(const char *spec, const char *node, int *flags, char **orig_opts, char **opt_args, int running_bg); #endif #include "logmessage.h" /* Has EX_USAGE and other exit values. */ #include "xmalloc.h" /* Has xmalloc(), xstrdup() & xstrndup() */ watchdog-5.15/include/xmalloc.h0000644000175000017500000000031412664037554016277 0ustar michaelmichael#ifndef _XMALLOC_H #define _XMALLOC_H void *xmalloc (size_t size); void *xcalloc (size_t nmemb, size_t size); char *xstrdup (const char *s); char *xstrndup (const char *s, int n); #endif /*_XMALLOC_H*/ watchdog-5.15/include/mount_constants.h0000644000175000017500000000177112664037554020106 0ustar michaelmichael#ifndef MS_RDONLY #define MS_RDONLY 1 /* Mount read-only */ #endif #ifndef MS_NOSUID #define MS_NOSUID 2 /* Ignore suid and sgid bits */ #endif #ifndef MS_NODEV #define MS_NODEV 4 /* Disallow access to device special files */ #endif #ifndef MS_NOEXEC #define MS_NOEXEC 8 /* Disallow program execution */ #endif #ifndef MS_SYNCHRONOUS #define MS_SYNCHRONOUS 16 /* Writes are synced at once */ #endif #ifndef MS_REMOUNT #define MS_REMOUNT 32 /* Alter flags of a mounted FS */ #endif #ifndef MS_MANDLOCK #define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */ #endif #ifndef MS_NOATIME #define MS_NOATIME 1024 /* Do not update access times. */ #endif #ifndef MS_NODIRATIME #define MS_NODIRATIME 2048 /* Do not update directory access times */ #endif /* * Magic mount flag number. Has to be or-ed to the flag values. */ #ifndef MS_MGC_VAL #define MS_MGC_VAL 0xC0ED0000 /* magic flag number to indicate "new" flags */ #endif #ifndef MS_MGC_MSK #define MS_MGC_MSK 0xffff0000 /* magic flag number mask */ #endif watchdog-5.15/include/read-conf.h0000644000175000017500000000161412664037554016502 0ustar michaelmichael#ifndef READ_CONF_H #define READ_CONF_H typedef struct read_list_s { const char *name; int value; } read_list_t; #define READ_LIST_ADD(name, value) {name, value}, #define READ_LIST_ENUM(enumv) {#enumv, enumv}, #define READ_LIST_END() {NULL, 0} typedef enum { Read_allow_blank = 1, Read_string_only = 2 } string_read_e; /** read-conf.c **/ void trim_white(char *buf); char *str_start(char *p); int read_int_func(char *arg, char *val, const char *name, int imin, int imax, int *iv); int read_string_func(char *arg, char *val, const char *name, string_read_e mode, char **str); int read_enumerated_func(char *arg, char *val, const char *name, const read_list_t list[], int *iv); int read_list_func(char *arg, char *val, const char *name, int version, struct list **list); void add_list(struct list **list, const char *name, int version); void free_list(struct list **list); #endif /*READ_CONF_H*/ watchdog-5.15/include/watch_err.h0000644000175000017500000000156512664037554016627 0ustar michaelmichael#ifndef _WATCH_ERR_H #define _WATCH_ERR_H /*********************************/ /* additional error return codes */ /*********************************/ #define ENOERR 0 /* no error */ #define EREBOOT 255 /* unconditional reboot (255 = -1 as unsigned 8-bit) */ #define ERESET 254 /* unconditional hard reset */ #define EMAXLOAD 253 /* load average too high */ #define ETOOHOT 252 /* too hot inside */ #define ENOLOAD 251 /* /proc/loadavg contains no data */ #define ENOCHANGE 250 /* file wasn't changed in the given interval */ #define EINVMEM 249 /* /proc/meminfo contains invalid data */ #define ECHKILL 248 /* child was killed by signal */ #define ETOOLONG 247 /* child didn't return in time */ #define EUSERVALUE 246 /* reserved for user error code */ #define EDONTKNOW 245 /* unknown, not "no error" (i.e. success) but implies test still running */ #endif /*_WATCH_ERR_H*/ watchdog-5.15/include/ext2_mnt.h0000644000175000017500000000066112664037554016405 0ustar michaelmichael/* * this file contains some information still missing from glibc header files */ /* * from mntent.h */ #define MNTTYPE_EXT2 "ext2" /* Second Extended file system */ #define MNTOPT_NOQUOTA "noquota" /* don't use any quota on this partition */ #define MNTOPT_USRQUOTA "usrquota" /* use userquota on this partition */ #define MNTOPT_GRPQUOTA "grpquota" /* use groupquota on this partition */ watchdog-5.15/include/nfsmount.h0000644000175000017500000002533312664037554016521 0ustar michaelmichael/* * Please do not edit this file. * It was generated using rpcgen. */ #ifndef _NFSMOUNT_H_RPCGEN #define _NFSMOUNT_H_RPCGEN #include /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape * media and as a part of the software program in whole or part. Users * may copy or modify Sun RPC without charge, but are not authorized * to license or distribute it to anyone else except as part of a product or * program developed by the user or with the express written consent of * Sun Microsystems, Inc. * * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. * * Sun RPC is provided with no support and without any obligation on the * part of Sun Microsystems, Inc. to assist in its use, correction, * modification or enhancement. * * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC * OR ANY PART THEREOF. * * In no event will Sun Microsystems, Inc. be liable for any lost revenue * or profits or other special, indirect and consequential damages, even if * Sun has been advised of the possibility of such damages. * * Sun Microsystems, Inc. * 2550 Garcia Avenue * Mountain View, California 94043 */ /* * Copyright (c) 1985, 1990 by Sun Microsystems, Inc. */ /* from @(#)mount.x 1.3 91/03/11 TIRPC 1.0 */ #ifndef _rpcsvc_mount_h #define _rpcsvc_mount_h #define MNTPATHLEN 1024 #define MNTNAMLEN 255 #define FHSIZE 32 typedef char fhandle[FHSIZE]; #ifdef __cplusplus extern "C" bool_t xdr_fhandle(XDR *, fhandle); #elif __STDC__ extern bool_t xdr_fhandle(XDR *, fhandle); #else /* Old Style C */ bool_t xdr_fhandle(); #endif /* Old Style C */ struct fhstatus { u_int fhs_status; union { fhandle fhs_fhandle; } fhstatus_u; }; typedef struct fhstatus fhstatus; #ifdef __cplusplus extern "C" bool_t xdr_fhstatus(XDR *, fhstatus *); #elif __STDC__ extern bool_t xdr_fhstatus(XDR *, fhstatus *); #else /* Old Style C */ bool_t xdr_fhstatus(); #endif /* Old Style C */ typedef char *dirpath; #ifdef __cplusplus extern "C" bool_t xdr_dirpath(XDR *, dirpath *); #elif __STDC__ extern bool_t xdr_dirpath(XDR *, dirpath *); #else /* Old Style C */ bool_t xdr_dirpath(); #endif /* Old Style C */ typedef char *name; #ifdef __cplusplus extern "C" bool_t xdr_name(XDR *, name *); #elif __STDC__ extern bool_t xdr_name(XDR *, name *); #else /* Old Style C */ bool_t xdr_name(); #endif /* Old Style C */ typedef struct mountbody *mountlist; #ifdef __cplusplus extern "C" bool_t xdr_mountlist(XDR *, mountlist *); #elif __STDC__ extern bool_t xdr_mountlist(XDR *, mountlist *); #else /* Old Style C */ bool_t xdr_mountlist(); #endif /* Old Style C */ struct mountbody { name ml_hostname; dirpath ml_directory; mountlist ml_next; }; typedef struct mountbody mountbody; #ifdef __cplusplus extern "C" bool_t xdr_mountbody(XDR *, mountbody *); #elif __STDC__ extern bool_t xdr_mountbody(XDR *, mountbody *); #else /* Old Style C */ bool_t xdr_mountbody(); #endif /* Old Style C */ typedef struct groupnode *groups; #ifdef __cplusplus extern "C" bool_t xdr_groups(XDR *, groups *); #elif __STDC__ extern bool_t xdr_groups(XDR *, groups *); #else /* Old Style C */ bool_t xdr_groups(); #endif /* Old Style C */ struct groupnode { name gr_name; groups gr_next; }; typedef struct groupnode groupnode; #ifdef __cplusplus extern "C" bool_t xdr_groupnode(XDR *, groupnode *); #elif __STDC__ extern bool_t xdr_groupnode(XDR *, groupnode *); #else /* Old Style C */ bool_t xdr_groupnode(); #endif /* Old Style C */ typedef struct exportnode *exports; #ifdef __cplusplus extern "C" bool_t xdr_exports(XDR *, exports *); #elif __STDC__ extern bool_t xdr_exports(XDR *, exports *); #else /* Old Style C */ bool_t xdr_exports(); #endif /* Old Style C */ struct exportnode { dirpath ex_dir; groups ex_groups; exports ex_next; }; typedef struct exportnode exportnode; #ifdef __cplusplus extern "C" bool_t xdr_exportnode(XDR *, exportnode *); #elif __STDC__ extern bool_t xdr_exportnode(XDR *, exportnode *); #else /* Old Style C */ bool_t xdr_exportnode(); #endif /* Old Style C */ struct ppathcnf { int pc_link_max; short pc_max_canon; short pc_max_input; short pc_name_max; short pc_path_max; short pc_pipe_buf; u_char pc_vdisable; char pc_xxx; short pc_mask[2]; }; typedef struct ppathcnf ppathcnf; #ifdef __cplusplus extern "C" bool_t xdr_ppathcnf(XDR *, ppathcnf *); #elif __STDC__ extern bool_t xdr_ppathcnf(XDR *, ppathcnf *); #else /* Old Style C */ bool_t xdr_ppathcnf(); #endif /* Old Style C */ #endif /*!_rpcsvc_mount_h */ #define MOUNTPROG ((u_long)100005) #define MOUNTVERS ((u_long)1) #ifdef __cplusplus #define MOUNTPROC_NULL ((u_long)0) extern "C" void *mountproc_null_1(void *, CLIENT *); extern "C" void *mountproc_null_1_svc(void *, struct svc_req *); #define MOUNTPROC_MNT ((u_long)1) extern "C" fhstatus * mountproc_mnt_1(dirpath *, CLIENT *); extern "C" fhstatus * mountproc_mnt_1_svc(dirpath *, struct svc_req *); #define MOUNTPROC_DUMP ((u_long)2) extern "C" mountlist * mountproc_dump_1(void *, CLIENT *); extern "C" mountlist * mountproc_dump_1_svc(void *, struct svc_req *); #define MOUNTPROC_UMNT ((u_long)3) extern "C" void *mountproc_umnt_1(dirpath *, CLIENT *); extern "C" void *mountproc_umnt_1_svc(dirpath *, struct svc_req *); #define MOUNTPROC_UMNTALL ((u_long)4) extern "C" void *mountproc_umntall_1(void *, CLIENT *); extern "C" void *mountproc_umntall_1_svc(void *, struct svc_req *); #define MOUNTPROC_EXPORT ((u_long)5) extern "C" exports * mountproc_export_1(void *, CLIENT *); extern "C" exports * mountproc_export_1_svc(void *, struct svc_req *); #define MOUNTPROC_EXPORTALL ((u_long)6) extern "C" exports * mountproc_exportall_1(void *, CLIENT *); extern "C" exports * mountproc_exportall_1_svc(void *, struct svc_req *); #elif __STDC__ #define MOUNTPROC_NULL ((u_long)0) extern void *mountproc_null_1(void *, CLIENT *); extern void *mountproc_null_1_svc(void *, struct svc_req *); #define MOUNTPROC_MNT ((u_long)1) extern fhstatus *mountproc_mnt_1(dirpath *, CLIENT *); extern fhstatus *mountproc_mnt_1_svc(dirpath *, struct svc_req *); #define MOUNTPROC_DUMP ((u_long)2) extern mountlist *mountproc_dump_1(void *, CLIENT *); extern mountlist *mountproc_dump_1_svc(void *, struct svc_req *); #define MOUNTPROC_UMNT ((u_long)3) extern void *mountproc_umnt_1(dirpath *, CLIENT *); extern void *mountproc_umnt_1_svc(dirpath *, struct svc_req *); #define MOUNTPROC_UMNTALL ((u_long)4) extern void *mountproc_umntall_1(void *, CLIENT *); extern void *mountproc_umntall_1_svc(void *, struct svc_req *); #define MOUNTPROC_EXPORT ((u_long)5) extern exports *mountproc_export_1(void *, CLIENT *); extern exports *mountproc_export_1_svc(void *, struct svc_req *); #define MOUNTPROC_EXPORTALL ((u_long)6) extern exports *mountproc_exportall_1(void *, CLIENT *); extern exports *mountproc_exportall_1_svc(void *, struct svc_req *); #else /* Old Style C */ #define MOUNTPROC_NULL ((u_long)0) extern void *mountproc_null_1(); extern void *mountproc_null_1_svc(); #define MOUNTPROC_MNT ((u_long)1) extern fhstatus *mountproc_mnt_1(); extern fhstatus *mountproc_mnt_1_svc(); #define MOUNTPROC_DUMP ((u_long)2) extern mountlist *mountproc_dump_1(); extern mountlist *mountproc_dump_1_svc(); #define MOUNTPROC_UMNT ((u_long)3) extern void *mountproc_umnt_1(); extern void *mountproc_umnt_1_svc(); #define MOUNTPROC_UMNTALL ((u_long)4) extern void *mountproc_umntall_1(); extern void *mountproc_umntall_1_svc(); #define MOUNTPROC_EXPORT ((u_long)5) extern exports *mountproc_export_1(); extern exports *mountproc_export_1_svc(); #define MOUNTPROC_EXPORTALL ((u_long)6) extern exports *mountproc_exportall_1(); extern exports *mountproc_exportall_1_svc(); #endif /* Old Style C */ #define MOUNTVERS_POSIX ((u_long)2) #ifdef __cplusplus extern "C" void *mountproc_null_2(void *, CLIENT *); extern "C" void *mountproc_null_2_svc(void *, struct svc_req *); extern "C" fhstatus * mountproc_mnt_2(dirpath *, CLIENT *); extern "C" fhstatus * mountproc_mnt_2_svc(dirpath *, struct svc_req *); extern "C" mountlist * mountproc_dump_2(void *, CLIENT *); extern "C" mountlist * mountproc_dump_2_svc(void *, struct svc_req *); extern "C" void *mountproc_umnt_2(dirpath *, CLIENT *); extern "C" void *mountproc_umnt_2_svc(dirpath *, struct svc_req *); extern "C" void *mountproc_umntall_2(void *, CLIENT *); extern "C" void *mountproc_umntall_2_svc(void *, struct svc_req *); extern "C" exports * mountproc_export_2(void *, CLIENT *); extern "C" exports * mountproc_export_2_svc(void *, struct svc_req *); extern "C" exports * mountproc_exportall_2(void *, CLIENT *); extern "C" exports * mountproc_exportall_2_svc(void *, struct svc_req *); #define MOUNTPROC_PATHCONF ((u_long)7) extern "C" ppathcnf * mountproc_pathconf_2(dirpath *, CLIENT *); extern "C" ppathcnf * mountproc_pathconf_2_svc(dirpath *, struct svc_req *); #elif __STDC__ extern void *mountproc_null_2(void *, CLIENT *); extern void *mountproc_null_2_svc(void *, struct svc_req *); extern fhstatus *mountproc_mnt_2(dirpath *, CLIENT *); extern fhstatus *mountproc_mnt_2_svc(dirpath *, struct svc_req *); extern mountlist *mountproc_dump_2(void *, CLIENT *); extern mountlist *mountproc_dump_2_svc(void *, struct svc_req *); extern void *mountproc_umnt_2(dirpath *, CLIENT *); extern void *mountproc_umnt_2_svc(dirpath *, struct svc_req *); extern void *mountproc_umntall_2(void *, CLIENT *); extern void *mountproc_umntall_2_svc(void *, struct svc_req *); extern exports *mountproc_export_2(void *, CLIENT *); extern exports *mountproc_export_2_svc(void *, struct svc_req *); extern exports *mountproc_exportall_2(void *, CLIENT *); extern exports *mountproc_exportall_2_svc(void *, struct svc_req *); #define MOUNTPROC_PATHCONF ((u_long)7) extern ppathcnf *mountproc_pathconf_2(dirpath *, CLIENT *); extern ppathcnf *mountproc_pathconf_2_svc(dirpath *, struct svc_req *); #else /* Old Style C */ extern void *mountproc_null_2(); extern void *mountproc_null_2_svc(); extern fhstatus *mountproc_mnt_2(); extern fhstatus *mountproc_mnt_2_svc(); extern mountlist *mountproc_dump_2(); extern mountlist *mountproc_dump_2_svc(); extern void *mountproc_umnt_2(); extern void *mountproc_umnt_2_svc(); extern void *mountproc_umntall_2(); extern void *mountproc_umntall_2_svc(); extern exports *mountproc_export_2(); extern exports *mountproc_export_2_svc(); extern exports *mountproc_exportall_2(); extern exports *mountproc_exportall_2_svc(); #define MOUNTPROC_PATHCONF ((u_long)7) extern ppathcnf *mountproc_pathconf_2(); extern ppathcnf *mountproc_pathconf_2_svc(); #endif /* Old Style C */ #endif /* !_NFSMOUNT_H_RPCGEN */ watchdog-5.15/include/extern.h0000644000175000017500000000757012664037554016160 0ustar michaelmichael#ifndef _EXTERN_H_ #define _EXTERN_H_ #include #include #include #include #include "logmessage.h" #include "xmalloc.h" /* === Variable types === */ struct pingmode { struct sockaddr to; int sock_fp; unsigned char *packet; }; struct filemode { int mtime; }; struct ifmode { unsigned long bytes; }; struct tempmode { int in_use; unsigned char have1, have2, have3; }; union wdog_options { struct pingmode net; struct filemode file; struct ifmode iface; struct tempmode temp; }; struct list { char *name; int version; time_t last_time; int repair_count; union wdog_options parameter; struct list *next; }; /* === Constants === */ #define DATALEN (64 - 8) #define MAXIPLEN 60 #define MAXICMPLEN 76 #define MAXPACKET (65536 - 60 - 8) /* max packet size */ #ifndef TRUE #define TRUE 1 #endif #ifndef FALSE #define FALSE 0 #endif #define TS_SIZE 12 /* === External variables === */ /* From configfile.c */ extern int tint; extern int logtick; extern int ticker; extern int schedprio; extern int maxload1; extern int maxload5; extern int maxload15; extern int minpages; extern int minalloc; extern int maxtemp; extern int pingcount; extern int temp_poweroff; extern int sigterm_delay; extern int repair_max; extern char *devname; extern char *admin; extern int test_timeout; /* test-binary time out value. */ extern int repair_timeout; /* repair-binary time out value. */ extern int dev_timeout; /* Watchdog hardware time-out. */ extern int retry_timeout; /* Retry on non-critical errors. */ extern char *logdir; extern char *heartbeat; extern int hbstamps; extern int realtime; extern struct list *tr_bin_list; extern struct list *file_list; extern struct list *target_list; extern struct list *pidfile_list; extern struct list *iface_list; extern struct list *temp_list; extern char *repair_bin; /* = Not (yet) from config file. = */ extern int softboot; extern int verbose; /* From watchdog.c */ extern char *filename_buf; /* From daemon-pid.c */ extern pid_t daemon_pid; /* === Function prototypes === */ #ifndef GCC_NORETURN #ifdef __GNUC__ #define GCC_NORETURN __attribute__((noreturn)) #else #define GCC_NORETURN #endif /*!__GNUC__ */ #endif /*!GCC_NORETURN */ /** file_stat.c **/ int check_file_stat(struct list *); /** file_table.c **/ int check_file_table(void); /** keep_alive.c **/ int open_watchdog(char *name, int timeout); int set_watchdog_timeout(int timeout); int keep_alive(void); int get_watchdog_fd(void); int close_watchdog(void); void safe_sleep(int sec); /** load.c **/ int open_loadcheck(void); int check_load(void); int close_loadcheck(void); /** net.c **/ int check_net(char *target, int sock_fp, struct sockaddr to, unsigned char *packet, int time, int count); int open_netcheck(struct list *tlist); /** temp.c **/ int open_tempcheck(struct list *tlist); int check_temp(struct list *act); int close_tempcheck(void); /** test_binary.c **/ int check_bin(char *, int, int); void free_process(void); /** pidfile.c **/ int check_pidfile(struct list *); /** iface.c **/ int check_iface(struct list *); /** memory.c **/ int open_memcheck(void); int check_memory(void); int close_memcheck(void); int check_allocatable(void); /** shutdown.c **/ void do_shutdown(int errorcode); void sigterm_handler(int arg); void terminate(int ecode) GCC_NORETURN; /** heartbeat.c **/ int open_heartbeat(void); int write_heartbeat(void); int close_heartbeat(void); /** lock_mem.c **/ void lock_our_memory(int do_lock, int priority, pid_t pid); void unlock_our_memory(void); /** daemon-pid.c **/ int write_pid_file(const char *fname); int remove_pid_file(void); int wd_daemon(int nochdir, int noclose); /** configfile.c **/ void read_config(char *configfile); /** errorcodes.c **/ const char *wd_strerror(int err); /** sigterm.c **/ extern volatile sig_atomic_t _running; void sigterm_handler(int arg); #endif /*_EXTERN_H_*/ watchdog-5.15/include/lomount.h0000644000175000017500000000026412664037554016341 0ustar michaelmichaelextern int mount_verbose; extern int set_loop(const char *, const char *, int, const char *, int *); extern int del_loop(const char *); extern char *find_unused_loop_device(void); watchdog-5.15/include/fstab.h0000644000175000017500000000133512664037554015743 0ustar michaelmichael#define _PATH_FSTAB "/etc/fstab" #define MOUNTED_LOCK "/etc/mtab~" #define MOUNTED_TEMP "/etc/mtab.tmp" #define LOCK_TIMEOUT 10 int mtab_is_writable(void); int mtab_does_not_exist(void); int mtab_is_a_symlink(void); struct mntentchn { struct mntentchn *nxt, *prev; char *mnt_fsname; char *mnt_dir; char *mnt_type; char *mnt_opts; }; struct mntentchn *mtab_head(void); struct mntentchn *getmntfile(const char *name); struct mntentchn *getmntoptfile(const char *file); struct mntentchn *fstab_head(void); struct mntentchn *getfsfile(const char *file); struct mntentchn *getfsspec(const char *spec); #include void lock_mtab(void); void unlock_mtab(void); void update_mtab(const char *special, struct mntent *with); watchdog-5.15/include/stamp-h.in0000644000175000017500000000001212664037554016363 0ustar michaelmichaeltimestamp watchdog-5.15/include/nfs_mount4.h0000644000175000017500000000262112664037554016737 0ustar michaelmichael/* * We want to be able to compile mount on old kernels in such a way * that the binary will work well on more recent kernels. * Thus, if necessary we teach nfsmount.c the structure of new fields * that will come later. * * Moreover, the new kernel includes conflict with glibc includes * so it is easiest to ignore the kernel altogether (at compile time). */ #define NFS_MOUNT_VERSION 4 struct nfs2_fh { char data[32]; }; struct nfs3_fh { unsigned short size; unsigned char data[64]; }; struct nfs_mount_data { int version; /* 1 */ int fd; /* 1 */ struct nfs2_fh old_root; /* 1 */ int flags; /* 1 */ int rsize; /* 1 */ int wsize; /* 1 */ int timeo; /* 1 */ int retrans; /* 1 */ int acregmin; /* 1 */ int acregmax; /* 1 */ int acdirmin; /* 1 */ int acdirmax; /* 1 */ struct sockaddr_in addr; /* 1 */ char hostname[256]; /* 1 */ int namlen; /* 2 */ unsigned int bsize; /* 3 */ struct nfs3_fh root; /* 4 */ }; /* bits in the flags field */ #define NFS_MOUNT_SOFT 0x0001 /* 1 */ #define NFS_MOUNT_INTR 0x0002 /* 1 */ #define NFS_MOUNT_SECURE 0x0004 /* 1 */ #define NFS_MOUNT_POSIX 0x0008 /* 1 */ #define NFS_MOUNT_NOCTO 0x0010 /* 1 */ #define NFS_MOUNT_NOAC 0x0020 /* 1 */ #define NFS_MOUNT_TCP 0x0040 /* 2 */ #define NFS_MOUNT_VER3 0x0080 /* 3 */ #define NFS_MOUNT_KERBEROS 0x0100 /* 3 */ #define NFS_MOUNT_NONLM 0x0200 /* 3 */ #define NFS_MOUNT_BROKEN_SUID 0x0400 /* 4 */ watchdog-5.15/include/logmessage.h0000644000175000017500000000421612664037554016773 0ustar michaelmichael#ifndef _LOGMESSAGE_H #define _LOGMESSAGE_H /* These include files are for the strerror(errno) replacement for '%m' format option of syslog. */ #include #include /* * We need the LOG_? values used for log_message() so either include * or we include manually define them as an alternative. */ #ifdef USE_SYSLOG #include #else #define LOG_EMERG 0 /* system is unusable */ #define LOG_ALERT 1 /* action must be taken immediately */ #define LOG_CRIT 2 /* critical conditions */ #define LOG_ERR 3 /* error conditions */ #define LOG_WARNING 4 /* warning conditions */ #define LOG_NOTICE 5 /* normal but significant condition */ #define LOG_INFO 6 /* informational */ #define LOG_DEBUG 7 /* debug-level messages */ #endif /* !USE_SYSLOG */ /* * Define exit status for fatal_error() calls (from sundries.h originally). * Bits below are ORed. */ #ifndef EX_USAGE #define EX_USAGE 1 /* incorrect invocation or permission */ #define EX_SYSERR 2 /* out of memory, cannot fork, ... */ #define EX_SOFTWARE 4 /* internal mount bug or wrong version */ #define EX_USER 8 /* user interrupt */ #define EX_FILEIO 16 /* problems writing, locking, ... mtab/fstab */ #define EX_FAIL 32 /* mount failure */ #define EX_SOMEOK 64 /* some mount succeeded */ #define EX_BG 256 /* retry in background (internal only) */ #endif /*EX_USAGE*/ /* Define bit-values for the 'flags' in open_logging() to decide where messages go. */ #define MSG_TO_STDERR 1 #define MSG_TO_SYSLOG 2 /* * Enable the printf() format string checking of gcc: * http://gcc.gnu.org/onlinedocs/gcc-3.2/gcc/Function-Attributes.html */ #ifndef PRINTF_STYLE #if defined( __GNUC__ ) #define PRINTF_STYLE(Fmt, FirstArg) __attribute__ ((format (printf, Fmt, FirstArg))) #else #define PRINTF_STYLE(Fmt, FirstArg) #endif /* !__GNUC__ */ #endif /* PRINTF_STYLE */ /** logmessage.c **/ int open_logging(const char *name, int flags); int log_message(int level, const char *fmt, ...) PRINTF_STYLE(2, 3); void fatal_error(int exitcode, const char *fmt, ...) PRINTF_STYLE(2, 3); int close_logging(void); int suspend_logging(void); int resume_logging(void); #endif /*_LOGMESSAGE_H */ watchdog-5.15/watchdog.sysconfig0000644000175000017500000000023512664037554016574 0ustar michaelmichael# # /etc/sysconfig/watchdog # # Controls the behaviour of the watchdog # # VERBOSE - Enables or disables verbose operation (logging to syslog) # VERBOSE=no watchdog-5.15/watchdog.conf.50000644000175000017500000002004612664037554015662 0ustar michaelmichael.TH WATCHDOG.CONF 5 "January 2016" .UC 4 .SH NAME watchdog.conf \- configuration file for the watchdog daemon .SH DESCRIPTION This file carries all configuration options for the Linux watchdog daemon. Each option has to be written on a line for itself. Comments start with '#'. Blanks are ignored except after the '=' sign. An empty text after the '=' sign disables the feature as long as that makes sense. .SH OPTIONS .TP interval = Set the highest possible interval between two writes to the watchdog device. The device is triggered after each check regardless of the time it took. After finishing all checks watchdog goes to sleep for a full cycle of seconds. Default value is 1 second. The kernel drivers expects a write command every minute. Otherwise the system will be rebooted. Therefore an interval of more than a minute can only be used with the force command-line option [\-\-force | \-f]. .TP logtick = If you enable verbose logging, a message is written into the syslog or a logfile. While this is nice, it is not necessary to get a message every interval which really fills up disk and needs CPU. logtick allows adjustment of the number of intervals skipped before a log message is written. If you use logtick = 60 and interval = 10, only every 10 minutes (600 seconds) a message is written. This may make the exact time of a crash harder to find but greatly reduces disk usage and administrator nerves if you're looking for a particular syslog entry in between of watchdog messages. .TP max-load-1 = Set the maximal allowed load average for a 1 minute span. Once this load average is reached the system is rebooted. Default value is 0. That means the load average check is disabled. Be careful not to set this parameter too low. To set a value less then the predefined minimal value of 2, you have to use the \-f command line option. .TP max-load-5 = Set the maximal allowed load average for a 5 minute span. Once this load average is reached the system is rebooted. Default value is 3/4*max-load-1. Be careful not to this parameter too low. To set a value less then the predefined minimal value of 2, you have to use the \-f command line option. .TP max-load-15 = Set the maximal allowed load average for a 15 minute span. Once this load average is reached the system is rebooted. Default value is 1/2*max-load-1. Be careful not to this parameter too low. To set a value less then the predefined minimal value of 2, you have to use the \-f command line option. .TP min-memory = Set the minimal amount of virtual memory that has to stay free. Note that this is in memory pages (4kB on x86). Default value is 0 pages which means this test is disabled. The page size is taken from the system include files. This is a 'passive' test and works by reading /proc/meminfo .TP allocatable-memory = Set the minimum amount of allocatable memory available on the system. Note that this is in pages. Default value is 0 pages which means the test is disabled. As with min-memory, the page size is taken from the system include files. This is an 'active' test and it works by attempting to memory-map a block of the configured size. .TP watchdog-device = Set the watchdog device name, typically /dev/watchdog. Default is to disable keep alive support. This should be tested by running the daemon from the command line before configuring it to start automatically on booting. .TP watchdog-timeout = Set the watchdog device timeout during startup. If not set, a default is used that should be set to the kernel timer margin at compile time. .TP temperature-sensor = Set the temperature sensor name. This is normally a 'virtual file' under /sys and it contains the temperature in milli-Celsius. Usually these are generated by the .B sensors package, but take care as device enumeration may not be fixed. Default is to disable temperature checking. Multiple sensors can be used by having repeated temperature-sensor entries. .TP max-temperature = Set the maximal allowed temperature. Once this temperature is reached the system is stopped. Default value is 90 C. Watchdog will issue warnings once the temperature increases 90%, 95% and 98% of this temperature. .TP temp-power-off = Set the watchdog action on overheating. Yes option (default) is to power the machine off, no option is to halt machine and allow Ctrl-Alt-Del reboot. .TP file = Set file name for file mode. This option can be given as often as you like to check several files. .TP change = Set the change interval time for file mode. This options always belongs to the active filename, that is when finding a 'change =' line watchdog assumes it belongs to the most recently read 'file =' line. They don't necessarily have to follow each other directly. But you cannot specify a 'change =' before a 'file ='. The default is to only stat the file and don't look for changes. Using this feature to monitor changes in /var/log/messages might require some special syslog daemon configuration, e.g. rsyslog needs "$ActionWriteAllMarkMessages on" to be set to make sure the marks are written no matter what. .TP pidfile = Set pidfile name for server test mode. This option can be given as often as you like to check several servers. .TP ping = Set IPv4 address for ping mode. This option can be used more than once to check different connections. .TP interface = Set interface name for network mode. This option can be used more than once to check different interfaces. Note it is only possible to check physical interfaces, and not aliased IP interfaces. .TP test-binary = Execute the given binary to do some user defined tests. .TP test-timeout = User defined tests may only run for seconds. Set to 0 for unlimited. .TP repair-binary = Execute the given binary in case of a problem instead of shutting down the system. .TP repair-timeout = repair command may only run for seconds. Set to 0 for 'unlimited', but note that the hardware timer is not refreshed in this case so the system will hard-reset at some point. .TP retry-timeout = Allow most error conditions to persist for seconds. Set to 0 for immediate action (like softboot behaviour). .TP repair-maximum = This allows no more then repair attempts against a given fault that report success (i.e. return 0), but fail to clear the fault, before a reboot is initiated anyway. If set to zero then a repairable fault can always be blocked by a repair program reporting success (previous daemon behaviour). .TP admin = Email address to send admin mail to. That is, who shall be notified that the machine is being halted or rebooted. Default is 'root'. If you want to disable notification via email just set admin to en empty string. .TP realtime = If set to yes watchdog will lock itself into memory so it is never swapped out. .TP priority = Set the schedule priority for realtime mode. .TP test-directory = Set the directory to run user test/repair scripts. Default is '/etc/watchdog.d' See the Test Directory section in watchdog(8) for more information. .TP log-dir = Set the log directory to capture the standard output and standard error from repair-binary and test-binary execution. Default is '/var/log/watchdog'. .TP sigterm-delay =