From: Heiko Carstens Date: Tue, 6 Sep 2011 00:52:55 +0000 (+0200) Subject: lscpu: allow read_cache() to be called for offline cpus X-Git-Tag: v2.21-rc1~451 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dcdead4271232c5638afdc8bc99cf792383eb27f;p=thirdparty%2Futil-linux.git 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 --- diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c index 203c64f512..1e37471ac4 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;