diff options
Diffstat (limited to 'src/shared/watchdog.c')
-rw-r--r-- | src/shared/watchdog.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/shared/watchdog.c b/src/shared/watchdog.c index 4f3e0125f3..b0a422da84 100644 --- a/src/shared/watchdog.c +++ b/src/shared/watchdog.c @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1+ */ /*** This file is part of systemd. @@ -26,10 +27,12 @@ #include "fd-util.h" #include "log.h" +#include "string-util.h" #include "time-util.h" #include "watchdog.h" static int watchdog_fd = -1; +static char *watchdog_device = NULL; static usec_t watchdog_timeout = USEC_INFINITY; static int update_timeout(void) { @@ -83,7 +86,8 @@ static int open_watchdog(void) { if (watchdog_fd >= 0) return 0; - watchdog_fd = open("/dev/watchdog", O_WRONLY|O_CLOEXEC); + watchdog_fd = open(watchdog_device ?: "/dev/watchdog", + O_WRONLY|O_CLOEXEC); if (watchdog_fd < 0) return -errno; @@ -95,6 +99,10 @@ static int open_watchdog(void) { return update_timeout(); } +int watchdog_set_device(char *path) { + return free_and_strdup(&watchdog_device, path); +} + int watchdog_set_timeout(usec_t *usec) { int r; |