diff options
Diffstat (limited to 'tools/lib/api/fs/fs.c')
-rw-r--r-- | tools/lib/api/fs/fs.c | 13 |
1 files changed, 13 insertions, 0 deletions
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); +} |