diff options
author | Gerrit Renker | 2010-12-28 10:53:03 +0100 |
---|---|---|
committer | Karel Zak | 2010-12-31 00:22:52 +0100 |
commit | 3d6e5c355d10dcd9d6336331c96935013ffcd3b1 (patch) | |
tree | 22e0a8e3eaf7dd9459fede7d483c415849f31629 /sys-utils/lscpu.c | |
parent | partx: fix authors section in man page (diff) | |
download | kernel-qcow2-util-linux-3d6e5c355d10dcd9d6336331c96935013ffcd3b1.tar.gz kernel-qcow2-util-linux-3d6e5c355d10dcd9d6336331c96935013ffcd3b1.tar.xz kernel-qcow2-util-linux-3d6e5c355d10dcd9d6336331c96935013ffcd3b1.zip |
lscpu: avoid len = 0 as a consequence of maxcpus = 0
This problem was observed on an x86_64 Mobile AMD Sempron 3700+ where kernel_max
returned "0" as the index of the highest CPU.
As a consequence, several variables in lscpu, which relied on maxcpus >= 1 (in
particular the 'len' value) were set to 0, resulting in the following errors:
host>./lscpu
lscpu: failed to read: /sys/devices/system/cpu/online: No such file or directory
host> cat /sys/devices/system/cpu/kernel_max
0
The fix used by this patch is to interpret kernel_max as an index and maxcpus as
a count >= 1, tested to work.
Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/lscpu.c')
-rw-r--r-- | sys-utils/lscpu.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c index ca2adb864..224d5f99b 100644 --- a/sys-utils/lscpu.c +++ b/sys-utils/lscpu.c @@ -392,7 +392,8 @@ read_basicinfo(struct lscpu_desc *desc) fclose(fp); if (path_exist(_PATH_SYS_SYSTEM "/cpu/kernel_max")) - maxcpus = path_getnum(_PATH_SYS_SYSTEM "/cpu/kernel_max"); + /* note that kernel_max is maximum index [NR_CPUS-1] */ + maxcpus = path_getnum(_PATH_SYS_SYSTEM "/cpu/kernel_max") + 1; else if (!sysrootlen) /* the root is '/' so we are working with data from the current kernel */ |