* RFC: watchdog
@ 2018-02-20 7:19 Masatake YAMATO
2018-02-20 10:48 ` Karel Zak
0 siblings, 1 reply; 3+ messages in thread
From: Masatake YAMATO @ 2018-02-20 7:19 UTC (permalink / raw)
To: util-linux; +Cc: yamato
Hi,
As far as I know, there is no enough popular tool to inspect the
current status of /dev/watchdog. watchdog device provides ioctl
commands to return timeout value and timeleft value. The tool
I assume is reports the values for given device.
/sys/class/watchdog is provided. However, whether it
is available or not is up to kernel build-configuration.
How do you think about adding such tool to util-linux?
Do you think such command should be in a separate project?
If the answer is yes, what command name do you prefer to for
the command? ("watchdog" is not good name).
If the answer is no, could you tell me a project or person
I should talk to about this command?
I attached a prototype.
Masatake YAMATO
/* catdog.c
* No copyright is claimed. This code is in the public domain; do with
* it what you wish. */
#include <stdio.h>
#include <stdlib.h>
#include <error.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <linux/watchdog.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
static void
usage(char *program, int status, FILE *fp)
{
fprintf(fp, "Usage: ");
fprintf(fp, " %s DEVICE", program);
exit(status);
}
int
main(int argc, char **argv)
{
if (argc < 2)
usage(argv[0], 1, stderr);
int fd;
if (strcmp(argv[1], "-h") == 0
|| strcmp(argv[1], "-?") == 0
|| strcmp(argv[1], "--help") == 0)
usage(argv[0], 0, stdout);
/* TODO: Check the major number */
fd = open(argv[1], O_RDONLY);
if (fd < 0)
error(1, errno, "cannot open the watchdog device: %s", argv[1]);
int p = 0;
unsigned int q;
if (ioctl(fd, WDIOC_GETSTATUS, &q) < 0)
perror ("Error in GETSTATUS");
else
printf("BOOTSTATUS: %u\n", q);
if (ioctl(fd, WDIOC_GETBOOTSTATUS, &p) < 0)
perror ("Error in GETBOOTSTATUS");
else
printf("BOOTSTATUS: %d\n", p);
if (ioctl(fd, WDIOC_GETTIMEOUT, &p) < 0)
perror ("Error in GETTIMEOUT");
else
printf("TIMEOUT: %d\n", p);
if (ioctl(fd, WDIOC_GETTIMELEFT, &p) < 0)
perror ("Error in GETTIMELEFT");
else
printf("TIMELEFT: %d\n", p);
return 0;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: RFC: watchdog
2018-02-20 7:19 RFC: watchdog Masatake YAMATO
@ 2018-02-20 10:48 ` Karel Zak
2018-02-20 12:12 ` Masatake YAMATO
0 siblings, 1 reply; 3+ messages in thread
From: Karel Zak @ 2018-02-20 10:48 UTC (permalink / raw)
To: Masatake YAMATO; +Cc: util-linux
On Tue, Feb 20, 2018 at 04:19:09PM +0900, Masatake YAMATO wrote:
> As far as I know, there is no enough popular tool to inspect the
> current status of /dev/watchdog. watchdog device provides ioctl
> commands to return timeout value and timeleft value. The tool
> I assume is reports the values for given device.
>
> /sys/class/watchdog is provided. However, whether it
> is available or not is up to kernel build-configuration.
>
> How do you think about adding such tool to util-linux?
> Do you think such command should be in a separate project?
> If the answer is yes, what command name do you prefer to for
> the command? ("watchdog" is not good name).
>
> If the answer is no, could you tell me a project or person
> I should talk to about this command?
man wdctl :-)
# wdctl
Device: /dev/watchdog
Identity: iTCO_wdt [version 0]
Timeout: 30 seconds
Pre-timeout: 0 seconds
Timeleft: 2 seconds
FLAG DESCRIPTION STATUS BOOT-STATUS
KEEPALIVEPING Keep alive ping reply 1 0
MAGICCLOSE Supports magic close char 0 0
SETTIMEOUT Set timeout (in seconds) 0 0
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: RFC: watchdog
2018-02-20 10:48 ` Karel Zak
@ 2018-02-20 12:12 ` Masatake YAMATO
0 siblings, 0 replies; 3+ messages in thread
From: Masatake YAMATO @ 2018-02-20 12:12 UTC (permalink / raw)
To: kzak; +Cc: util-linux
Oh, thank you.
Masatake YAMATO
> On Tue, Feb 20, 2018 at 04:19:09PM +0900, Masatake YAMATO wrote:
>> As far as I know, there is no enough popular tool to inspect the
>> current status of /dev/watchdog. watchdog device provides ioctl
>> commands to return timeout value and timeleft value. The tool
>> I assume is reports the values for given device.
>>
>> /sys/class/watchdog is provided. However, whether it
>> is available or not is up to kernel build-configuration.
>>
>> How do you think about adding such tool to util-linux?
>> Do you think such command should be in a separate project?
>> If the answer is yes, what command name do you prefer to for
>> the command? ("watchdog" is not good name).
>>
>> If the answer is no, could you tell me a project or person
>> I should talk to about this command?
>
> man wdctl :-)
>
> # wdctl
> Device: /dev/watchdog
> Identity: iTCO_wdt [version 0]
> Timeout: 30 seconds
> Pre-timeout: 0 seconds
> Timeleft: 2 seconds
> FLAG DESCRIPTION STATUS BOOT-STATUS
> KEEPALIVEPING Keep alive ping reply 1 0
> MAGICCLOSE Supports magic close char 0 0
> SETTIMEOUT Set timeout (in seconds) 0 0
>
> Karel
>
>
> --
> Karel Zak <kzak@redhat.com>
> http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-02-20 12:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-20 7:19 RFC: watchdog Masatake YAMATO
2018-02-20 10:48 ` Karel Zak
2018-02-20 12:12 ` Masatake YAMATO
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).