Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 74685702 authored by Shuah Khan (Samsung OSG)'s avatar Shuah Khan (Samsung OSG) Committed by Greg Kroah-Hartman
Browse files

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: default avatarShuah Khan (Samsung OSG) <shuah@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 58ceffab
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -89,7 +89,13 @@ int main(int argc, char *argv[])
	fd = open("/dev/watchdog", O_WRONLY);

	if (fd == -1) {
		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);
	}