]> git.ipfire.org Git - thirdparty/util-linux.git/blobdiff - sys-utils/lscpu.c
libblkid: do not interpret NTFS as MBR
[thirdparty/util-linux.git] / sys-utils / lscpu.c
index 08e5df5bcee3bb43043d88a6c733088383caf03c..4f1ab47e90380ad58ca56fd6a6fea57e43807f0e 100644 (file)
@@ -33,6 +33,7 @@
 #include <stdarg.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/personality.h>
 
 #if (defined(__x86_64__) || defined(__i386__))
 # if !defined( __SANITIZE_ADDRESS__)
 
 #include "closestream.h"
 #include "optutils.h"
+#include "fileutils.h"
 
 #include "lscpu.h"
-#include "lscpu-arm.h"
 
 #define CACHE_MAX 100
 
 /* /sys paths */
 #define _PATH_SYS_SYSTEM       "/sys/devices/system"
-#define _PATH_SYS_HYP_FEATURES "/sys/hypervisor/properties/features"
+#define _PATH_SYS_HYP_FEATURES "/sys/hypervisor/properties/features"
 #define _PATH_SYS_CPU          _PATH_SYS_SYSTEM "/cpu"
 #define _PATH_SYS_NODE         _PATH_SYS_SYSTEM "/node"
-#define _PATH_PROC_XEN         "/proc/xen"
-#define _PATH_PROC_XENCAP      _PATH_PROC_XEN "/capabilities"
-#define _PATH_PROC_CPUINFO     "/proc/cpuinfo"
-#define _PATH_PROC_PCIDEVS     "/proc/bus/pci/devices"
-#define _PATH_PROC_SYSINFO     "/proc/sysinfo"
-#define _PATH_PROC_STATUS      "/proc/self/status"
-#define _PATH_PROC_VZ  "/proc/vz"
-#define _PATH_PROC_BC  "/proc/bc"
-#define _PATH_PROC_DEVICETREE  "/proc/device-tree"
-#define _PATH_DEV_MEM          "/dev/mem"
-#define _PATH_PROC_OSRELEASE   "/proc/sys/kernel/osrelease"
 
 /* Xen Domain feature flag used for /sys/hypervisor/properties/features */
 #define XENFEAT_supervisor_mode_kernel         3
@@ -166,54 +156,103 @@ static int maxcpus;              /* size in bits of kernel cpu mask */
  * IDs
  */
 enum {
-       COL_CPU,
-       COL_CORE,
-       COL_SOCKET,
-       COL_NODE,
-       COL_BOOK,
-       COL_DRAWER,
-       COL_CACHE,
-       COL_POLARIZATION,
-       COL_ADDRESS,
-       COL_CONFIGURED,
-       COL_ONLINE,
-       COL_MAXMHZ,
-       COL_MINMHZ,
+       COL_CPU_CPU,
+       COL_CPU_CORE,
+       COL_CPU_SOCKET,
+       COL_CPU_NODE,
+       COL_CPU_BOOK,
+       COL_CPU_DRAWER,
+       COL_CPU_CACHE,
+       COL_CPU_POLARIZATION,
+       COL_CPU_ADDRESS,
+       COL_CPU_CONFIGURED,
+       COL_CPU_ONLINE,
+       COL_CPU_MAXMHZ,
+       COL_CPU_MINMHZ,
 };
 
+enum {
+       COL_CACHE_ALLSIZE,
+       COL_CACHE_LEVEL,
+       COL_CACHE_NAME,
+       COL_CACHE_ONESIZE,
+       COL_CACHE_TYPE,
+       COL_CACHE_WAYS,
+       COL_CACHE_ALLOCPOL,
+       COL_CACHE_WRITEPOL,
+       COL_CACHE_PHYLINE,
+       COL_CACHE_SETS,
+       COL_CACHE_COHERENCYSIZE
+};
+
+
 /* column description
  */
 struct lscpu_coldesc {
        const char *name;
        const char *help;
 
+       int flags;
        unsigned int  is_abbr:1;        /* name is abbreviation */
 };
 
-static struct lscpu_coldesc coldescs[] =
+static struct lscpu_coldesc coldescs_cpu[] =
+{
+       [COL_CPU_CPU]          = { "CPU", N_("logical CPU number"), SCOLS_FL_RIGHT, 1 },
+       [COL_CPU_CORE]         = { "CORE", N_("logical core number"), SCOLS_FL_RIGHT },
+       [COL_CPU_SOCKET]       = { "SOCKET", N_("logical socket number"), SCOLS_FL_RIGHT },
+       [COL_CPU_NODE]         = { "NODE", N_("logical NUMA node number"), SCOLS_FL_RIGHT },
+       [COL_CPU_BOOK]         = { "BOOK", N_("logical book number"), SCOLS_FL_RIGHT },
+       [COL_CPU_DRAWER]       = { "DRAWER", N_("logical drawer number"), SCOLS_FL_RIGHT },
+       [COL_CPU_CACHE]        = { "CACHE", N_("shows how caches are shared between CPUs") },
+       [COL_CPU_POLARIZATION] = { "POLARIZATION", N_("CPU dispatching mode on virtual hardware") },
+       [COL_CPU_ADDRESS]      = { "ADDRESS", N_("physical address of a CPU") },
+       [COL_CPU_CONFIGURED]   = { "CONFIGURED", N_("shows if the hypervisor has allocated the CPU") },
+       [COL_CPU_ONLINE]       = { "ONLINE", N_("shows if Linux currently makes use of the CPU"), SCOLS_FL_RIGHT },
+       [COL_CPU_MAXMHZ]       = { "MAXMHZ", N_("shows the maximum MHz of the CPU"), SCOLS_FL_RIGHT },
+       [COL_CPU_MINMHZ]       = { "MINMHZ", N_("shows the minimum MHz of the CPU"), SCOLS_FL_RIGHT }
+};
+
+static struct lscpu_coldesc coldescs_cache[] =
 {
-       [COL_CPU]          = { "CPU", N_("logical CPU number"), 1 },
-       [COL_CORE]         = { "CORE", N_("logical core number") },
-       [COL_SOCKET]       = { "SOCKET", N_("logical socket number") },
-       [COL_NODE]         = { "NODE", N_("logical NUMA node number") },
-       [COL_BOOK]         = { "BOOK", N_("logical book number") },
-       [COL_DRAWER]       = { "DRAWER", N_("logical drawer number") },
-       [COL_CACHE]        = { "CACHE", N_("shows how caches are shared between CPUs") },
-       [COL_POLARIZATION] = { "POLARIZATION", N_("CPU dispatching mode on virtual hardware") },
-       [COL_ADDRESS]      = { "ADDRESS", N_("physical address of a CPU") },
-       [COL_CONFIGURED]   = { "CONFIGURED", N_("shows if the hypervisor has allocated the CPU") },
-       [COL_ONLINE]       = { "ONLINE", N_("shows if Linux currently makes use of the CPU") },
-       [COL_MAXMHZ]       = { "MAXMHZ", N_("shows the maximum MHz of the CPU") },
-       [COL_MINMHZ]       = { "MINMHZ", N_("shows the minimum MHz of the CPU") }
+       [COL_CACHE_ALLSIZE]    = { "ALL-SIZE", N_("size of all system caches"), SCOLS_FL_RIGHT },
+       [COL_CACHE_LEVEL]      = { "LEVEL", N_("cache level"), SCOLS_FL_RIGHT },
+       [COL_CACHE_NAME]       = { "NAME", N_("cache name") },
+       [COL_CACHE_ONESIZE]    = { "ONE-SIZE", N_("size of one cache"), SCOLS_FL_RIGHT },
+       [COL_CACHE_TYPE]       = { "TYPE", N_("cache type") },
+       [COL_CACHE_WAYS]       = { "WAYS", N_("ways of associativity"), SCOLS_FL_RIGHT },
+       [COL_CACHE_ALLOCPOL]   = { "ALLOC-POLICY", N_("allocation policy") },
+       [COL_CACHE_WRITEPOL]   = { "WRITE-POLICY", N_("write policy") },
+       [COL_CACHE_PHYLINE]    = { "PHY-LINE", N_("number of physical cache line per cache t"), SCOLS_FL_RIGHT },
+       [COL_CACHE_SETS]       = { "SETS", N_("number of sets in the cache; set lines has the same cache index"), SCOLS_FL_RIGHT },
+       [COL_CACHE_COHERENCYSIZE] = { "COHERENCY-SIZE", N_("minimum amount of data in bytes transferred from memory to cache"), SCOLS_FL_RIGHT }
 };
 
+
+static int get_cache_full_size(struct lscpu_desc *desc, struct cpu_cache *ca, uint64_t *res);
+
+static int
+cpu_column_name_to_id(const char *name, size_t namesz)
+{
+       size_t i;
+
+       for (i = 0; i < ARRAY_SIZE(coldescs_cpu); i++) {
+               const char *cn = coldescs_cpu[i].name;
+
+               if (!strncasecmp(name, cn, namesz) && !*(cn + namesz))
+                       return i;
+       }
+       warnx(_("unknown column: %s"), name);
+       return -1;
+}
+
 static int
-column_name_to_id(const char *name, size_t namesz)
+cache_column_name_to_id(const char *name, size_t namesz)
 {
        size_t i;
 
-       for (i = 0; i < ARRAY_SIZE(coldescs); i++) {
-               const char *cn = coldescs[i].name;
+       for (i = 0; i < ARRAY_SIZE(coldescs_cache); i++) {
+               const char *cn = coldescs_cache[i].name;
 
                if (!strncasecmp(name, cn, namesz) && !*(cn + namesz))
                        return i;
@@ -303,8 +342,10 @@ lookup_cache(char *line, struct lscpu_desc *desc)
        type = 0;
        if (strncmp(p, "Data", 4) == 0)
                type = 'd';
-       if (strncmp(p, "Instruction", 11) == 0)
+       else if (strncmp(p, "Instruction", 11) == 0)
                type = 'i';
+       else if (strncmp(p, "Unified", 7) == 0)
+               type = 'u';
        p = strstr(line, "size=");
        if (!p || sscanf(p, "size=%lld", &size) != 1)
               return 0;
@@ -314,11 +355,18 @@ lookup_cache(char *line, struct lscpu_desc *desc)
                                 desc->necaches * sizeof(struct cpu_cache));
        cache = &desc->ecaches[desc->necaches - 1];
        memset(cache, 0 , sizeof(*cache));
-       if (type)
+
+       if (type == 'i' || type == 'd')
                xasprintf(&cache->name, "L%d%c", level, type);
        else
                xasprintf(&cache->name, "L%d", level);
-       xasprintf(&cache->size, "%lldK", size);
+
+       cache->level = level;
+       cache->size = size * 1024;
+
+       cache->type = type == 'i' ? xstrdup("Instruction") :
+                     type == 'd' ? xstrdup("Data") :
+                     type == 'u' ? xstrdup("Unified") : NULL;
        return 1;
 }
 
@@ -344,6 +392,19 @@ init_mode(struct lscpu_modifier *mod)
     defined(__s390x__) || defined(__s390__) || defined(__sparc_v9__)
        m |= MODE_32BIT;
 #endif
+
+#if defined(__aarch64__)
+       {
+               /* personality() is the most reliable way (since 4.7)
+                * to determine aarch32 support */
+               int pers = personality(PER_LINUX32);
+               if (pers != -1) {
+                       personality(pers);
+                       m |= MODE_32BIT;
+               }
+               m |= MODE_64BIT;
+       }
+#endif
        return m;
 }
 
@@ -386,59 +447,84 @@ static void read_physical_info_powerpc(
 }
 #endif
 
-static void
-arm_cpu_decode(struct lscpu_desc *desc)
+static int cmp_vulnerability_name(const void *a0, const void *b0)
 {
-       int j, impl, part;
-       const struct id_part *parts = NULL;
-       char buf[8];
-       if (desc->vendor == NULL || desc->model == NULL)
-               return;
-       if ((strncmp(desc->vendor,"0x",2) ||
-                strncmp(desc->model,"0x",2) ))
+       const struct cpu_vulnerability *a = (const struct cpu_vulnerability *) a0,
+                                      *b = (const struct cpu_vulnerability *) b0;
+       return strcmp(a->name, b->name);
+}
+
+static void read_vulnerabilities(struct lscpu_desc *desc)
+{
+       struct dirent *d;
+       DIR *dir = ul_path_opendir(desc->syscpu, "vulnerabilities");
+       int n = 0;
+
+       if (!dir)
                return;
 
-       impl=(int)strtol(desc->vendor, NULL, 0);
-       part=(int)strtol(desc->model, NULL, 0);
+       desc->nvuls = n = 0;
 
-       for (j = 0; hw_implementer[j].id != -1; j++) {
-       if (hw_implementer[j].id == impl) {
-               parts = hw_implementer[j].parts;
-               desc->vendor = (char *)hw_implementer[j].name;
-               break;
-               }
-       }
-       if ( parts == NULL)
+       while (xreaddir(dir))
+               n++;
+       if (!n)
                return;
 
-       for (j = 0; parts[j].id != -1; j++) {
-       if (parts[j].id == part) {
-               desc->modelname = (char *)parts[j].name;
-               break;
+       rewinddir(dir);
+       desc->vuls = xcalloc(n, sizeof(struct cpu_vulnerability));
+
+       while (desc->nvuls < n && (d = xreaddir(dir))) {
+               char *str, *p;
+               struct cpu_vulnerability *vu;
+
+#ifdef _DIRENT_HAVE_D_TYPE
+               if (d->d_type == DT_DIR || d->d_type == DT_UNKNOWN)
+                       continue;
+#endif
+               if (ul_path_readf_string(desc->syscpu, &str,
+                                       "vulnerabilities/%s", d->d_name) <= 0)
+                       continue;
+
+               vu = &desc->vuls[desc->nvuls++];
+
+               /* Name */
+               vu->name = xstrdup(d->d_name);
+               *vu->name = toupper(*vu->name);
+               strrep(vu->name, '_', ' ');
+
+               /* Description */
+               vu->text = str;
+               p = (char *) startswith(vu->text, "Mitigation");
+               if (p) {
+                       *p = ';';
+                       strrem(vu->text, ':');
                }
        }
+       closedir(dir);
 
-       /* Print out the rXpY string for ARM cores */
-       if (impl == 0x41 && desc->revision != NULL &&
-               desc->stepping != NULL) {
-               int revision = atoi(desc->revision);
-               int variant = (int)strtol(desc->stepping, NULL, 0);
-               snprintf(buf, sizeof(buf), "r%dp%d", variant, revision );
-               desc->stepping=xstrdup(buf);
-       }
+       qsort(desc->vuls, desc->nvuls,
+             sizeof(struct cpu_vulnerability), cmp_vulnerability_name);
 }
 
+
+
+
 static void
 read_basicinfo(struct lscpu_desc *desc, struct lscpu_modifier *mod)
 {
-       FILE *fp = path_fopen("r", 1, _PATH_PROC_CPUINFO);
+       FILE *fp;
        char buf[BUFSIZ];
        struct utsname utsbuf;
        size_t setsize;
+       cpu_set_t *cpuset = NULL;
 
        /* architecture */
        if (uname(&utsbuf) == -1)
                err(EXIT_FAILURE, _("error: uname failed"));
+
+       fp = ul_path_fopen(desc->procfs, "r", "cpuinfo");
+       if (!fp)
+               err(EXIT_FAILURE, _("cannot open %s"), "/proc/cpuinfo");
        desc->arch = xstrdup(utsbuf.machine);
 
        /* details */
@@ -467,6 +553,7 @@ read_basicinfo(struct lscpu_desc *desc, struct lscpu_modifier *mod)
                else if (lookup(buf, "revision", &desc->revision)) ;
                else if (lookup(buf, "CPU revision", &desc->revision)) ; /* aarch64 */
                else if (lookup(buf, "max thread id", &desc->mtid)) ; /* s390 */
+               else if (lookup(buf, "address sizes", &desc->addrsz)) ; /* x86 */
                else if (lookup_cache(buf, desc)) ;
                else
                        continue;
@@ -497,9 +584,9 @@ read_basicinfo(struct lscpu_desc *desc, struct lscpu_modifier *mod)
 
        fclose(fp);
 
-       if (path_exist(_PATH_SYS_CPU "/kernel_max"))
+       if (ul_path_read_s32(desc->syscpu, &maxcpus, "kernel_max") == 0)
                /* note that kernel_max is maximum index [NR_CPUS-1] */
-               maxcpus = path_read_s32(_PATH_SYS_CPU "/kernel_max") + 1;
+               maxcpus += 1;
 
        else if (mod->system == SYSTEM_LIVE)
                /* the root is '/' so we are working with data from the current kernel */
@@ -512,59 +599,63 @@ read_basicinfo(struct lscpu_desc *desc, struct lscpu_modifier *mod)
 
        setsize = CPU_ALLOC_SIZE(maxcpus);
 
-       if (path_exist(_PATH_SYS_CPU "/possible")) {
-               cpu_set_t *tmp = path_read_cpulist(maxcpus, _PATH_SYS_CPU "/possible");
+       if (ul_path_readf_cpulist(desc->syscpu, &cpuset, maxcpus, "possible") == 0) {
                int num, idx;
 
-               desc->ncpuspos = CPU_COUNT_S(setsize, tmp);
+               desc->ncpuspos = CPU_COUNT_S(setsize, cpuset);
                desc->idx2cpunum = xcalloc(desc->ncpuspos, sizeof(int));
 
                for (num = 0, idx = 0; num < maxcpus; num++) {
-                       if (CPU_ISSET(num, tmp))
+                       if (CPU_ISSET_S(num, setsize, cpuset))
                                desc->idx2cpunum[idx++] = num;
                }
-               cpuset_free(tmp);
+               cpuset_free(cpuset);
+               cpuset = NULL;
        } else
                err(EXIT_FAILURE, _("failed to determine number of CPUs: %s"),
                                _PATH_SYS_CPU "/possible");
 
 
        /* get mask for present CPUs */
-       if (path_exist(_PATH_SYS_CPU "/present")) {
-               desc->present = path_read_cpulist(maxcpus, _PATH_SYS_CPU "/present");
+       if (ul_path_readf_cpulist(desc->syscpu, &desc->present, maxcpus, "present") == 0)
                desc->ncpus = CPU_COUNT_S(setsize, desc->present);
-       }
 
        /* get mask for online CPUs */
-       if (path_exist(_PATH_SYS_CPU "/online")) {
-               desc->online = path_read_cpulist(maxcpus, _PATH_SYS_CPU "/online");
+       if (ul_path_readf_cpulist(desc->syscpu, &desc->online, maxcpus, "online") == 0)
                desc->nthreads = CPU_COUNT_S(setsize, desc->online);
-       }
 
        /* get dispatching mode */
-       if (path_exist(_PATH_SYS_CPU "/dispatching"))
-               desc->dispatching = path_read_s32(_PATH_SYS_CPU "/dispatching");
-       else
+       if (ul_path_read_s32(desc->syscpu, &desc->dispatching, "dispatching") != 0)
                desc->dispatching = -1;
 
+       /* get cpufreq boost mode */
+       if (ul_path_read_s32(desc->syscpu, &desc->freqboost, "cpufreq/boost") != 0)
+               desc->freqboost = -1;
+
        if (mod->system == SYSTEM_LIVE)
                read_physical_info_powerpc(desc);
 
-       if ((fp = path_fopen("r", 0, _PATH_PROC_SYSINFO))) {
-               while (fgets(buf, sizeof(buf), fp) != NULL && !desc->machinetype)
-                       lookup(buf, "Type", &desc->machinetype);
+       if ((fp = ul_path_fopen(desc->procfs, "r", "sysinfo"))) {
+               while (fgets(buf, sizeof(buf), fp) != NULL) {
+                       if (lookup(buf, "Type", &desc->machinetype))
+                               break;
+               }
                fclose(fp);
        }
+
+       /* vulnerabilities */
+       if (ul_path_access(desc->syscpu, F_OK, "vulnerabilities") == 0)
+               read_vulnerabilities(desc);
 }
 
 static int
-has_pci_device(unsigned int vendor, unsigned int device)
+has_pci_device(struct lscpu_desc *desc, unsigned int vendor, unsigned int device)
 {
        FILE *f;
        unsigned int num, fn, ven, dev;
        int res = 1;
 
-       f = path_fopen("r", 0, _PATH_PROC_PCIDEVS);
+       f = ul_path_fopen(desc->procfs, "r", "bus/pci/devices");
        if (!f)
                return 0;
 
@@ -650,9 +741,9 @@ read_hypervisor_cpuid(struct lscpu_desc *desc __attribute__((__unused__)))
 }
 #endif
 
-static int is_compatible(const char *path, const char *str)
+static int is_devtree_compatible(struct lscpu_desc *desc, const char *str)
 {
-       FILE *fd = path_fopen("r", 0, "%s", path);
+       FILE *fd = ul_path_fopen(desc->procfs, "r", "device-tree/compatible");
 
        if (fd) {
                char buf[256];
@@ -679,23 +770,25 @@ read_hypervisor_powerpc(struct lscpu_desc *desc)
        assert(!desc->hyper);
 
         /* IBM iSeries: legacy, para-virtualized on top of OS/400 */
-       if (path_exist("/proc/iSeries")) {
+       if (ul_path_access(desc->procfs, F_OK, "iSeries") == 0) {
                desc->hyper = HYPER_OS400;
                desc->virtype = VIRT_PARA;
 
        /* PowerNV (POWER Non-Virtualized, bare-metal) */
-       } else if (is_compatible(_PATH_PROC_DEVICETREE "/compatible", "ibm,powernv")) {
+       } else if (is_devtree_compatible(desc, "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")
-                  && path_exist(_PATH_PROC_DEVICETREE "/hmc-managed?")
-                  && !path_exist(_PATH_PROC_DEVICETREE "/chosen/qemu,graphic-width")) {
+       } else if (ul_path_access(desc->procfs, F_OK, "device-tree/ibm,partition-name") == 0
+                  && ul_path_access(desc->procfs, F_OK, "device-tree/hmc-managed?") == 0
+                  && ul_path_access(desc->procfs, F_OK, "device-tree/chosen/qemu,graphic-width") != 0) {
+
                FILE *fd;
                desc->hyper = HYPER_PHYP;
                desc->virtype = VIRT_PARA;
-               fd = path_fopen("r", 0, _PATH_PROC_DEVICETREE "/ibm,partition-name");
+
+               fd = ul_path_fopen(desc->procfs, "r", "device-tree/ibm,partition-name");
                if (fd) {
                        char buf[256];
                        if (fscanf(fd, "%255s", buf) == 1 && !strcmp(buf, "full"))
@@ -704,7 +797,7 @@ read_hypervisor_powerpc(struct lscpu_desc *desc)
                }
 
        /* Qemu */
-       } else if (is_compatible(_PATH_PROC_DEVICETREE "/compatible", "qemu,pseries")) {
+       } else if (is_devtree_compatible(desc, "qemu,pseries")) {
                desc->hyper = HYPER_KVM;
                desc->virtype = VIRT_PARA;
        }
@@ -809,7 +902,7 @@ read_hypervisor(struct lscpu_desc *desc, struct lscpu_modifier *mod)
 
        /* We have to detect WSL first. is_vmware_platform() crashes on Windows 10. */
 
-       if ((fd = path_fopen("r", 0, _PATH_PROC_OSRELEASE))) {
+       if ((fd = ul_path_fopen(desc->procfs, "r", "sys/kernel/osrelease"))) {
                char buf[256];
 
                if (fgets(buf, sizeof(buf), fd) != NULL) {
@@ -837,7 +930,8 @@ read_hypervisor(struct lscpu_desc *desc, struct lscpu_modifier *mod)
                if (desc->hyper == HYPER_XEN) {
                        uint32_t features;
 
-                       fd = path_fopen("r", 0, _PATH_SYS_HYP_FEATURES);
+                       fd = ul_prefix_fopen(desc->prefix, "r", _PATH_SYS_HYP_FEATURES);
+
                        if (fd && fscanf(fd, "%x", &features) == 1) {
                                /* Xen PV domain */
                                if (features & XEN_FEATURES_PV_MASK)
@@ -846,16 +940,17 @@ read_hypervisor(struct lscpu_desc *desc, struct lscpu_modifier *mod)
                                else if ((features & XEN_FEATURES_PVH_MASK)
                                                                == XEN_FEATURES_PVH_MASK)
                                        desc->virtype = VIRT_PARA;
-                               fclose(fd);
                        }
+                       if (fd)
+                               fclose(fd);
                }
        } else if (read_hypervisor_powerpc(desc) > 0) {}
 
        /* Xen para-virt or dom0 */
-       else if (path_exist(_PATH_PROC_XEN)) {
+       else if (ul_path_access(desc->procfs, F_OK, "xen") == 0) {
                int dom0 = 0;
-               fd = path_fopen("r", 0, _PATH_PROC_XENCAP);
 
+               fd = ul_path_fopen(desc->procfs, "r", "xen/capabilities");
                if (fd) {
                        char buf[256];
 
@@ -868,25 +963,25 @@ read_hypervisor(struct lscpu_desc *desc, struct lscpu_modifier *mod)
                desc->hyper = HYPER_XEN;
 
        /* Xen full-virt on non-x86_64 */
-       } else if (has_pci_device( hv_vendor_pci[HYPER_XEN], hv_graphics_pci[HYPER_XEN])) {
+       } else if (has_pci_device(desc, hv_vendor_pci[HYPER_XEN], hv_graphics_pci[HYPER_XEN])) {
                desc->hyper = HYPER_XEN;
                desc->virtype = VIRT_FULL;
-       } else if (has_pci_device( hv_vendor_pci[HYPER_VMWARE], hv_graphics_pci[HYPER_VMWARE])) {
+       } else if (has_pci_device(desc, hv_vendor_pci[HYPER_VMWARE], hv_graphics_pci[HYPER_VMWARE])) {
                desc->hyper = HYPER_VMWARE;
                desc->virtype = VIRT_FULL;
-       } else if (has_pci_device( hv_vendor_pci[HYPER_VBOX], hv_graphics_pci[HYPER_VBOX])) {
+       } else if (has_pci_device(desc, hv_vendor_pci[HYPER_VBOX], hv_graphics_pci[HYPER_VBOX])) {
                desc->hyper = HYPER_VBOX;
                desc->virtype = VIRT_FULL;
 
        /* IBM PR/SM */
-       } else if ((fd = path_fopen("r", 0, _PATH_PROC_SYSINFO))) {
+       } else if ((fd = ul_path_fopen(desc->procfs, "r", "sysinfo"))) {
                char buf[BUFSIZ];
 
                desc->hyper = HYPER_IBM;
                desc->hypervisor = "PR/SM";
                desc->virtype = VIRT_FULL;
                while (fgets(buf, sizeof(buf), fd) != NULL) {
-                       char *str;
+                       char *str, *p;
 
                        if (!strstr(buf, "Control Program:"))
                                continue;
@@ -894,10 +989,10 @@ read_hypervisor(struct lscpu_desc *desc, struct lscpu_modifier *mod)
                                desc->hyper = HYPER_IBM;
                        else
                                desc->hyper = HYPER_KVM;
-                       str = strchr(buf, ':');
-                       if (!str)
+                       p = strchr(buf, ':');
+                       if (!p)
                                continue;
-                       xasprintf(&str, "%s", str + 1);
+                       xasprintf(&str, "%s", p + 1);
 
                        /* remove leading, trailing and repeating whitespace */
                        while (*str == ' ')
@@ -908,13 +1003,15 @@ read_hypervisor(struct lscpu_desc *desc, struct lscpu_modifier *mod)
                                *(str--) = '\0';
                        while ((str = strstr(desc->hypervisor, "  ")))
                                memmove(str, str + 1, strlen(str));
+                       break;
                }
                fclose(fd);
        }
 
        /* OpenVZ/Virtuozzo - /proc/vz dir should exist
         *                    /proc/bc should not */
-       else if (path_exist(_PATH_PROC_VZ) && !path_exist(_PATH_PROC_BC)) {
+       else if (ul_path_access(desc->procfs, F_OK, "vz") == 0 &&
+                ul_path_access(desc->procfs, F_OK, "bc") != 0) {
                desc->hyper = HYPER_PARALLELS;
                desc->virtype = VIRT_CONT;
 
@@ -931,7 +1028,7 @@ read_hypervisor(struct lscpu_desc *desc, struct lscpu_modifier *mod)
                desc->virtype = VIRT_PARA;
 
        /* Linux-VServer */
-       } else if ((fd = path_fopen("r", 0, _PATH_PROC_STATUS))) {
+       } else if ((fd = ul_path_fopen(desc->procfs, "r", "self/status"))) {
                char buf[BUFSIZ];
                char *val = NULL;
 
@@ -985,37 +1082,29 @@ read_topology(struct lscpu_desc *desc, int idx)
        int coreid, socketid, bookid, drawerid;
        int i, num = real_cpu_num(desc, idx);
 
-       if (!path_exist(_PATH_SYS_CPU "/cpu%d/topology/thread_siblings", num))
+       if (ul_path_accessf(desc->syscpu, F_OK, "cpu%d/topology/thread_siblings", num) != 0)
                return;
 
-       thread_siblings = path_read_cpuset(maxcpus, _PATH_SYS_CPU
-                                       "/cpu%d/topology/thread_siblings", num);
-       core_siblings = path_read_cpuset(maxcpus, _PATH_SYS_CPU
-                                       "/cpu%d/topology/core_siblings", num);
-       book_siblings = NULL;
-       if (path_exist(_PATH_SYS_CPU "/cpu%d/topology/book_siblings", num))
-               book_siblings = path_read_cpuset(maxcpus, _PATH_SYS_CPU
-                                           "/cpu%d/topology/book_siblings", num);
-       drawer_siblings = NULL;
-       if (path_exist(_PATH_SYS_CPU "/cpu%d/topology/drawer_siblings", num))
-               drawer_siblings = path_read_cpuset(maxcpus, _PATH_SYS_CPU
-                                           "/cpu%d/topology/drawer_siblings", num);
-       coreid = -1;
-       if (path_exist(_PATH_SYS_CPU "/cpu%d/topology/core_id", num))
-               coreid = path_read_s32(_PATH_SYS_CPU
-                                      "/cpu%d/topology/core_id", num);
-       socketid = -1;
-       if (path_exist(_PATH_SYS_CPU "/cpu%d/topology/physical_package_id", num))
-               socketid = path_read_s32(_PATH_SYS_CPU
-                                      "/cpu%d/topology/physical_package_id", num);
-       bookid = -1;
-       if (path_exist(_PATH_SYS_CPU "/cpu%d/topology/book_id", num))
-               bookid = path_read_s32(_PATH_SYS_CPU
-                                      "/cpu%d/topology/book_id", num);
-       drawerid = -1;
-       if (path_exist(_PATH_SYS_CPU "/cpu%d/topology/drawer_id", num))
-               drawerid = path_read_s32(_PATH_SYS_CPU
-                                      "/cpu%d/topology/drawer_id", num);
+       ul_path_readf_cpuset(desc->syscpu, &thread_siblings, maxcpus,
+                                       "cpu%d/topology/thread_siblings", num);
+       ul_path_readf_cpuset(desc->syscpu, &core_siblings, maxcpus,
+                                       "cpu%d/topology/core_siblings", num);
+       ul_path_readf_cpuset(desc->syscpu, &book_siblings, maxcpus,
+                                       "cpu%d/topology/book_siblings", num);
+       ul_path_readf_cpuset(desc->syscpu, &drawer_siblings, maxcpus,
+                                       "cpu%d/topology/drawer_siblings", num);
+
+       if (ul_path_readf_s32(desc->syscpu, &coreid, "cpu%d/topology/core_id", num) != 0)
+               coreid = -1;
+
+       if (ul_path_readf_s32(desc->syscpu, &socketid, "cpu%d/topology/physical_package_id", num) != 0)
+               socketid = -1;
+
+       if (ul_path_readf_s32(desc->syscpu, &bookid, "cpu%d/topology/book_id", num) != 0)
+               bookid = -1;
+
+       if (ul_path_readf_s32(desc->syscpu, &drawerid, "cpu%d/topology/drawer_id", num) != 0)
+               drawerid = -1;
 
        if (!desc->coremaps) {
                int ndrawers, nbooks, nsockets, ncores, nthreads;
@@ -1104,11 +1193,13 @@ read_polarization(struct lscpu_desc *desc, int idx)
 
        if (desc->dispatching < 0)
                return;
-       if (!path_exist(_PATH_SYS_CPU "/cpu%d/polarization", num))
+       if (ul_path_accessf(desc->syscpu, F_OK, "cpu%d/polarization", num) != 0)
                return;
        if (!desc->polarization)
                desc->polarization = xcalloc(desc->ncpuspos, sizeof(int));
-       path_read_str(mode, sizeof(mode), _PATH_SYS_CPU "/cpu%d/polarization", num);
+
+       ul_path_readf_buffer(desc->syscpu, mode, sizeof(mode), "cpu%d/polarization", num);
+
        if (strncmp(mode, "vertical:low", sizeof(mode)) == 0)
                desc->polarization[idx] = POLAR_VLOW;
        else if (strncmp(mode, "vertical:medium", sizeof(mode)) == 0)
@@ -1126,11 +1217,11 @@ read_address(struct lscpu_desc *desc, int idx)
 {
        int num = real_cpu_num(desc, idx);
 
-       if (!path_exist(_PATH_SYS_CPU "/cpu%d/address", num))
+       if (ul_path_accessf(desc->syscpu, F_OK, "cpu%d/address", num) != 0)
                return;
        if (!desc->addresses)
                desc->addresses = xcalloc(desc->ncpuspos, sizeof(int));
-       desc->addresses[idx] = path_read_s32(_PATH_SYS_CPU "/cpu%d/address", num);
+       ul_path_readf_s32(desc->syscpu, &desc->addresses[idx], "cpu%d/address", num);
 }
 
 static void
@@ -1138,11 +1229,11 @@ read_configured(struct lscpu_desc *desc, int idx)
 {
        int num = real_cpu_num(desc, idx);
 
-       if (!path_exist(_PATH_SYS_CPU "/cpu%d/configure", num))
+       if (ul_path_accessf(desc->syscpu, F_OK, "cpu%d/configure", num) != 0)
                return;
        if (!desc->configured)
                desc->configured = xcalloc(desc->ncpuspos, sizeof(int));
-       desc->configured[idx] = path_read_s32(_PATH_SYS_CPU "/cpu%d/configure", num);
+       ul_path_readf_s32(desc->syscpu, &desc->configured[idx], "cpu%d/configure", num);
 }
 
 /* Read overall maximum frequency of cpu */
@@ -1150,11 +1241,12 @@ static char *
 cpu_max_mhz(struct lscpu_desc *desc, char *buf, size_t bufsz)
 {
        int i;
-       float cpu_freq = atof(desc->maxmhz[0]);
+       float cpu_freq = 0.0;
+       size_t setsize = CPU_ALLOC_SIZE(maxcpus);
 
        if (desc->present) {
-               for (i = 1; i < desc->ncpuspos; i++) {
-                       if (CPU_ISSET(real_cpu_num(desc, i), desc->present)
+               for (i = 0; i < desc->ncpuspos; i++) {
+                       if (CPU_ISSET_S(real_cpu_num(desc, i), setsize, desc->present)
                            && desc->maxmhz[i]) {
                                float freq = atof(desc->maxmhz[i]);
 
@@ -1171,16 +1263,17 @@ cpu_max_mhz(struct lscpu_desc *desc, char *buf, size_t bufsz)
 static char *
 cpu_min_mhz(struct lscpu_desc *desc, char *buf, size_t bufsz)
 {
-        int i;
-        float cpu_freq = atof(desc->minmhz[0]);
+       int i;
+       float cpu_freq = -1.0;
+       size_t setsize = CPU_ALLOC_SIZE(maxcpus);
 
        if (desc->present) {
-               for (i = 1; i < desc->ncpuspos; i++) {
-                       if (CPU_ISSET(real_cpu_num(desc, i), desc->present)
+               for (i = 0; i < desc->ncpuspos; i++) {
+                       if (CPU_ISSET_S(real_cpu_num(desc, i), setsize, desc->present)
                            && desc->minmhz[i]) {
                                float freq = atof(desc->minmhz[i]);
 
-                               if (freq < cpu_freq)
+                               if (cpu_freq < 0.0 || freq < cpu_freq)
                                        cpu_freq = freq;
                        }
                }
@@ -1194,28 +1287,26 @@ static void
 read_max_mhz(struct lscpu_desc *desc, int idx)
 {
        int num = real_cpu_num(desc, idx);
+       int mhz;
 
-       if (!path_exist(_PATH_SYS_CPU "/cpu%d/cpufreq/cpuinfo_max_freq", num))
+       if (ul_path_readf_s32(desc->syscpu, &mhz, "cpu%d/cpufreq/cpuinfo_max_freq", num) != 0)
                return;
        if (!desc->maxmhz)
                desc->maxmhz = xcalloc(desc->ncpuspos, sizeof(char *));
-       xasprintf(&(desc->maxmhz[idx]), "%.4f",
-                 (float)path_read_s32(_PATH_SYS_CPU
-                                      "/cpu%d/cpufreq/cpuinfo_max_freq", num) / 1000);
+       xasprintf(&desc->maxmhz[idx], "%.4f", (float) mhz / 1000);
 }
 
 static void
 read_min_mhz(struct lscpu_desc *desc, int idx)
 {
        int num = real_cpu_num(desc, idx);
+       int mhz;
 
-       if (!path_exist(_PATH_SYS_CPU "/cpu%d/cpufreq/cpuinfo_min_freq", num))
+       if (ul_path_readf_s32(desc->syscpu, &mhz, "cpu%d/cpufreq/cpuinfo_min_freq", num) != 0)
                return;
        if (!desc->minmhz)
                desc->minmhz = xcalloc(desc->ncpuspos, sizeof(char *));
-       xasprintf(&(desc->minmhz[idx]), "%.4f",
-                 (float)path_read_s32(_PATH_SYS_CPU
-                                      "/cpu%d/cpufreq/cpuinfo_min_freq", num) / 1000);
+       xasprintf(&desc->minmhz[idx], "%.4f", (float) mhz / 1000);
 }
 
 static int
@@ -1235,60 +1326,69 @@ read_cache(struct lscpu_desc *desc, int idx)
        int num = real_cpu_num(desc, idx);
 
        if (!desc->ncaches) {
-               while(path_exist(_PATH_SYS_CPU "/cpu%d/cache/index%d",
-                                       num, desc->ncaches))
+               while (ul_path_accessf(desc->syscpu, F_OK,
+                                       "cpu%d/cache/index%d",
+                                       num, desc->ncaches) == 0)
                        desc->ncaches++;
 
                if (!desc->ncaches)
                        return;
-
                desc->caches = xcalloc(desc->ncaches, sizeof(*desc->caches));
        }
        for (i = 0; i < desc->ncaches; i++) {
                struct cpu_cache *ca = &desc->caches[i];
                cpu_set_t *map;
 
-               if (!path_exist(_PATH_SYS_CPU "/cpu%d/cache/index%d",
-                               num, i))
+               if (ul_path_accessf(desc->syscpu, F_OK,
+                                       "cpu%d/cache/index%d", num, i) != 0)
                        continue;
                if (!ca->name) {
-                       int type, level;
+                       int type = 0;
 
                        /* cache type */
-                       path_read_str(buf, sizeof(buf),
-                                       _PATH_SYS_CPU "/cpu%d/cache/index%d/type",
-                                       num, i);
-                       if (!strcmp(buf, "Data"))
-                               type = 'd';
-                       else if (!strcmp(buf, "Instruction"))
-                               type = 'i';
-                       else
-                               type = 0;
+                       if (ul_path_readf_string(desc->syscpu, &ca->type,
+                                       "cpu%d/cache/index%d/type", num, i) > 0) {
+                               if (!strcmp(ca->type, "Data"))
+                                       type = 'd';
+                               else if (!strcmp(ca->type, "Instruction"))
+                                       type = 'i';
+                       }
 
                        /* cache level */
-                       level = path_read_s32(_PATH_SYS_CPU "/cpu%d/cache/index%d/level",
-                                       num, i);
+                       ul_path_readf_s32(desc->syscpu, &ca->level,
+                                       "cpu%d/cache/index%d/level", num, i);
                        if (type)
-                               snprintf(buf, sizeof(buf), "L%d%c", level, type);
+                               snprintf(buf, sizeof(buf), "L%d%c", ca->level, type);
                        else
-                               snprintf(buf, sizeof(buf), "L%d", level);
+                               snprintf(buf, sizeof(buf), "L%d", ca->level);
 
                        ca->name = xstrdup(buf);
 
+                       ul_path_readf_u32(desc->syscpu, &ca->ways_of_associativity,
+                                       "cpu%d/cache/index%d/ways_of_associativity", num, i);
+                       ul_path_readf_u32(desc->syscpu, &ca->physical_line_partition,
+                                       "cpu%d/cache/index%d/physical_line_partition", num, i);
+                       ul_path_readf_u32(desc->syscpu, &ca->number_of_sets,
+                                       "cpu%d/cache/index%d/number_of_sets", num, i);
+                       ul_path_readf_u32(desc->syscpu, &ca->coherency_line_size,
+                                       "cpu%d/cache/index%d/coherency_line_size", num, i);
+
+                       ul_path_readf_string(desc->syscpu, &ca->allocation_policy,
+                                       "cpu%d/cache/index%d/allocation_policy", num, i);
+                       ul_path_readf_string(desc->syscpu, &ca->write_policy,
+                                       "cpu%d/cache/index%d/write_policy", num, i);
+
                        /* cache size */
-                       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");
-                       }
+                       if (ul_path_readf_buffer(desc->syscpu, buf, sizeof(buf),
+                                       "cpu%d/cache/index%d/size", num, i) > 0)
+                               parse_size(buf, &ca->size, NULL);
+                       else
+                               ca->size = 0;
                }
 
                /* information about how CPUs share different caches */
-               map = path_read_cpuset(maxcpus,
-                                 _PATH_SYS_CPU "/cpu%d/cache/index%d/shared_cpu_map",
-                                 num, i);
+               ul_path_readf_cpuset(desc->syscpu, &map, maxcpus,
+                                 "cpu%d/cache/index%d/shared_cpu_map", num, i);
 
                if (!ca->sharedmaps)
                        ca->sharedmaps = xcalloc(desc->ncpuspos, sizeof(cpu_set_t *));
@@ -1320,15 +1420,19 @@ read_nodes(struct lscpu_desc *desc)
        int i = 0;
        DIR *dir;
        struct dirent *d;
-       const char *path;
+       struct path_cxt *sysnode;
 
        desc->nnodes = 0;
 
-       /* number of NUMA node */
-       if (!(path = path_get(_PATH_SYS_NODE)))
-               return;
-       if (!(dir = opendir(path)))
-               return;
+       sysnode = ul_new_path(_PATH_SYS_NODE);
+       if (!sysnode)
+               err(EXIT_FAILURE, _("failed to initialize %s handler"), _PATH_SYS_NODE);
+       ul_path_set_prefix(sysnode, desc->prefix);
+
+       dir = ul_path_opendir(sysnode, NULL);
+       if (!dir)
+               goto done;
+
        while ((d = readdir(dir))) {
                if (is_node_dirent(d))
                        desc->nnodes++;
@@ -1336,7 +1440,7 @@ read_nodes(struct lscpu_desc *desc)
 
        if (!desc->nnodes) {
                closedir(dir);
-               return;
+               goto done;
        }
 
        desc->nodemaps = xcalloc(desc->nnodes, sizeof(cpu_set_t *));
@@ -1353,9 +1457,10 @@ read_nodes(struct lscpu_desc *desc)
 
        /* information about how nodes share different CPUs */
        for (i = 0; i < desc->nnodes; i++)
-               desc->nodemaps[i] = path_read_cpuset(maxcpus,
-                                       _PATH_SYS_NODE "/node%d/cpumap",
-                                       desc->idx2nodenum[i]);
+               ul_path_readf_cpuset(sysnode, &desc->nodemaps[i], maxcpus,
+                               "node%d/cpumap", desc->idx2nodenum[i]);
+done:
+       ul_unref_path(sysnode);
 }
 
 static char *
@@ -1370,10 +1475,10 @@ get_cell_data(struct lscpu_desc *desc, int idx, int col,
        *buf = '\0';
 
        switch (col) {
-       case COL_CPU:
+       case COL_CPU_CPU:
                snprintf(buf, bufsz, "%d", cpu);
                break;
-       case COL_CORE:
+       case COL_CPU_CORE:
                if (mod->physical) {
                        if (desc->coreids[idx] == -1)
                                snprintf(buf, bufsz, "-");
@@ -1385,7 +1490,7 @@ get_cell_data(struct lscpu_desc *desc, int idx, int col,
                                snprintf(buf, bufsz, "%zu", i);
                }
                break;
-       case COL_SOCKET:
+       case COL_CPU_SOCKET:
                if (mod->physical) {
                        if (desc->socketids[idx] ==  -1)
                                snprintf(buf, bufsz, "-");
@@ -1397,12 +1502,12 @@ get_cell_data(struct lscpu_desc *desc, int idx, int col,
                                snprintf(buf, bufsz, "%zu", i);
                }
                break;
-       case COL_NODE:
+       case COL_CPU_NODE:
                if (cpuset_ary_isset(cpu, desc->nodemaps,
                                     desc->nnodes, setsize, &i) == 0)
                        snprintf(buf, bufsz, "%d", desc->idx2nodenum[i]);
                break;
-       case COL_DRAWER:
+       case COL_CPU_DRAWER:
                if (mod->physical) {
                        if (desc->drawerids[idx] == -1)
                                snprintf(buf, bufsz, "-");
@@ -1414,7 +1519,7 @@ get_cell_data(struct lscpu_desc *desc, int idx, int col,
                                snprintf(buf, bufsz, "%zu", i);
                }
                break;
-       case COL_BOOK:
+       case COL_CPU_BOOK:
                if (mod->physical) {
                        if (desc->bookids[idx] == -1)
                                snprintf(buf, bufsz, "-");
@@ -1426,7 +1531,7 @@ get_cell_data(struct lscpu_desc *desc, int idx, int col,
                                snprintf(buf, bufsz, "%zu", i);
                }
                break;
-       case COL_CACHE:
+       case COL_CPU_CACHE:
        {
                char *p = buf;
                size_t sz = bufsz;
@@ -1453,7 +1558,7 @@ get_cell_data(struct lscpu_desc *desc, int idx, int col,
                }
                break;
        }
-       case COL_POLARIZATION:
+       case COL_CPU_POLARIZATION:
                if (desc->polarization) {
                        int x = desc->polarization[idx];
 
@@ -1463,11 +1568,11 @@ get_cell_data(struct lscpu_desc *desc, int idx, int col,
                                                polar_modes[x].readable);
                }
                break;
-       case COL_ADDRESS:
+       case COL_CPU_ADDRESS:
                if (desc->addresses)
                        snprintf(buf, bufsz, "%d", desc->addresses[idx]);
                break;
-       case COL_CONFIGURED:
+       case COL_CPU_CONFIGURED:
                if (!desc->configured)
                        break;
                if (mod->mode == OUTPUT_PARSABLE)
@@ -1477,7 +1582,7 @@ get_cell_data(struct lscpu_desc *desc, int idx, int col,
                        snprintf(buf, bufsz, "%s",
                                 desc->configured[idx] ? _("yes") : _("no"));
                break;
-       case COL_ONLINE:
+       case COL_CPU_ONLINE:
                if (!desc->online)
                        break;
                if (mod->mode == OUTPUT_PARSABLE)
@@ -1487,11 +1592,11 @@ get_cell_data(struct lscpu_desc *desc, int idx, int col,
                        snprintf(buf, bufsz, "%s",
                                 is_cpu_online(desc, cpu) ? _("yes") : _("no"));
                break;
-       case COL_MAXMHZ:
+       case COL_CPU_MAXMHZ:
                if (desc->maxmhz && desc->maxmhz[idx])
                        xstrncpy(buf, desc->maxmhz[idx], bufsz);
                break;
-       case COL_MINMHZ:
+       case COL_CPU_MINMHZ:
                if (desc->minmhz && desc->minmhz[idx])
                        xstrncpy(buf, desc->minmhz[idx], bufsz);
                break;
@@ -1506,7 +1611,7 @@ get_cell_header(struct lscpu_desc *desc, int col,
 {
        *buf = '\0';
 
-       if (col == COL_CACHE) {
+       if (col == COL_CPU_CACHE) {
                char *p = buf;
                size_t sz = bufsz;
                int i;
@@ -1528,10 +1633,118 @@ get_cell_header(struct lscpu_desc *desc, int col,
                if (desc->ncaches)
                        return buf;
        }
-       snprintf(buf, bufsz, "%s", coldescs[col].name);
+       snprintf(buf, bufsz, "%s", coldescs_cpu[col].name);
        return buf;
 }
 
+/*
+ * [-C] backend
+ */
+static void
+print_caches_readable(struct lscpu_desc *desc, int cols[], int ncols,
+              struct lscpu_modifier *mod)
+{
+       int i;
+       struct libscols_table *table;
+
+       scols_init_debug(0);
+
+       table = scols_new_table();
+       if (!table)
+                err(EXIT_FAILURE, _("failed to allocate output table"));
+       if (mod->json) {
+               scols_table_enable_json(table, 1);
+               scols_table_set_name(table, "caches");
+       }
+
+       for (i = 0; i < ncols; i++) {
+               struct lscpu_coldesc *cd = &coldescs_cache[cols[i]];
+               if (!scols_table_new_column(table, cd->name, 0, cd->flags))
+                       err(EXIT_FAILURE, _("failed to allocate output column"));
+       }
+
+       for (i = desc->ncaches - 1; i >= 0; i--) {
+               struct cpu_cache *ca = &desc->caches[i];
+               struct libscols_line *line;
+               int c;
+
+               line = scols_table_new_line(table, NULL);
+               if (!line)
+                       err(EXIT_FAILURE, _("failed to allocate output line"));
+
+               for (c = 0; c < ncols; c++) {
+                       char *data = NULL;
+                       int col = cols[c];
+
+                       switch (col) {
+                       case COL_CACHE_NAME:
+                               if (ca->name)
+                                       data = xstrdup(ca->name);
+                               break;
+                       case COL_CACHE_ONESIZE:
+                               if (!ca->size)
+                                       break;
+                               if (mod->bytes)
+                                       xasprintf(&data, "%" PRIu64, ca->size);
+                               else
+                                       data = size_to_human_string(SIZE_SUFFIX_1LETTER, ca->size);
+                               break;
+                       case COL_CACHE_ALLSIZE:
+                       {
+                               uint64_t sz = 0;
+
+                               if (get_cache_full_size(desc, ca, &sz) != 0)
+                                       break;
+                               if (mod->bytes)
+                                       xasprintf(&data, "%" PRIu64, sz);
+                               else
+                                       data = size_to_human_string(SIZE_SUFFIX_1LETTER, sz);
+                               break;
+                       }
+                       case COL_CACHE_WAYS:
+                               if (ca->ways_of_associativity)
+                                       xasprintf(&data, "%u", ca->ways_of_associativity);
+                               break;
+
+                       case COL_CACHE_TYPE:
+                               if (ca->type)
+                                       data = xstrdup(ca->type);
+                               break;
+                       case COL_CACHE_LEVEL:
+                               if (ca->level)
+                                       xasprintf(&data, "%d", ca->level);
+                               break;
+                       case COL_CACHE_ALLOCPOL:
+                               if (ca->allocation_policy)
+                                       data = xstrdup(ca->allocation_policy);
+                               break;
+                       case COL_CACHE_WRITEPOL:
+                               if (ca->write_policy)
+                                       data = xstrdup(ca->write_policy);
+                               break;
+                       case COL_CACHE_PHYLINE:
+                               if (ca->physical_line_partition)
+                                       xasprintf(&data, "%u", ca->physical_line_partition);
+                               break;
+                       case COL_CACHE_SETS:
+                               if (ca->number_of_sets)
+                                       xasprintf(&data, "%u", ca->number_of_sets);
+                               break;
+                       case COL_CACHE_COHERENCYSIZE:
+                               if (ca->coherency_line_size)
+                                       xasprintf(&data, "%u", ca->coherency_line_size);
+                               break;
+                       }
+
+                       if (data && scols_line_refer_data(line, c, data))
+                               err(EXIT_FAILURE, _("failed to add output data"));
+               }
+       }
+
+       scols_print_table(table);
+       scols_unref_table(table);
+}
+
 /*
  * [-p] backend, we support two parsable formats:
  *
@@ -1556,7 +1769,7 @@ get_cell_header(struct lscpu_desc *desc, int col,
  *     1,1,0,0,1:1:0
  */
 static void
-print_parsable(struct lscpu_desc *desc, int cols[], int ncols,
+print_cpus_parsable(struct lscpu_desc *desc, int cols[], int ncols,
               struct lscpu_modifier *mod)
 {
        char buf[BUFSIZ], *data;
@@ -1574,7 +1787,7 @@ print_parsable(struct lscpu_desc *desc, int cols[], int ncols,
        for (i = 0; i < ncols; i++) {
                int col = cols[i];
 
-               if (col == COL_CACHE) {
+               if (col == COL_CPU_CACHE) {
                        if (mod->compat && !desc->ncaches)
                                continue;
                        if (mod->compat && i != 0)
@@ -1585,8 +1798,8 @@ print_parsable(struct lscpu_desc *desc, int cols[], int ncols,
 
                data = get_cell_header(desc, col, mod, buf, sizeof(buf));
 
-               if (data && * data && col != COL_CACHE &&
-                   !coldescs[col].is_abbr) {
+               if (data && * data && col != COL_CPU_CACHE &&
+                   !coldescs_cpu[col].is_abbr) {
                        /*
                         * For normal column names use mixed case (e.g. "Socket")
                         */
@@ -1608,14 +1821,16 @@ print_parsable(struct lscpu_desc *desc, int cols[], int ncols,
                int c;
                int cpu = real_cpu_num(desc, i);
 
-               if (!mod->offline && desc->online && !is_cpu_online(desc, cpu))
-                       continue;
-               if (!mod->online && desc->online && is_cpu_online(desc, cpu))
-                       continue;
+               if (desc->online) {
+                       if (!mod->offline && !is_cpu_online(desc, cpu))
+                               continue;
+                       if (!mod->online && is_cpu_online(desc, cpu))
+                               continue;
+               }
                if (desc->present && !is_cpu_present(desc, cpu))
                        continue;
                for (c = 0; c < ncols; c++) {
-                       if (mod->compat && cols[c] == COL_CACHE) {
+                       if (mod->compat && cols[c] == COL_CPU_CACHE) {
                                if (!desc->ncaches)
                                        continue;
                                if (c > 0)
@@ -1636,7 +1851,7 @@ print_parsable(struct lscpu_desc *desc, int cols[], int ncols,
  * [-e] backend
  */
 static void
-print_readable(struct lscpu_desc *desc, int cols[], int ncols,
+print_cpus_readable(struct lscpu_desc *desc, int cols[], int ncols,
               struct lscpu_modifier *mod)
 {
        int i;
@@ -1656,7 +1871,7 @@ print_readable(struct lscpu_desc *desc, int cols[], int ncols,
 
        for (i = 0; i < ncols; i++) {
                data = get_cell_header(desc, cols[i], mod, buf, sizeof(buf));
-               if (!scols_table_new_column(table, data, 0, 0))
+               if (!scols_table_new_column(table, data, 0, coldescs_cpu[cols[i]].flags))
                        err(EXIT_FAILURE, _("failed to allocate output column"));
        }
 
@@ -1665,10 +1880,12 @@ print_readable(struct lscpu_desc *desc, int cols[], int ncols,
                struct libscols_line *line;
                int cpu = real_cpu_num(desc, i);
 
-               if (!mod->offline && desc->online && !is_cpu_online(desc, cpu))
-                       continue;
-               if (!mod->online && desc->online && is_cpu_online(desc, cpu))
-                       continue;
+               if (desc->online) {
+                       if (!mod->offline && !is_cpu_online(desc, cpu))
+                               continue;
+                       if (!mod->online && is_cpu_online(desc, cpu))
+                               continue;
+               }
                if (desc->present && !is_cpu_present(desc, cpu))
                        continue;
 
@@ -1705,7 +1922,8 @@ static void __attribute__ ((__format__(printf, 3, 4)))
                err(EXIT_FAILURE, _("failed to allocate output line"));
 
        /* description column */
-       scols_line_set_data(ln, 0, txt);
+       if (txt && scols_line_set_data(ln, 0, txt))
+               err(EXIT_FAILURE, _("failed to add output data"));
 
        /* data column */
        va_start(args, fmt);
@@ -1736,6 +1954,32 @@ print_cpuset(struct libscols_table *tb,
        }
 }
 
+static int get_cache_full_size(struct lscpu_desc *desc,
+               struct cpu_cache *ca, uint64_t *res)
+{
+       size_t setsize = CPU_ALLOC_SIZE(maxcpus);
+       int i, nshares = 0;
+
+       /* Count number of CPUs which shares the cache */
+       for (i = 0; i < desc->ncpuspos; i++) {
+               int cpu = real_cpu_num(desc, i);
+
+               if (desc->present && !is_cpu_present(desc, cpu))
+                       continue;
+               if (CPU_ISSET_S(cpu, setsize, ca->sharedmaps[0]))
+                       nshares++;
+       }
+
+       /* Correction for CPU threads */
+       if (desc->nthreads > desc->ncores)
+               nshares /= (desc->nthreads / desc->ncores);
+       if (nshares < 1)
+               nshares = 1;
+
+       *res = (desc->ncores / nshares) * ca->size;
+       return 0;
+}
+
 /*
  * default output
  */
@@ -1760,7 +2004,7 @@ print_summary(struct lscpu_desc *desc, struct lscpu_modifier *mod)
        }
 
        if (scols_table_new_column(tb, "field", 0, 0) == NULL ||
-           scols_table_new_column(tb, "data", 0, SCOLS_FL_NOEXTREMES) == NULL)
+           scols_table_new_column(tb, "data", 0, SCOLS_FL_NOEXTREMES | SCOLS_FL_WRAP) == NULL)
                err(EXIT_FAILURE, _("failed to initialize output column"));
 
        add_summary_s(tb, _("Architecture:"), desc->arch);
@@ -1783,6 +2027,10 @@ print_summary(struct lscpu_desc *desc, struct lscpu_modifier *mod)
 #else
        add_summary_s(tb, _("Byte Order:"), "Big Endian");
 #endif
+
+       if (desc->addrsz)
+               add_summary_s(tb, _("Address sizes:"), desc->addrsz);
+
        add_summary_n(tb, _("CPU(s):"), desc->ncpus);
 
        if (desc->online)
@@ -1827,7 +2075,7 @@ print_summary(struct lscpu_desc *desc, struct lscpu_modifier *mod)
                 * If the cpu topology is not exported (e.g. 2nd level guest)
                 * fall back to old calculation scheme.
                 */
-               if ((fd = path_fopen("r", 0, _PATH_PROC_SYSINFO))) {
+               if ((fd = ul_path_fopen(desc->procfs, "r", "sysinfo"))) {
                        int t0, t1;
 
                        while (fd && fgets(buf, sizeof(buf), fd) != NULL) {
@@ -1874,6 +2122,9 @@ print_summary(struct lscpu_desc *desc, struct lscpu_modifier *mod)
                add_summary_s(tb, _("Model name:"), desc->cpu ? desc->cpu : desc->modelname);
        if (desc->stepping)
                add_summary_s(tb, _("Stepping:"), desc->stepping);
+       if (desc->freqboost >= 0)
+               add_summary_s(tb, _("Frequency boost:"), desc->freqboost ?
+                               _("enabled") : _("disabled"));
        if (desc->mhz)
                add_summary_s(tb, _("CPU MHz:"), desc->mhz);
        if (desc->dynamic_mhz)
@@ -1902,16 +2153,41 @@ print_summary(struct lscpu_desc *desc, struct lscpu_modifier *mod)
                add_summary_s(tb, _("Dispatching mode:"), _(disp_modes[desc->dispatching]));
        if (desc->ncaches) {
                for (i = desc->ncaches - 1; i >= 0; i--) {
-                       snprintf(buf, sizeof(buf),
-                                       _("%s cache:"), desc->caches[i].name);
-                       add_summary_s(tb, buf, desc->caches[i].size);
+                       uint64_t sz = 0;
+                       char *tmp;
+                       struct cpu_cache *ca = &desc->caches[i];
+
+                       if (ca->size == 0)
+                               continue;
+                       if (get_cache_full_size(desc, ca, &sz) != 0 || sz == 0)
+                               continue;
+                       if (mod->bytes)
+                               xasprintf(&tmp, "%" PRIu64, sz);
+                       else
+                               tmp = size_to_human_string(
+                                       SIZE_SUFFIX_3LETTER | SIZE_SUFFIX_SPACE,
+                                       sz);
+                       snprintf(buf, sizeof(buf), _("%s cache:"), ca->name);
+                       add_summary_s(tb, buf, tmp);
+                       free(tmp);
                }
        }
        if (desc->necaches) {
                for (i = desc->necaches - 1; i >= 0; i--) {
-                       snprintf(buf, sizeof(buf),
-                                       _("%s cache:"), desc->ecaches[i].name);
-                       add_summary_s(tb, buf, desc->ecaches[i].size);
+                       char *tmp;
+                       struct cpu_cache *ca = &desc->ecaches[i];
+
+                       if (ca->size == 0)
+                               continue;
+                       if (mod->bytes)
+                               xasprintf(&tmp, "%" PRIu64, ca->size);
+                       else
+                               tmp = size_to_human_string(
+                                       SIZE_SUFFIX_3LETTER | SIZE_SUFFIX_SPACE,
+                                       ca->size);
+                       snprintf(buf, sizeof(buf), _("%s cache:"), ca->name);
+                       add_summary_s(tb, buf, tmp);
+                       free(tmp);
                }
        }
 
@@ -1926,6 +2202,13 @@ print_summary(struct lscpu_desc *desc, struct lscpu_modifier *mod)
                add_summary_n(tb, _("Physical cores/chip:"), desc->physcoresperchip);
        }
 
+       if (desc->vuls) {
+               for (i = 0; i < desc->nvuls; i++) {
+                       snprintf(buf, sizeof(buf), ("Vulnerability %s:"), desc->vuls[i].name);
+                       add_summary_s(tb, buf, desc->vuls[i].text);
+               }
+       }
+
        if (desc->flags)
                add_summary_s(tb, _("Flags:"), desc->flags);
 
@@ -1947,6 +2230,8 @@ static void __attribute__((__noreturn__)) usage(void)
        fputs(USAGE_OPTIONS, out);
        fputs(_(" -a, --all               print both online and offline CPUs (default for -e)\n"), out);
        fputs(_(" -b, --online            print online CPUs only (default for -p)\n"), out);
+       fputs(_(" -B, --bytes             print sizes in bytes rather than in human readable format\n"), out);
+       fputs(_(" -C, --caches[=<list>]   info about caches in extended readable format\n"), out);
        fputs(_(" -c, --offline           print offline CPUs only\n"), out);
        fputs(_(" -J, --json              use JSON for default or extended format\n"), out);
        fputs(_(" -e, --extended[=<list>] print out an extended readable format\n"), out);
@@ -1954,12 +2239,17 @@ static void __attribute__((__noreturn__)) usage(void)
        fputs(_(" -s, --sysroot <dir>     use specified directory as system root\n"), out);
        fputs(_(" -x, --hex               print hexadecimal masks rather than lists of CPUs\n"), out);
        fputs(_(" -y, --physical          print physical instead of logical IDs\n"), out);
+       fputs(_("     --output-all        print all available columns for -e, -p or -C\n"), out);
        fputs(USAGE_SEPARATOR, out);
        printf(USAGE_HELP_OPTIONS(25));
 
-       fputs(USAGE_COLUMNS, out);
-       for (i = 0; i < ARRAY_SIZE(coldescs); i++)
-               fprintf(out, " %13s  %s\n", coldescs[i].name, _(coldescs[i].help));
+       fputs(_("\nAvailable output columns for -e or -p:\n"), out);
+       for (i = 0; i < ARRAY_SIZE(coldescs_cpu); i++)
+               fprintf(out, " %13s  %s\n", coldescs_cpu[i].name, _(coldescs_cpu[i].help));
+
+       fputs(_("\nAvailable output columns for -C:\n"), out);
+       for (i = 0; i < ARRAY_SIZE(coldescs_cache); i++)
+               fprintf(out, " %13s  %s\n", coldescs_cache[i].name, _(coldescs_cache[i].help));
 
        printf(USAGE_MAN_TAIL("lscpu(1)"));
 
@@ -1970,13 +2260,19 @@ int main(int argc, char *argv[])
 {
        struct lscpu_modifier _mod = { .mode = OUTPUT_SUMMARY }, *mod = &_mod;
        struct lscpu_desc _desc = { .flags = NULL }, *desc = &_desc;
-       int c, i;
-       int columns[ARRAY_SIZE(coldescs)], ncolumns = 0;
+       int c, i, all = 0;
+       int columns[ARRAY_SIZE(coldescs_cpu)], ncolumns = 0;
        int cpu_modifier_specified = 0;
+       size_t setsize;
 
+       enum {
+               OPT_OUTPUT_ALL = CHAR_MAX + 1,
+       };
        static const struct option longopts[] = {
                { "all",        no_argument,       NULL, 'a' },
                { "online",     no_argument,       NULL, 'b' },
+               { "bytes",      no_argument,       NULL, 'B' },
+               { "caches",     optional_argument, NULL, 'C' },
                { "offline",    no_argument,       NULL, 'c' },
                { "help",       no_argument,       NULL, 'h' },
                { "extended",   optional_argument, NULL, 'e' },
@@ -1986,12 +2282,13 @@ int main(int argc, char *argv[])
                { "physical",   no_argument,       NULL, 'y' },
                { "hex",        no_argument,       NULL, 'x' },
                { "version",    no_argument,       NULL, 'V' },
+               { "output-all", no_argument,       NULL, OPT_OUTPUT_ALL },
                { NULL,         0, NULL, 0 }
        };
 
        static const ul_excl_t excl[] = {       /* rows and cols in ASCII order */
+               { 'C','e','p' },
                { 'a','b','c' },
-               { 'e','p' },
                { 0 }
        };
        int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;
@@ -1999,9 +2296,9 @@ int main(int argc, char *argv[])
        setlocale(LC_ALL, "");
        bindtextdomain(PACKAGE, LOCALEDIR);
        textdomain(PACKAGE);
-       atexit(close_stdout);
+       close_stdout_atexit();
 
-       while ((c = getopt_long(argc, argv, "abce::hJp::s:xyV", longopts, NULL)) != -1) {
+       while ((c = getopt_long(argc, argv, "aBbC::ce::hJp::s:xyV", longopts, NULL)) != -1) {
 
                err_exclusive_options(c, longopts, excl, excl_st);
 
@@ -2010,6 +2307,9 @@ int main(int argc, char *argv[])
                        mod->online = mod->offline = 1;
                        cpu_modifier_specified = 1;
                        break;
+               case 'B':
+                       mod->bytes = 1;
+                       break;
                case 'b':
                        mod->online = 1;
                        cpu_modifier_specified = 1;
@@ -2018,8 +2318,18 @@ int main(int argc, char *argv[])
                        mod->offline = 1;
                        cpu_modifier_specified = 1;
                        break;
-               case 'h':
-                       usage();
+               case 'C':
+                       if (optarg) {
+                               if (*optarg == '=')
+                                       optarg++;
+                               ncolumns = string_to_idarray(optarg,
+                                               columns, ARRAY_SIZE(columns),
+                                               cache_column_name_to_id);
+                               if (ncolumns < 0)
+                                       return EXIT_FAILURE;
+                       }
+                       mod->mode = OUTPUT_CACHES;
+                       break;
                case 'J':
                        mod->json = 1;
                        break;
@@ -2030,15 +2340,14 @@ int main(int argc, char *argv[])
                                        optarg++;
                                ncolumns = string_to_idarray(optarg,
                                                columns, ARRAY_SIZE(columns),
-                                               column_name_to_id);
+                                               cpu_column_name_to_id);
                                if (ncolumns < 0)
                                        return EXIT_FAILURE;
                        }
                        mod->mode = c == 'p' ? OUTPUT_PARSABLE : OUTPUT_READABLE;
                        break;
                case 's':
-                       if(path_set_prefix(optarg))
-                               err(EXIT_FAILURE, _("invalid argument to %s"), "--sysroot");
+                       desc->prefix = optarg;
                        mod->system = SYSTEM_SNAPSHOT;
                        break;
                case 'x':
@@ -2047,14 +2356,28 @@ int main(int argc, char *argv[])
                case 'y':
                        mod->physical = 1;
                        break;
+               case OPT_OUTPUT_ALL:
+                       all = 1;
+                       break;
+
+               case 'h':
+                       usage();
                case 'V':
-                       printf(UTIL_LINUX_VERSION);
-                       return EXIT_SUCCESS;
+                       print_version(EXIT_SUCCESS);
                default:
                        errtryhelp(EXIT_FAILURE);
                }
        }
 
+       if (all && ncolumns == 0) {
+               size_t sz, maxsz = mod->mode == OUTPUT_CACHES ?
+                               ARRAY_SIZE(coldescs_cache) :
+                               ARRAY_SIZE(coldescs_cpu);
+
+               for (sz = 0; sz < maxsz; sz++)
+                       columns[ncolumns++] = sz;
+       }
+
        if (cpu_modifier_specified && mod->mode == OUTPUT_SUMMARY) {
                fprintf(stderr,
                        _("%s: options --all, --online and --offline may only "
@@ -2074,12 +2397,30 @@ int main(int argc, char *argv[])
                mod->offline = mod->mode == OUTPUT_READABLE ? 1 : 0;
        }
 
+       ul_path_init_debug();
+
+       /* /sys/devices/system/cpu */
+       desc->syscpu = ul_new_path(_PATH_SYS_CPU);
+       if (!desc->syscpu)
+               err(EXIT_FAILURE, _("failed to initialize CPUs sysfs handler"));
+       if (desc->prefix)
+               ul_path_set_prefix(desc->syscpu, desc->prefix);
+
+       /* /proc */
+       desc->procfs = ul_new_path("/proc");
+       if (!desc->procfs)
+               err(EXIT_FAILURE, _("failed to initialize procfs handler"));
+       if (desc->prefix)
+               ul_path_set_prefix(desc->procfs, desc->prefix);
+
        read_basicinfo(desc, mod);
 
+       setsize = CPU_ALLOC_SIZE(maxcpus);
+
        for (i = 0; i < desc->ncpuspos; i++) {
                /* only consider present CPUs */
                if (desc->present &&
-                   !CPU_ISSET(real_cpu_num(desc, i), desc->present))
+                   !CPU_ISSET_S(real_cpu_num(desc, i), setsize, desc->present))
                        continue;
                read_topology(desc, i);
                read_cache(desc, i);
@@ -2106,49 +2447,65 @@ int main(int argc, char *argv[])
        case OUTPUT_SUMMARY:
                print_summary(desc, mod);
                break;
+       case OUTPUT_CACHES:
+               if (!ncolumns) {
+                       columns[ncolumns++] = COL_CACHE_NAME;
+                       columns[ncolumns++] = COL_CACHE_ONESIZE;
+                       columns[ncolumns++] = COL_CACHE_ALLSIZE;
+                       columns[ncolumns++] = COL_CACHE_WAYS;
+                       columns[ncolumns++] = COL_CACHE_TYPE;
+                       columns[ncolumns++] = COL_CACHE_LEVEL;
+                       columns[ncolumns++] = COL_CACHE_SETS;
+                       columns[ncolumns++] = COL_CACHE_PHYLINE;
+                       columns[ncolumns++] = COL_CACHE_COHERENCYSIZE;
+               }
+               print_caches_readable(desc, columns, ncolumns, mod);
+               break;
        case OUTPUT_PARSABLE:
                if (!ncolumns) {
-                       columns[ncolumns++] = COL_CPU;
-                       columns[ncolumns++] = COL_CORE;
-                       columns[ncolumns++] = COL_SOCKET;
-                       columns[ncolumns++] = COL_NODE;
-                       columns[ncolumns++] = COL_CACHE;
+                       columns[ncolumns++] = COL_CPU_CPU;
+                       columns[ncolumns++] = COL_CPU_CORE;
+                       columns[ncolumns++] = COL_CPU_SOCKET;
+                       columns[ncolumns++] = COL_CPU_NODE;
+                       columns[ncolumns++] = COL_CPU_CACHE;
                        mod->compat = 1;
                }
-               print_parsable(desc, columns, ncolumns, mod);
+               print_cpus_parsable(desc, columns, ncolumns, mod);
                break;
        case OUTPUT_READABLE:
                if (!ncolumns) {
                        /* No list was given. Just print whatever is there. */
-                       columns[ncolumns++] = COL_CPU;
+                       columns[ncolumns++] = COL_CPU_CPU;
                        if (desc->nodemaps)
-                               columns[ncolumns++] = COL_NODE;
+                               columns[ncolumns++] = COL_CPU_NODE;
                        if (desc->drawermaps)
-                               columns[ncolumns++] = COL_DRAWER;
+                               columns[ncolumns++] = COL_CPU_DRAWER;
                        if (desc->bookmaps)
-                               columns[ncolumns++] = COL_BOOK;
+                               columns[ncolumns++] = COL_CPU_BOOK;
                        if (desc->socketmaps)
-                               columns[ncolumns++] = COL_SOCKET;
+                               columns[ncolumns++] = COL_CPU_SOCKET;
                        if (desc->coremaps)
-                               columns[ncolumns++] = COL_CORE;
+                               columns[ncolumns++] = COL_CPU_CORE;
                        if (desc->caches)
-                               columns[ncolumns++] = COL_CACHE;
+                               columns[ncolumns++] = COL_CPU_CACHE;
                        if (desc->online)
-                               columns[ncolumns++] = COL_ONLINE;
+                               columns[ncolumns++] = COL_CPU_ONLINE;
                        if (desc->configured)
-                               columns[ncolumns++] = COL_CONFIGURED;
+                               columns[ncolumns++] = COL_CPU_CONFIGURED;
                        if (desc->polarization)
-                               columns[ncolumns++] = COL_POLARIZATION;
+                               columns[ncolumns++] = COL_CPU_POLARIZATION;
                        if (desc->addresses)
-                               columns[ncolumns++] = COL_ADDRESS;
+                               columns[ncolumns++] = COL_CPU_ADDRESS;
                        if (desc->maxmhz)
-                               columns[ncolumns++] = COL_MAXMHZ;
+                               columns[ncolumns++] = COL_CPU_MAXMHZ;
                        if (desc->minmhz)
-                               columns[ncolumns++] = COL_MINMHZ;
+                               columns[ncolumns++] = COL_CPU_MINMHZ;
                }
-               print_readable(desc, columns, ncolumns, mod);
+               print_cpus_readable(desc, columns, ncolumns, mod);
                break;
        }
 
+       ul_unref_path(desc->syscpu);
+       ul_unref_path(desc->procfs);
        return EXIT_SUCCESS;
 }