From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95863C432C3 for ; Sat, 16 Nov 2019 15:49:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5F9FC20729 for ; Sat, 16 Nov 2019 15:49:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573919340; bh=QapvbyAR0UCwp5TQJRgpF5BAlHZWPUtIxkqmXmTEBlI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=g5PkapfY1eQ4OFAdXjKcUZPVXlxa+qjc+2I6zSFiNHE16ouQIV7rzzBc5N0RmZ/iJ 7mnghRpOseGJalaOwOvJkYr1ICwo1YThm2Qp3+L/qGbNprIoDLM5Eu0LBcjCFMrT3p tqWdd7txQDJKqU4YdPpc/N+iIA0ac2K4pY/dB1Do= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730252AbfKPPs7 (ORCPT ); Sat, 16 Nov 2019 10:48:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:56216 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730190AbfKPPsv (ORCPT ); Sat, 16 Nov 2019 10:48:51 -0500 Received: from sasha-vm.mshome.net (unknown [50.234.116.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8668020729; Sat, 16 Nov 2019 15:48:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573919330; bh=QapvbyAR0UCwp5TQJRgpF5BAlHZWPUtIxkqmXmTEBlI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fv+690B9DzP4h2LiqZsY6UWcLvxYQi6WbHGi2YP8rW20GyY4IQLBvmOdE1IJ36K0d /Np8FPNPCcFPuZNTKTN0k0CjeYtNBf9GtSD/ah7fotG/KDRIyT6Dy145592qWJxbCF bpJJW39zcu3WUOvjFeNinIdKmah1sx99ChJv+xKM= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "Shuah Khan (Samsung OSG)" , Sasha Levin , linux-kselftest@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 072/150] selftests: watchdog: fix message when /dev/watchdog open fails Date: Sat, 16 Nov 2019 10:46:10 -0500 Message-Id: <20191116154729.9573-72-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191116154729.9573-1-sashal@kernel.org> References: <20191116154729.9573-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Shuah Khan (Samsung OSG)" [ 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) Signed-off-by: Sasha Levin --- tools/testing/selftests/watchdog/watchdog-test.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/watchdog/watchdog-test.c b/tools/testing/selftests/watchdog/watchdog-test.c index 6e290874b70e2..e029e2017280f 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); } -- 2.20.1