[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250126150923.962963-1-sashal@kernel.org>
Date: Sun, 26 Jan 2025 10:09:20 -0500
From: Sasha Levin <sashal@...nel.org>
To: linux-kernel@...r.kernel.org,
stable@...r.kernel.org
Cc: Ian Rogers <irogers@...gle.com>,
Namhyung Kim <namhyung@...nel.org>,
Arnaldo Carvalho de Melo <acme@...hat.com>,
Adrian Hunter <adrian.hunter@...el.com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Andi Kleen <ak@...ux.intel.com>,
Athira Rajeev <atrajeev@...ux.vnet.ibm.com>,
Ben Gainey <ben.gainey@....com>,
Colin Ian King <colin.i.king@...il.com>,
Dominique Martinet <asmadeus@...ewreck.org>,
Ilkka Koskinen <ilkka@...amperecomputing.com>,
Ingo Molnar <mingo@...hat.com>,
James Clark <james.clark@...aro.org>,
Jiri Olsa <jolsa@...nel.org>,
Kan Liang <kan.liang@...ux.intel.com>,
Mark Rutland <mark.rutland@....com>,
Oliver Upton <oliver.upton@...ux.dev>,
Paran Lee <p4ranlee@...il.com>,
Peter Zijlstra <peterz@...radead.org>,
"Steinar H . Gunderson" <sesse@...gle.com>,
Steven Rostedt <rostedt@...dmis.org>,
Thomas Falcon <thomas.falcon@...el.com>,
Weilin Wang <weilin.wang@...el.com>,
Yang Jihong <yangjihong@...edance.com>,
Yang Li <yang.lee@...ux.alibaba.com>,
Ze Gao <zegao2021@...il.com>,
Zixian Cai <fzczx123@...il.com>,
zhaimingbing <zhaimingbing@...s.chinamobile.com>,
Sasha Levin <sashal@...nel.org>
Subject: [PATCH AUTOSEL 5.15 1/3] tool api fs: Correctly encode errno for read/write open failures
From: Ian Rogers <irogers@...gle.com>
[ Upstream commit 05be17eed774aaf56f6b1e12714325ca3a266c04 ]
Switch from returning -1 to -errno so that callers can determine types
of failure.
Reviewed-by: Namhyung Kim <namhyung@...nel.org>
Signed-off-by: Ian Rogers <irogers@...gle.com>
Acked-by: Arnaldo Carvalho de Melo <acme@...hat.com>
Cc: Adrian Hunter <adrian.hunter@...el.com>
Cc: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc: Andi Kleen <ak@...ux.intel.com>
Cc: Athira Rajeev <atrajeev@...ux.vnet.ibm.com>
Cc: Ben Gainey <ben.gainey@....com>
Cc: Colin Ian King <colin.i.king@...il.com>
Cc: Dominique Martinet <asmadeus@...ewreck.org>
Cc: Ilkka Koskinen <ilkka@...amperecomputing.com>
Cc: Ingo Molnar <mingo@...hat.com>
Cc: James Clark <james.clark@...aro.org>
Cc: Jiri Olsa <jolsa@...nel.org>
Cc: Kan Liang <kan.liang@...ux.intel.com>
Cc: Mark Rutland <mark.rutland@....com>
Cc: Oliver Upton <oliver.upton@...ux.dev>
Cc: Paran Lee <p4ranlee@...il.com>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Steinar H. Gunderson <sesse@...gle.com>
Cc: Steven Rostedt (VMware) <rostedt@...dmis.org>
Cc: Thomas Falcon <thomas.falcon@...el.com>
Cc: Weilin Wang <weilin.wang@...el.com>
Cc: Yang Jihong <yangjihong@...edance.com>
Cc: Yang Li <yang.lee@...ux.alibaba.com>
Cc: Ze Gao <zegao2021@...il.com>
Cc: Zixian Cai <fzczx123@...il.com>
Cc: zhaimingbing <zhaimingbing@...s.chinamobile.com>
Link: https://lore.kernel.org/r/20241118225345.889810-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
tools/lib/api/fs/fs.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index 82f53d81a7a78..a0a6a907315f0 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -323,7 +323,7 @@ int filename__read_int(const char *filename, int *value)
int fd = open(filename, O_RDONLY), err = -1;
if (fd < 0)
- return -1;
+ return -errno;
if (read(fd, line, sizeof(line)) > 0) {
*value = atoi(line);
@@ -341,7 +341,7 @@ static int filename__read_ull_base(const char *filename,
int fd = open(filename, O_RDONLY), err = -1;
if (fd < 0)
- return -1;
+ return -errno;
if (read(fd, line, sizeof(line)) > 0) {
*value = strtoull(line, NULL, base);
@@ -428,7 +428,7 @@ int filename__write_int(const char *filename, int value)
char buf[64];
if (fd < 0)
- return err;
+ return -errno;
sprintf(buf, "%d", value);
if (write(fd, buf, sizeof(buf)) == sizeof(buf))
--
2.39.5
Powered by blists - more mailing lists