aboutsummaryrefslogtreecommitdiff
path: root/tools/lib/api/fs/fs.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <[email protected]>2014-12-11 13:37:10 -0300
committerArnaldo Carvalho de Melo <[email protected]>2014-12-11 17:53:00 -0300
commit42e3c4a1274d49b42e9d4306ec096b282a6e14aa (patch)
treef87fd0437839d08c4b6fc1bbdfddfc5b278e362c /tools/lib/api/fs/fs.c
parent3a351127cbc682c3a0ae7383c4ff6fd0e8fee83c (diff)
tools lib fs: Add sysctl__read_int helper
Will come in handy for tools, see next patches. Cc: Adrian Hunter <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: David Ahern <[email protected]> Cc: Don Zickus <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Mike Galbraith <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Paul Mackerras <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Link: http://lkml.kernel.org/n/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
Diffstat (limited to 'tools/lib/api/fs/fs.c')
-rw-r--r--tools/lib/api/fs/fs.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index b8d0df8878d1..65d9be3f9887 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);
+}