mirror of
https://github.com/torvalds/linux.git
synced 2026-06-08 06:25:52 +02:00
selftests: watchdog: fix message when /dev/watchdog open fails
[ Upstream commit 9a244229a4 ]
When /dev/watchdog open fails, watchdog exits with "watchdog not enabled"
message. This is incorrect when open fails due to insufficient privilege.
Fix message to clearly state the reason when open fails with EACCESS when
a non-root user runs it.
Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
58ceffabad
commit
7468570236
|
|
@ -89,7 +89,13 @@ int main(int argc, char *argv[])
|
|||
fd = open("/dev/watchdog", O_WRONLY);
|
||||
|
||||
if (fd == -1) {
|
||||
printf("Watchdog device not enabled.\n");
|
||||
if (errno == ENOENT)
|
||||
printf("Watchdog device not enabled.\n");
|
||||
else if (errno == EACCES)
|
||||
printf("Run watchdog as root.\n");
|
||||
else
|
||||
printf("Watchdog device open failed %s\n",
|
||||
strerror(errno));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user