From a6ac6ad76d16ebcd81fb8f1517aaf422c60e6488 Mon Sep 17 00:00:00 2001 From: Benjamin Larsson Date: Fri, 15 Jun 2018 15:47:30 +0200 Subject: [PATCH] watchdog: fix running on new 4.1 kernel --- iwatchdog/src/src/watchdog.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/iwatchdog/src/src/watchdog.c b/iwatchdog/src/src/watchdog.c index a4c18283b..936f245fd 100644 --- a/iwatchdog/src/src/watchdog.c +++ b/iwatchdog/src/src/watchdog.c @@ -5,15 +5,22 @@ #include const char *watchdog_file = "/proc/watchdog"; +const char *watchdog_file_nvram = "/proc/nvram/watchdog"; const char *init_string = "1 5000000 1 4"; const char *kicker = "OK"; int main(int argc, char **argv) { - int fd = open(watchdog_file, O_WRONLY); + int ret = 0; + char *wdt_string_prt = watchdog_file; + int fd = open(wdt_string_prt, O_WRONLY); if (fd < 0) { - perror("Open watchdog file"); - exit(1); + wdt_string_prt = watchdog_file_nvram; + fd = open(wdt_string_prt, O_WRONLY); + if (fd < 0) { + perror("Open watchdog file"); + exit(1); + } } /* init */ @@ -23,14 +30,17 @@ int main(int argc, char **argv) perror("Error init watchdog"); exit(1); } + close(fd); while (1) { + fd = open(wdt_string_prt, O_WRONLY); sleep(1); res = write (fd, kicker, strlen(init_string) + 1); if (res < 0 ){ perror("Error kicking watchdog"); } + close(fd); } return 0; }