diff options
-rw-r--r-- | tools/lib/perf/cpumap.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/tools/lib/perf/cpumap.c b/tools/lib/perf/cpumap.c index f7bde19558e2..a0c10ed9914e 100644 --- a/tools/lib/perf/cpumap.c +++ b/tools/lib/perf/cpumap.c @@ -11,6 +11,7 @@ #include <ctype.h> #include <limits.h> #include "internal.h" +#include <api/fs/fs.h> #define MAX_NR_CPUS 4096 @@ -103,12 +104,12 @@ static struct perf_cpu_map *cpu_map__new_sysconf(void) static struct perf_cpu_map *cpu_map__new_sysfs_online(void) { struct perf_cpu_map *cpus = NULL; - FILE *onlnf; + char *buf = NULL; + size_t buf_len; - onlnf = fopen("/sys/devices/system/cpu/online", "r"); - if (onlnf) { - cpus = perf_cpu_map__read(onlnf); - fclose(onlnf); + if (sysfs__read_str("devices/system/cpu/online", &buf, &buf_len) >= 0) { + cpus = perf_cpu_map__new(buf); + free(buf); } return cpus; } |