]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lscpu: allow read_cache() to be called for offline cpus
authorHeiko Carstens <heiko.carstens@de.ibm.com>
Tue, 6 Sep 2011 00:52:55 +0000 (02:52 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 18 Oct 2011 12:22:26 +0000 (14:22 +0200)
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>
sys-utils/lscpu.c

index 607e062f22dd44680f551bc4f165810b77a19370..dd59614a9937258ae28a827a642f2ea7d4d4ddcd 100644 (file)
@@ -712,6 +712,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;