[<prev] [next>] [day] [month] [year] [list]
Date: Fri, 12 Dec 2014 00:19:24 -0800
From: tip-bot for Arnaldo Carvalho de Melo <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: paulus@...ba.org, tglx@...utronix.de, namhyung@...nel.org,
dzickus@...hat.com, acme@...hat.com, eranian@...gle.com,
hpa@...or.com, mingo@...nel.org, linux-kernel@...r.kernel.org,
dsahern@...il.com, fweisbec@...il.com, jolsa@...hat.com,
adrian.hunter@...el.com, bp@...e.de, efault@....de,
peterz@...radead.org
Subject: [tip:perf/urgent] tools lib fs: Add sysctl__read_int helper
Commit-ID: 42e3c4a1274d49b42e9d4306ec096b282a6e14aa
Gitweb: http://git.kernel.org/tip/42e3c4a1274d49b42e9d4306ec096b282a6e14aa
Author: Arnaldo Carvalho de Melo <acme@...hat.com>
AuthorDate: Thu, 11 Dec 2014 13:37:10 -0300
Committer: Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Thu, 11 Dec 2014 17:53:00 -0300
tools lib fs: Add sysctl__read_int helper
Will come in handy for tools, see next patches.
Cc: Adrian Hunter <adrian.hunter@...el.com>
Cc: Borislav Petkov <bp@...e.de>
Cc: David Ahern <dsahern@...il.com>
Cc: Don Zickus <dzickus@...hat.com>
Cc: Frederic Weisbecker <fweisbec@...il.com>
Cc: Jiri Olsa <jolsa@...hat.com>
Cc: Mike Galbraith <efault@....de>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Paul Mackerras <paulus@...ba.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Stephane Eranian <eranian@...gle.com>
Link: http://lkml.kernel.org/n/tip-nay9j62ztxpytt4ew1tkl4op@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
tools/lib/api/fs/fs.c | 13 +++++++++++++
tools/lib/api/fs/fs.h | 1 +
2 files changed, 14 insertions(+)
diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index b8d0df8..65d9be3 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -184,3 +184,16 @@ int filename__read_int(const char *filename, int *value)
close(fd);
return err;
}
+
+int sysctl__read_int(const char *sysctl, int *value)
+{
+ char path[PATH_MAX];
+ const char *procfs = procfs__mountpoint();
+
+ if (!procfs)
+ return -1;
+
+ snprintf(path, sizeof(path), "%s/sys/%s", procfs, sysctl);
+
+ return filename__read_int(path, value);
+}
diff --git a/tools/lib/api/fs/fs.h b/tools/lib/api/fs/fs.h
index 4d0aef6..6caa2bb 100644
--- a/tools/lib/api/fs/fs.h
+++ b/tools/lib/api/fs/fs.h
@@ -13,4 +13,5 @@ const char *sysfs__mountpoint(void);
const char *procfs__mountpoint(void);
int filename__read_int(const char *filename, int *value);
+int sysctl__read_int(const char *sysctl, int *value);
#endif /* __API_FS__ */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists