{
struct blob_attr *tb[__WDT_MAX];
const char *status;
+ ssize_t timeleft = -1;
if (!msg)
return UBUS_STATUS_INVALID_ARGUMENT;
status = "offline";
else if (watchdog_get_stopped())
status = "stopped";
- else
+ else {
status = "running";
+ timeleft = watchdog_get_timeleft();
+ }
blob_buf_init(&b, 0);
blobmsg_add_string(&b, "status", status);
blobmsg_add_u32(&b, "timeout", watchdog_timeout(0));
blobmsg_add_u32(&b, "frequency", watchdog_frequency(0));
blobmsg_add_u8(&b, "magicclose", watchdog_get_magicclose());
+ if (timeleft >= 0)
+ blobmsg_add_u32(&b, "timeleft", timeleft);
ubus_send_reply(ctx, req, b.head);
return 0;
flags &= ~FD_CLOEXEC;
fcntl(wdt_fd, F_SETFD, flags);
}
+
+ssize_t watchdog_get_timeleft(void)
+{
+ ssize_t timeleft;
+
+ ioctl(wdt_fd, WDIOC_GETTIMELEFT, &timeleft);
+
+ return timeleft;
+}
#ifndef __PROCD_WATCHDOG_H
#define __PROCD_WATCHDOG_H
+#include <sys/types.h>
#include <stdbool.h>
#ifndef DISABLE_INIT
bool watchdog_get_stopped(void);
void watchdog_set_cloexec(bool val);
void watchdog_ping(void);
+ssize_t watchdog_get_timeleft(void);
#else
static inline void watchdog_init(int preinit)
{