Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools lib fs: Add sysctl__read_int helper

Will come in handy for tools, see next patches.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-nay9j62ztxpytt4ew1tkl4op@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+14
+13
tools/lib/api/fs/fs.c
··· 184 184 close(fd); 185 185 return err; 186 186 } 187 + 188 + int sysctl__read_int(const char *sysctl, int *value) 189 + { 190 + char path[PATH_MAX]; 191 + const char *procfs = procfs__mountpoint(); 192 + 193 + if (!procfs) 194 + return -1; 195 + 196 + snprintf(path, sizeof(path), "%s/sys/%s", procfs, sysctl); 197 + 198 + return filename__read_int(path, value); 199 + }
+1
tools/lib/api/fs/fs.h
··· 13 13 const char *procfs__mountpoint(void); 14 14 15 15 int filename__read_int(const char *filename, int *value); 16 + int sysctl__read_int(const char *sysctl, int *value); 16 17 #endif /* __API_FS__ */