summaryrefslogtreecommitdiffstats
path: root/sys-utils/lscpu.c
diff options
context:
space:
mode:
authorHeiko Carstens2011-09-06 02:52:55 +0200
committerKarel Zak2011-09-09 06:30:06 +0200
commitdcdead4271232c5638afdc8bc99cf792383eb27f (patch)
tree8879dc7fb9fb3c313fdd56b34238b47fa8cdbc38 /sys-utils/lscpu.c
parentlscpu: simplify cache column output function (diff)
downloadkernel-qcow2-util-linux-dcdead4271232c5638afdc8bc99cf792383eb27f.tar.gz
kernel-qcow2-util-linux-dcdead4271232c5638afdc8bc99cf792383eb27f.tar.xz
kernel-qcow2-util-linux-dcdead4271232c5638afdc8bc99cf792383eb27f.zip
lscpu: allow read_cache() to be called for offline cpus
First check path before accessing files to be sure they actually exist. This is necessary when also informations for offline CPUs will be printed. Since we do not necessarily know if "cpu is offline" means the same as "path does not exist" just check for it. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Diffstat (limited to 'sys-utils/lscpu.c')
-rw-r--r--sys-utils/lscpu.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index 203c64f51..1e37471ac 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -804,6 +804,9 @@ read_cache(struct lscpu_desc *desc, int num)
struct cpu_cache *ca = &desc->caches[i];
cpu_set_t *map;
+ if (!path_exist(_PATH_SYS_SYSTEM "/cpu/cpu%d/cache/index%d",
+ num, i))
+ continue;
if (!ca->name) {
int type, level;