FreeBSD/usr.sbin/watchdogd/watchdogd.c
/*
 * Toggle the kernel's watchdog. This routine is used to enable and
 * disable the watchdog.
 */
Toggle the kernel's watchdog. This routine is used to enable and
disable the watchdog.
Toggle the kernel ' s watchdog . This routine is used to enable and disable the watchdog .
static int
watchdog_onoff(int onoff)
{
	int error;
	if (is_dry_run)
		return 0;
	if (onoff) {
		error = ioctl(fd, WDIOC_SETSOFT, &softtimeout_set);
		if (error) {
			warn("setting WDIOC_SETSOFT %d", softtimeout_set);
			return (error);
		}
		error = watchdog_patpat((timeout|WD_ACTIVE));
		if (error) {
			warn("watchdog_patpat failed");
			goto failsafe;
		}
		if (softtimeout_act_set) {
			error = ioctl(fd, WDIOC_SETSOFTTIMEOUTACT,
			    &softtimeout_act);
			if (error) {
				warn("setting WDIOC_SETSOFTTIMEOUTACT %d",
				    softtimeout_act);
				goto failsafe;
			}
		}
		if (pretimeout_set) {
			error = ioctl(fd, WDIOC_SETPRETIMEOUT, &pretimeout);
			if (error) {
				warn("setting WDIOC_SETPRETIMEOUT %d",
				    pretimeout);
				goto failsafe;
			}
		}
		if (pretimeout_act_set) {
			error = ioctl(fd, WDIOC_SETPRETIMEOUTACT,
			    &pretimeout_act);
			if (error) {
				warn("setting WDIOC_SETPRETIMEOUTACT %d",
				    pretimeout_act);
				goto failsafe;
			}
		}
		return watchdog_patpat((timeout|WD_ACTIVE));
	 } else {
		return watchdog_patpat(exit_timeout);
	 }
failsafe:
	watchdog_patpat(exit_timeout);
	return (error);
}
static int watchdog_onoff ( int onoff ) { int error ; if ( is_dry_run ) return 0 ; if ( onoff ) { error = ioctl ( fd , WDIOC_SETSOFT , & softtimeout_set ) ; if ( error ) { warn ( " " , softtimeout_set ) ; return ( error ) ; } error = watchdog_patpat ( ( timeout | WD_ACTIVE ) ) ; if ( error ) { warn ( " " ) ; goto failsafe ; } if ( softtimeout_act_set ) { error = ioctl ( fd , WDIOC_SETSOFTTIMEOUTACT , & softtimeout_act ) ; if ( error ) { warn ( " " , softtimeout_act ) ; goto failsafe ; } } if ( pretimeout_set ) { error = ioctl ( fd , WDIOC_SETPRETIMEOUT , & pretimeout ) ; if ( error ) { warn ( " " , pretimeout ) ; goto failsafe ; } } if ( pretimeout_act_set ) { error = ioctl ( fd , WDIOC_SETPRETIMEOUTACT , & pretimeout_act ) ; if ( error ) { warn ( " " , pretimeout_act ) ; goto failsafe ; } } return watchdog_patpat ( ( timeout | WD_ACTIVE ) ) ; } else { return watchdog_patpat ( exit_timeout ) ; } failsafe : watchdog_patpat ( exit_timeout ) ; return ( error ) ; }
Toggle the kernel's watchdog.
Toggle the kernel ' s watchdog .
/* fake successful watchdog op if a dry run */ /*
		 * Call the WDIOC_SETSOFT regardless of softtimeout_set
		 * because we'll need to turn it off if someone had turned
		 * it on.
		 */ /* pat one more time for good measure */