blob: 56bd529c2c4971fa367e14fdb95868ce529c185e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
From: Shawn Bohrer <sbohrer@rgmadvisors.com>
Only count directories that match /sys/devices/system/cpu/cpu[0-9]+ as
CPUs. Previously any directory that started with cpu was counted which
caused cpufreq and cpuidle to be counted as CPUs.
Signed-off-by: Shawn Bohrer <sbohrer@rgmadvisors.com>
---
cputree.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/cputree.c b/cputree.c
index 3b0c982..b879785 100644
--- a/cputree.c
+++ b/cputree.c
@@ -25,6 +25,7 @@
*/
#include "config.h"
+#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -321,7 +322,7 @@ void parse_cpu_tree(void)
return;
do {
entry = readdir(dir);
- if (entry && strlen(entry->d_name)>3 && strstr(entry->d_name,"cpu")) {
+ if (entry && !strncmp(entry->d_name,"cpu", 3) && isdigit(entry->d_name[3])) {
char new_path[PATH_MAX];
sprintf(new_path, "/sys/devices/system/cpu/%s", entry->d_name);
do_one_cpu(new_path);
--
1.6.5.2
|