summaryrefslogtreecommitdiffstats
path: root/sys-utils/lscpu.c
diff options
context:
space:
mode:
authorKarel Zak2015-09-01 12:37:18 +0200
committerKarel Zak2015-09-01 12:37:18 +0200
commite03b613e8d65d8e705ce5850ed05b3a156097e75 (patch)
tree4b478dbd2d704a9f37621dda7c94b774c6c34ca5 /sys-utils/lscpu.c
parenttests: (blkid) update drbdmanage (diff)
downloadkernel-qcow2-util-linux-e03b613e8d65d8e705ce5850ed05b3a156097e75.tar.gz
kernel-qcow2-util-linux-e03b613e8d65d8e705ce5850ed05b3a156097e75.tar.xz
kernel-qcow2-util-linux-e03b613e8d65d8e705ce5850ed05b3a156097e75.zip
lscpu: fix read_hypervisor_powerpc() logic
We care about /proc/device-tree/compatible content... The patch also removes unnecessary path_exist(), it seems good enough to call open() rather than access() + open(). Addresses: https://github.com/karelzak/util-linux/issues/218 Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/lscpu.c')
-rw-r--r--sys-utils/lscpu.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index 1f8f5f198..47f690d88 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -603,9 +603,8 @@ read_hypervisor_cpuid(struct lscpu_desc *desc __attribute__((__unused__)))
static int is_compatible(const char *path, const char *str)
{
- FILE *fd;
+ FILE *fd = path_fopen("r", 0, "%s", path);
- fd = path_fopen("r", 0, "%s", path);
if (fd) {
char buf[256];
size_t i, len;
@@ -636,11 +635,9 @@ read_hypervisor_powerpc(struct lscpu_desc *desc)
desc->virtype = VIRT_PARA;
/* PowerNV (POWER Non-Virtualized, bare-metal) */
- } else if (path_exist(_PATH_PROC_DEVICETREE "/compatible")) {
- if (is_compatible(_PATH_PROC_DEVICETREE "/compatible", "ibm,powernv")) {
- desc->hyper = HYPER_NONE;
- desc->virtype = VIRT_NONE;
- }
+ } else if (is_compatible(_PATH_PROC_DEVICETREE "/compatible", "ibm,powernv")) {
+ desc->hyper = HYPER_NONE;
+ desc->virtype = VIRT_NONE;
/* PowerVM (IBM's proprietary hypervisor, aka pHyp) */
} else if (path_exist(_PATH_PROC_DEVICETREE "/ibm,partition-name")
@@ -658,11 +655,9 @@ read_hypervisor_powerpc(struct lscpu_desc *desc)
}
/* Qemu */
- } else if (path_exist(_PATH_PROC_DEVICETREE "/compatible")) {
- if (is_compatible(_PATH_PROC_DEVICETREE "/compatible", "qemu,pseries")) {
- desc->hyper = HYPER_KVM;
- desc->virtype = VIRT_PARA;
- }
+ } else if (is_compatible(_PATH_PROC_DEVICETREE "/compatible", "qemu,pseries")) {
+ desc->hyper = HYPER_KVM;
+ desc->virtype = VIRT_PARA;
}
return desc->hyper;
}