diff options
author | Shuah Khan (Samsung OSG) <shuah@kernel.org> | 2018-09-26 13:07:11 -0600 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-12-01 09:16:59 +0100 |
commit | 74685702363cc13dac2915bf47b49fa18627c666 (patch) | |
tree | 0f2f65b7343659ee860e66aca631235139aa2da1 /tools/testing | |
parent | 58ceffabad41aaab4dcf68490b10133344a2377e (diff) | |
download | linux-stable-74685702363cc13dac2915bf47b49fa18627c666.tar.gz linux-stable-74685702363cc13dac2915bf47b49fa18627c666.tar.bz2 linux-stable-74685702363cc13dac2915bf47b49fa18627c666.zip |
selftests: watchdog: fix message when /dev/watchdog open fails
[ Upstream commit 9a244229a4b850b11952a0df79607c69b18fd8df ]
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>
Diffstat (limited to 'tools/testing')
-rw-r--r-- | tools/testing/selftests/watchdog/watchdog-test.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/testing/selftests/watchdog/watchdog-test.c b/tools/testing/selftests/watchdog/watchdog-test.c index 6e290874b70e..e029e2017280 100644 --- a/tools/testing/selftests/watchdog/watchdog-test.c +++ b/tools/testing/selftests/watchdog/watchdog-test.c @@ -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); } |