Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp771154ybc; Sat, 16 Nov 2019 08:24:05 -0800 (PST) X-Google-Smtp-Source: APXvYqzakz832PbvU3HacwiZn6ZNrNLPxvUCPUjdSunpLBuEbH/DwRY3kmO+W76BlkAE15hqap/J X-Received: by 2002:a17:906:9248:: with SMTP id c8mr11179100ejx.47.1573921445175; Sat, 16 Nov 2019 08:24:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573921445; cv=none; d=google.com; s=arc-20160816; b=LvzF1MBAF9zIcVzkT0TxNI8EPh/m6Las4BwlXAd1ndzT5WiyJaF+6SE+HV94aNDgMO +dpBIa85NxA04jo3t3TE42GYE9pFq5txGbA9MQu8aEYc7uFESxlNeq7mmbwL5Fr+IiHf +zeNhT8IsGbEIfZUxEZK6iQlGyuLeW1WkSUjOe+TY2NBBXUq6KqkS1x7X3ZQEdDNKd8U zXS8vOUGo5nWmoiOAnoMydZ3YIGkBLrvBB6rAYL38RaKsffun5NnTq5iX9WqgBULqyS+ 62so03NsD6HTpKOfI5ygWCMk99h5au/2Yd0fqK+JRMU3/JX93vwEqsowc/NLZJuBypLr FYBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bi6qWyHqqNtQa/O3XnUAasdqzSgqwWTkCy1QnahL5PQ=; b=HqblCkIesVyLncuCUidqfvp2YzS+2AJ9RDt4syCRw8cnMYV3CGwDWU1jrNn1W8/RZY RAM40MCy1ullbS9qK+8KAE4oYqAn2Y3HFFG/NBHW8s8/gurXIfqI40VDdPGJ1S5ktY+p WCGvY4vavI+x0K97BuA77cWlXR/+LxVr0Ze/K6e8sCkY7y8/ideW+70FcTwRCtNmHPmi UORKoQDjGPMTqwaPK3aDgYbG58lKtnsk9xHaGvZhUaZ8QU3H0SIf6EOqfgjvNL9FG3g3 9RMIpVi+tM1WRE7OKRuJgJwgWDQD/0OI2p9uWvxWhjF0BqM2nO9fG4ZeEhYNjPJsfwWQ pc2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HfT59ara; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gv22si8230330ejb.2.2019.11.16.08.23.40; Sat, 16 Nov 2019 08:24:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HfT59ara; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732073AbfKPQVV (ORCPT + 99 others); Sat, 16 Nov 2019 11:21:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:47696 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728777AbfKPPng (ORCPT ); Sat, 16 Nov 2019 10:43:36 -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 7135620729; Sat, 16 Nov 2019 15:43:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573919015; bh=QapvbyAR0UCwp5TQJRgpF5BAlHZWPUtIxkqmXmTEBlI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HfT59ara3/2VtDWsfvuSZwURMpD3v2RHpJTGp53pzDt0mZDtt4ahZRfZj3Ylg9G0M LgqsXadZdA2RM0WPFeQx4CngxYv8YwhkCbmPRCzSRJiHir7M7Eey3pDDEeyIhhO+Ch /jDYQs0ibWkTdJHdSrupbs0wC3dFXU/FactJ4nsE= 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.19 117/237] selftests: watchdog: fix message when /dev/watchdog open fails Date: Sat, 16 Nov 2019 10:39:12 -0500 Message-Id: <20191116154113.7417-117-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191116154113.7417-1-sashal@kernel.org> References: <20191116154113.7417-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