diff options
author | Ruediger Meier | 2014-03-26 22:18:17 +0100 |
---|---|---|
committer | Ruediger Meier | 2014-03-27 09:11:57 +0100 |
commit | 10d927ab3ba442084283db670364045bca61dbb8 (patch) | |
tree | ec2e95e2f0633e56edd9113a4515ce5a924d2b6a /sys-utils/lscpu.c | |
parent | Merge branch 'fix-compile-color-cfdisk' of https://github.com/theonewolf/util... (diff) | |
download | kernel-qcow2-util-linux-10d927ab3ba442084283db670364045bca61dbb8.tar.gz kernel-qcow2-util-linux-10d927ab3ba442084283db670364045bca61dbb8.tar.xz kernel-qcow2-util-linux-10d927ab3ba442084283db670364045bca61dbb8.zip |
lscpu: don't abort if cache size is unknown
There are systems where the size file does not exist. Most badly even
lscpu -p would abort allthough it does not use the size:
$ lscpu -p
lscpu: error: cannot open
/sys/devices/system/cpu/cpu0/cache/index0/size: No such file or directory
This patch does not abort in this case and prints "unknown size" in
human-readable case. For examle on this qemu pcc test machine:
$ lscpu
Architecture: ppc
CPU op-mode(s): 32-bit
Byte Order: Big Endian
CPU(s): 1
On-line CPU(s) list: 0
Thread(s) per core: 1
Core(s) per socket: 1
Socket(s): 1
Model: Power Macintosh
BogoMIPS: 33.25
L1d cache: unknown size
L1i cache: unknown size
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Diffstat (limited to 'sys-utils/lscpu.c')
-rw-r--r-- | sys-utils/lscpu.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c index 4760d4e39..3e0e1cf04 100644 --- a/sys-utils/lscpu.c +++ b/sys-utils/lscpu.c @@ -897,10 +897,13 @@ read_cache(struct lscpu_desc *desc, int idx) ca->name = xstrdup(buf); /* cache size */ - path_read_str(buf, sizeof(buf), - _PATH_SYS_CPU "/cpu%d/cache/index%d/size", - num, i); - ca->size = xstrdup(buf); + if (path_exist(_PATH_SYS_CPU "/cpu%d/cache/index%d/size",num, i)) { + path_read_str(buf, sizeof(buf), + _PATH_SYS_CPU "/cpu%d/cache/index%d/size", num, i); + ca->size = xstrdup(buf); + } else { + ca->size = xstrdup("unknown size"); + } } /* information about how CPUs share different caches */ |