Signed-off-by: Federico Simoncelli fsimonce@redhat.com --- src/sysconfig.sanlock => init.d/sanlock.sysconfig | 0 wdmd/sysconfig.wdmd => init.d/wdmd.sysconfig | 3 ++ wdmd/main.c | 29 ++++++++++++-------- 3 files changed, 20 insertions(+), 12 deletions(-) rename src/sysconfig.sanlock => init.d/sanlock.sysconfig (100%) rename wdmd/sysconfig.wdmd => init.d/wdmd.sysconfig (73%)
diff --git a/src/sysconfig.sanlock b/init.d/sanlock.sysconfig similarity index 100% rename from src/sysconfig.sanlock rename to init.d/sanlock.sysconfig diff --git a/wdmd/sysconfig.wdmd b/init.d/wdmd.sysconfig similarity index 73% rename from wdmd/sysconfig.wdmd rename to init.d/wdmd.sysconfig index 06a13db..1ef8564 100644 --- a/wdmd/sysconfig.wdmd +++ b/init.d/wdmd.sysconfig @@ -5,4 +5,7 @@ # # To enable use of test scripts #WDMDOPTS="-G sanlock -S 1" +# +# To select a specific watchdog device +#WDMDOPTS="-G sanlock -w /dev/watchdog1"
diff --git a/wdmd/main.c b/wdmd/main.c index 1f1395a..9ea0018 100644 --- a/wdmd/main.c +++ b/wdmd/main.c @@ -65,6 +65,7 @@ static int shm_fd; static int allow_scripts; static int kill_script_sec; static char *scripts_dir = (char *)"/etc/wdmd.d"; +static char *watchdog_path = "/dev/watchdog";
struct script_status { uint64_t start; @@ -922,13 +923,13 @@ static int open_dev(void) int fd;
if (dev_fd != -1) { - log_error("/dev/watchdog already open fd %d", dev_fd); + log_error("watchdog already open fd %d", dev_fd); return -1; }
- fd = open("/dev/watchdog", O_WRONLY | O_CLOEXEC); + fd = open(watchdog_path, O_WRONLY | O_CLOEXEC); if (fd < 0) { - log_error("no /dev/watchdog, load a watchdog driver"); + log_error("no %s, load a watchdog driver", watchdog_path); return fd; }
@@ -943,7 +944,7 @@ static void close_watchdog_unclean(void) return; }
- log_error("/dev/watchdog closed unclean"); + log_error("%s closed unclean", watchdog_path); close(dev_fd); dev_fd = -1;
@@ -961,9 +962,9 @@ static void close_watchdog(void)
rv = write(dev_fd, "V", 1); if (rv < 0) - log_error("/dev/watchdog disarm write error %d", errno); + log_error("%s disarm write error %d", watchdog_path, errno); else - log_error("/dev/watchdog disarmed"); + log_error("%s disarmed", watchdog_path);
close(dev_fd); dev_fd = -1; @@ -981,7 +982,7 @@ static int setup_watchdog(void)
rv = ioctl(dev_fd, WDIOC_GETTIMEOUT, &timeout); if (rv < 0) { - log_error("/dev/watchdog failed to report timeout"); + log_error("%s failed to report timeout", watchdog_path); close_watchdog(); return -1; } @@ -993,18 +994,18 @@ static int setup_watchdog(void)
rv = ioctl(dev_fd, WDIOC_SETTIMEOUT, &timeout); if (rv < 0) { - log_error("/dev/watchdog failed to set timeout"); + log_error("%s failed to set timeout", watchdog_path); close_watchdog(); return -1; }
if (timeout != fire_timeout) { - log_error("/dev/watchdog failed to set new timeout"); + log_error("%s failed to set new timeout", watchdog_path); close_watchdog(); return -1; } out: - log_error("/dev/watchdog armed with fire_timeout %d", fire_timeout); + log_error("%s armed with fire_timeout %d", watchdog_path, fire_timeout);
return 0; } @@ -1153,7 +1154,7 @@ static int test_loop(void) if (dev_fd == -1) { open_dev(); pet_watchdog(); - log_error("/dev/watchdog reopen"); + log_error("%s reopen", watchdog_path); } else { pet_watchdog(); } @@ -1330,6 +1331,7 @@ static void print_usage_and_exit(int status) printf("-s <path> path to scripts dir (default %s)\n", scripts_dir); printf("-k <num> kill unfinished scripts after num seconds (default %d)\n", kill_script_sec); + printf("-w /dev/watchdog path to the watchdog device (default %s)\n", watchdog_path); exit(status); }
@@ -1362,7 +1364,7 @@ int main(int argc, char *argv[]) {0, 0, 0, 0 } };
- c = getopt_long(argc, argv, "hdVDFH:G:S:s:k:", + c = getopt_long(argc, argv, "hdVDFH:G:S:s:k:w:", long_options, &option_index); if (c == -1) break; @@ -1398,6 +1400,9 @@ int main(int argc, char *argv[]) case 'k': kill_script_sec = atoi(optarg); break; + case 'w': + watchdog_path = strdup(optarg); + break; } }
sanlock-devel@lists.fedorahosted.org