]> err.no Git - util-linux/commitdiff
lscpu: support sysfs without cpu/online file
authorKarel Zak <kzak@redhat.com>
Fri, 20 Aug 2010 19:15:51 +0000 (21:15 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 20 Aug 2010 19:15:51 +0000 (21:15 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/lscpu.c

index ac66d2ec8122d2f23558cd48f3a3dd9579b00320..027a29822f87216a6ebcfaeb75da80fd1f25cb15 100644 (file)
@@ -402,7 +402,8 @@ read_basicinfo(struct lscpu_desc *desc)
                maxcpus = desc->ncpus > 2048 ? desc->ncpus : 2048;
 
        /* get mask for online CPUs */
-       desc->online = path_cpulist(_PATH_SYS_SYSTEM "/cpu/online");
+       if (path_exist(_PATH_SYS_SYSTEM "/cpu/online"))
+               desc->online = path_cpulist(_PATH_SYS_SYSTEM "/cpu/online");
 }
 
 static int
@@ -709,7 +710,7 @@ print_parsable(struct lscpu_desc *desc)
 
        for (i = 0; i < desc->ncpus; i++) {
 
-               if (!is_cpu_online(desc, i))
+               if (desc->online && !is_cpu_online(desc, i))
                        continue;
 
                /* #CPU */
@@ -824,11 +825,12 @@ print_readable(struct lscpu_desc *desc, int hex)
 #endif
        print_n(_("CPU(s):"), desc->ncpus);
 
-       print_cpuset(hex ? _("On-line CPU(s) mask:") :
-                          _("On-line CPU(s) list:"),
-                    desc->online, hex);
+       if (desc->online)
+               print_cpuset(hex ? _("On-line CPU(s) mask:") :
+                                  _("On-line CPU(s) list:"),
+                               desc->online, hex);
 
-       if (CPU_COUNT_S(setsize, desc->online) != desc->ncpus) {
+       if (desc->online && CPU_COUNT_S(setsize, desc->online) != desc->ncpus) {
                cpu_set_t *set;
 
                /* Linux kernel provides cpuset of off-line CPUs that contains
@@ -952,7 +954,7 @@ int main(int argc, char *argv[])
        read_basicinfo(desc);
 
        for (i = 0; i < desc->ncpus; i++) {
-               if (!is_cpu_online(desc, i))
+               if (desc->online && !is_cpu_online(desc, i))
                        continue;
                read_topology(desc, i);
                read_cache(desc, i);