]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
5 years agolscpu: Adapt MIPS cpuinfo
Karel Zak [Tue, 3 Nov 2020 11:22:20 +0000 (12:22 +0100)] 
lscpu: Adapt MIPS cpuinfo

Port commit

  commit 6cb8af7be2d76cfd9201f141fa2d69fa2ed32deb
  Author: Jiaxun Yang <jiaxun.yang@flygoat.com>
  Date:   Sat Mar 28 12:19:42 2020 +0800

to new lscpu code.

References: 6cb8af7be2d76cfd9201f141fa2d69fa2ed32deb
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: add shared cached info for s390 lscpu -C
Karel Zak [Tue, 3 Nov 2020 11:10:35 +0000 (12:10 +0100)] 
lscpu: add shared cached info for s390 lscpu -C

Port commit
 commit 318542e060ff68e012bea7ee498f12a6ce7e5593
 Author: Sumanth Korikkar <sumanthk@linux.ibm.com>
 Date:   Fri Jun 5 18:15:10 2020 +0200

to new lscpu code.

References: 318542e060ff68e012bea7ee498f12a6ce7e5593
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: avoid segfault on PowerPC systems with valid hardware configurations
Thomas Abraham [Thu, 24 Sep 2020 18:52:33 +0000 (14:52 -0400)] 
lscpu: avoid segfault on PowerPC systems with valid hardware configurations

ntypes greater than 1 is valid in some hardware configurations, and an assert()
on the value isn't necessary or very future proof

[kzak@redhat.com: - port this patch to new code]

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: update tests
Karel Zak [Tue, 3 Nov 2020 10:49:28 +0000 (11:49 +0100)] 
lscpu: update tests

* cpu MHz is per-CPU value and not printed in summary anymore
* topology is reordered
* number of NUMA nodes is moved to NUMA section
* parsable output uses cache ID from kernel if avalable

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: fix MHZ parsing
Karel Zak [Tue, 3 Nov 2020 10:39:58 +0000 (11:39 +0100)] 
lscpu: fix MHZ parsing

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: improve bogomips use
Karel Zak [Tue, 3 Nov 2020 10:13:26 +0000 (11:13 +0100)] 
lscpu: improve bogomips use

* keep global (cputype) bogomips
* add per-CPU bogomips
* use bogomips from the first CPU as global (for cputype) if /proc/cpuinfo does not provide global bogomips
* add BOGOMIPS column for to -e/-p output

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: add note about cache IDs
Karel Zak [Tue, 3 Nov 2020 09:39:04 +0000 (10:39 +0100)] 
lscpu: add note about cache IDs

We read the ID from /sys/devices/system/cpu/cpu*/cache/index*/id.

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: add MHZ column
Karel Zak [Tue, 3 Nov 2020 09:27:46 +0000 (10:27 +0100)] 
lscpu: add MHZ column

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: don't use section for extra caches
Karel Zak [Tue, 3 Nov 2020 09:13:27 +0000 (10:13 +0100)] 
lscpu: don't use section for extra caches

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: fix for sparc64
Karel Zak [Tue, 3 Nov 2020 08:48:21 +0000 (09:48 +0100)] 
lscpu: fix for sparc64

We do not read CPUs from cpuinfo on sparc.

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: improve topology calculation
Karel Zak [Tue, 3 Nov 2020 08:46:45 +0000 (09:46 +0100)] 
lscpu: improve topology calculation

Let's make it more robust and readable. The sysinfo file on s390 may
contain zeros, so we need to check the values and fallback to data
from shared maps if necessary.

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: assume gaps in list of CPUs
Karel Zak [Tue, 3 Nov 2020 08:44:22 +0000 (09:44 +0100)] 
lscpu: assume gaps in list of CPUs

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: fix last caches separator in -e and -p output
Karel Zak [Mon, 2 Nov 2020 09:34:53 +0000 (10:34 +0100)] 
lscpu: fix last caches separator in -e and -p output

Note that cxt->ncaches is number of all instances, but we split
output according to split output according to caches names.

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: generate cache ID if not available
Karel Zak [Mon, 2 Nov 2020 09:11:46 +0000 (10:11 +0100)] 
lscpu: generate cache ID if not available

The file /sys/devices/system/cpu/cpu*/cache/index*/id is not available
in old kernels. This patch add code to generate IDs according to cache
type and level.

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: cleanup --parse
Karel Zak [Fri, 30 Oct 2020 09:43:17 +0000 (10:43 +0100)] 
lscpu: cleanup --parse

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: cleanup -e
Karel Zak [Fri, 30 Oct 2020 09:12:14 +0000 (10:12 +0100)] 
lscpu: cleanup -e

* keep one sharedmap per cache instance
* initialize topology IDs to -1
* rewrite -e code to use a new data structs

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: add extra caches to --cache output
Karel Zak [Thu, 29 Oct 2020 08:54:44 +0000 (09:54 +0100)] 
lscpu: add extra caches to --cache output

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: cleanup --cache
Karel Zak [Tue, 27 Oct 2020 11:43:37 +0000 (12:43 +0100)] 
lscpu: cleanup --cache

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: split output to sections
Karel Zak [Tue, 27 Oct 2020 10:18:49 +0000 (11:18 +0100)] 
lscpu: split output to sections

Let's make it more readable for humans.

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: add sections
Karel Zak [Mon, 14 Sep 2020 08:49:07 +0000 (10:49 +0200)] 
lscpu: add sections

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: add rest of summary
Karel Zak [Fri, 4 Sep 2020 09:37:21 +0000 (11:37 +0200)] 
lscpu: add rest of summary

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: keep static/dynamic MHz in cputype struct
Karel Zak [Fri, 4 Sep 2020 09:27:33 +0000 (11:27 +0200)] 
lscpu: keep static/dynamic MHz in cputype struct

The Dynamic and Static MHz are /proc/cpuinfo s390 per-CPU fields, but
we display it as a single value according the first parsed CPU. For
this purpose we store the values from the first CPU in lscpu_cputype.

For -p and -e outputs we will print per CPU values.

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: add another part of summary output
Karel Zak [Thu, 3 Sep 2020 14:32:37 +0000 (16:32 +0200)] 
lscpu: add another part of summary output

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: add functions to get CPU freq
Karel Zak [Thu, 3 Sep 2020 14:31:59 +0000 (16:31 +0200)] 
lscpu: add functions to get CPU freq

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: fix NUMAs reading code
Karel Zak [Thu, 3 Sep 2020 11:00:11 +0000 (13:00 +0200)] 
lscpu: fix NUMAs reading code

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: add per type summary function
Karel Zak [Mon, 31 Aug 2020 14:05:39 +0000 (16:05 +0200)] 
lscpu: add per type summary function

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: use size_t for counters
Karel Zak [Mon, 31 Aug 2020 14:05:18 +0000 (16:05 +0200)] 
lscpu: use size_t for counters

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: print generic part of the summary
Karel Zak [Fri, 28 Aug 2020 10:55:01 +0000 (12:55 +0200)] 
lscpu: print generic part of the summary

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: add setsize to lscpu context
Karel Zak [Fri, 21 Aug 2020 10:21:43 +0000 (12:21 +0200)] 
lscpu: add setsize to lscpu context

Don't recalculate again and again setsize from maxcpus.

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: add function to count caches size
Karel Zak [Fri, 21 Aug 2020 08:34:28 +0000 (10:34 +0200)] 
lscpu: add function to count caches size

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: use cache ID, keep caches independent on CPU type
Karel Zak [Thu, 20 Aug 2020 10:28:52 +0000 (12:28 +0200)] 
lscpu: use cache ID, keep caches independent on CPU type

The cache is identified by Type, Level and ID, the ID is unique cache
instance identifier (of the type).

This changes forces lscpu allocate more lscpu_cache instances (than
old version), but now we're ready for arbitrary scenario where
different CPU types share caches and the same cache type uses
different size in different instances, etc.

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: use new code to read CPUs info
Karel Zak [Wed, 19 Aug 2020 13:43:55 +0000 (15:43 +0200)] 
lscpu: use new code to read CPUs info

and remove test program from lscpu-cputype.c.

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: convert getopt block to new API
Karel Zak [Wed, 19 Aug 2020 13:20:02 +0000 (15:20 +0200)] 
lscpu: convert getopt block to new API

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: add LSCPU_OUTPUT_ enum
Karel Zak [Wed, 19 Aug 2020 13:10:38 +0000 (15:10 +0200)] 
lscpu: add LSCPU_OUTPUT_ enum

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: move to main function to init context
Karel Zak [Wed, 19 Aug 2020 11:08:44 +0000 (13:08 +0200)] 
lscpu: move to main function to init context

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: move debug initialization to main
Karel Zak [Wed, 19 Aug 2020 11:01:37 +0000 (13:01 +0200)] 
lscpu: move debug initialization to main

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: merge new API to lscpu.h
Karel Zak [Wed, 19 Aug 2020 10:56:22 +0000 (12:56 +0200)] 
lscpu: merge new API to lscpu.h

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: use constants from new API
Karel Zak [Wed, 19 Aug 2020 10:53:01 +0000 (12:53 +0200)] 
lscpu: use constants from new API

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: remove obsolete code
Karel Zak [Wed, 19 Aug 2020 10:43:48 +0000 (12:43 +0200)] 
lscpu: remove obsolete code

This is the first step in conversion from old lscpu to the new code.
The patch removes obsolete code from lscpu.c and lscpu.h. The old
output code in lscpu.c is temporary disabled by #ifdef due to
incompatibility between old and new internal APIs -- this will be
changed later by small steps to make all all the changes review-able.

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: (virt) add macros for VMWARE
Karel Zak [Wed, 19 Aug 2020 09:40:59 +0000 (11:40 +0200)] 
lscpu: (virt) add macros for VMWARE

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: (topology) read caches from /sys
Karel Zak [Tue, 18 Aug 2020 10:48:41 +0000 (12:48 +0200)] 
lscpu: (topology) read caches from /sys

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: sort extra caches
Karel Zak [Mon, 17 Aug 2020 13:01:54 +0000 (15:01 +0200)] 
lscpu: sort extra caches

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: improve debug message
Karel Zak [Mon, 17 Aug 2020 12:57:22 +0000 (14:57 +0200)] 
lscpu: improve debug message

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: remove unused function
Karel Zak [Mon, 17 Aug 2020 12:54:40 +0000 (14:54 +0200)] 
lscpu: remove unused function

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu; (cpuinfo) parse caches
Karel Zak [Mon, 17 Aug 2020 12:52:49 +0000 (14:52 +0200)] 
lscpu; (cpuinfo) parse caches

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: (topology) add read_mhz()
Karel Zak [Fri, 14 Aug 2020 10:30:18 +0000 (12:30 +0200)] 
lscpu: (topology) add read_mhz()

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: (topology) add read_configure()
Karel Zak [Fri, 14 Aug 2020 10:13:38 +0000 (12:13 +0200)] 
lscpu: (topology) add read_configure()

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: (topology) add read_address()
Karel Zak [Fri, 14 Aug 2020 10:10:26 +0000 (12:10 +0200)] 
lscpu: (topology) add read_address()

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: hide all to lscpu_read_topology()
Karel Zak [Fri, 14 Aug 2020 10:07:18 +0000 (12:07 +0200)] 
lscpu: hide all to lscpu_read_topology()

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: (virt) simplify hypervisor parsing
Karel Zak [Tue, 21 Jul 2020 10:17:32 +0000 (12:17 +0200)] 
lscpu: (virt) simplify hypervisor parsing

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolib/strutils: add normalize_whitespace()
Karel Zak [Tue, 21 Jul 2020 10:16:40 +0000 (12:16 +0200)] 
lib/strutils: add normalize_whitespace()

This function removes extra whitespace.

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: (cpuinfo) rewrite parser
Karel Zak [Mon, 20 Jul 2020 20:05:43 +0000 (22:05 +0200)] 
lscpu: (cpuinfo) rewrite parser

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: (cpuinfo) fill empty cputype
Karel Zak [Mon, 20 Jul 2020 13:43:33 +0000 (15:43 +0200)] 
lscpu: (cpuinfo) fill empty cputype

Don't introduce a new CPU-type if the current is empty.

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: new cpuinfo parser
Karel Zak [Fri, 17 Jul 2020 14:21:04 +0000 (16:21 +0200)] 
lscpu: new cpuinfo parser

* extendable by new patterns
* simple semantic
* the same code for all pattern types

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: keep hypervisor name in allocated memory
Karel Zak [Fri, 17 Jul 2020 14:15:02 +0000 (16:15 +0200)] 
lscpu: keep hypervisor name in allocated memory

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: temporary commit
Karel Zak [Fri, 17 Jul 2020 08:39:05 +0000 (10:39 +0200)] 
lscpu: temporary commit

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: improve topology calculation, use /proc/sysinfo
Karel Zak [Thu, 16 Jul 2020 12:58:37 +0000 (14:58 +0200)] 
lscpu: improve topology calculation, use /proc/sysinfo

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: support s390 cpuinfo processor-pre-line format
Karel Zak [Thu, 16 Jul 2020 11:27:13 +0000 (13:27 +0200)] 
lscpu: support s390 cpuinfo processor-pre-line format

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolsblk: add lscpu_read_topology_polarization()
Karel Zak [Thu, 16 Jul 2020 10:41:35 +0000 (12:41 +0200)] 
lsblk: add lscpu_read_topology_polarization()

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: move topology stuff to separate file
Karel Zak [Thu, 16 Jul 2020 09:32:18 +0000 (11:32 +0200)] 
lscpu: move topology stuff to separate file

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: improve topology debug message
Karel Zak [Thu, 16 Jul 2020 09:13:09 +0000 (11:13 +0200)] 
lscpu: improve topology debug message

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: calculate threads number from type specific values
Karel Zak [Thu, 16 Jul 2020 08:51:14 +0000 (10:51 +0200)] 
lscpu: calculate threads number from type specific values

Don't use global CPU masks (like "online" or "present") to
calculate type specific number of threads due systems with
mixed CPU types.

It's also necessary to check all thread_siblings maps to get the
highest number, because some threads (CPUs) may be disables, for
example old lscpu calculates number of threads from the cpu0 and
if you disable cpu0's sibling (cpu4):

CPU(s):                          8
On-line CPU(s) list:             0-7
Thread(s) per core:              2        <---
Core(s) per socket:              4
Socket(s):                       1

 # chcpu --disable 4
 CPU 4 disabled

CPU(s):                          8
On-line CPU(s) list:             0-3,5-7
Off-line CPU(s) list:            4
Thread(s) per core:              1        <--- !
Core(s) per socket:              4
Socket(s):                       1

because 'thread_siblings' contains only one thread for cpu0:

 # cat /sys/devices/system/cpu/cpu{0,1,2,3,4,5,6,7}/topology/thread_siblings_list
 0
 1,5
 2,6
 3,7
 cat: /sys/devices/system/cpu/cpu4/topology/thread_siblings_list: No such file or directory
 1,5
 2,6
 3,7

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: deallocate maps
Karel Zak [Wed, 15 Jul 2020 16:05:15 +0000 (18:05 +0200)] 
lscpu: deallocate maps

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: add lscpu_read_topolgy_ids()
Karel Zak [Wed, 15 Jul 2020 14:25:15 +0000 (16:25 +0200)] 
lscpu: add lscpu_read_topolgy_ids()

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: add lscpu_read_topology()
Karel Zak [Wed, 15 Jul 2020 14:21:26 +0000 (16:21 +0200)] 
lscpu: add lscpu_read_topology()

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: add lscpu_cpus_loopup_by_type(), improve readability
Karel Zak [Wed, 15 Jul 2020 11:07:15 +0000 (13:07 +0200)] 
lscpu: add lscpu_cpus_loopup_by_type(), improve readability

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: convert ARM decoding to new API
Karel Zak [Thu, 14 May 2020 13:20:52 +0000 (15:20 +0200)] 
lscpu: convert ARM decoding to new API

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: cleaup arch freeing
Karel Zak [Thu, 14 May 2020 10:02:44 +0000 (12:02 +0200)] 
lscpu: cleaup arch freeing

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: add lscpu_read_virtualization()
Karel Zak [Thu, 14 May 2020 09:52:49 +0000 (11:52 +0200)] 
lscpu: add lscpu_read_virtualization()

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: add lscpu_read_numas()
Karel Zak [Wed, 13 May 2020 11:33:36 +0000 (13:33 +0200)] 
lscpu: add lscpu_read_numas()

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: fix mem-leak in cpu
Karel Zak [Wed, 13 May 2020 11:33:13 +0000 (13:33 +0200)] 
lscpu: fix mem-leak in cpu

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: add lscpu_read_vulnerabilities()
Karel Zak [Thu, 7 May 2020 13:23:03 +0000 (15:23 +0200)] 
lscpu: add lscpu_read_vulnerabilities()

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: cleanup lscpu_unref_cputype()
Karel Zak [Thu, 7 May 2020 13:08:13 +0000 (15:08 +0200)] 
lscpu: cleanup lscpu_unref_cputype()

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: add lscpu_read_extra()
Karel Zak [Thu, 7 May 2020 13:03:40 +0000 (15:03 +0200)] 
lscpu: add lscpu_read_extra()

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: add lscpu_read_cpulists()
Karel Zak [Thu, 7 May 2020 12:47:24 +0000 (14:47 +0200)] 
lscpu: add lscpu_read_cpulists()

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: add lscpu_read_architecture()
Karel Zak [Thu, 7 May 2020 12:19:39 +0000 (14:19 +0200)] 
lscpu: add lscpu_read_architecture()

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: (cputype) simplify cpuinfo parsing
Karel Zak [Thu, 9 Apr 2020 10:10:43 +0000 (12:10 +0200)] 
lscpu: (cputype) simplify cpuinfo parsing

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: add lscpu_cpu to internal API
Karel Zak [Thu, 9 Apr 2020 08:32:11 +0000 (10:32 +0200)] 
lscpu: add lscpu_cpu to internal API

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: (cputype) move temporary stuff
Karel Zak [Wed, 18 Mar 2020 14:58:53 +0000 (15:58 +0100)] 
lscpu: (cputype) move temporary stuff

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: (cputype) add header file, cleanup patterns code
Karel Zak [Wed, 18 Mar 2020 14:56:20 +0000 (15:56 +0100)] 
lscpu: (cputype) add header file, cleanup patterns code

* move structs definitions to header file
* define set of /proc/cpuinfo parsing patterns for cpu-type and for
  CPUs

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: (cputype) add cpuinfo parser
Karel Zak [Tue, 17 Mar 2020 16:27:51 +0000 (17:27 +0100)] 
lscpu: (cputype) add cpuinfo parser

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoinclude/strutils: make xstrncpy() compatible with over-smart gcc 9
Karel Zak [Tue, 17 Mar 2020 16:24:28 +0000 (17:24 +0100)] 
include/strutils: make xstrncpy() compatible with over-smart gcc 9

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: (cputype) add ref-counting, allocate context
Karel Zak [Tue, 17 Mar 2020 12:41:28 +0000 (13:41 +0100)] 
lscpu: (cputype) add ref-counting, allocate context

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: (cputype) add debug stuff
Karel Zak [Tue, 17 Mar 2020 12:30:05 +0000 (13:30 +0100)] 
lscpu: (cputype) add debug stuff

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: add very basic cputype code
Karel Zak [Tue, 17 Mar 2020 12:12:12 +0000 (13:12 +0100)] 
lscpu: add very basic cputype code

The current lscpu assumes that all CPUs in the system are the same.
Unfortunately this is not true. We need to split all internal CPUs
descriptions to CPU-type and CPU.

This patch add lscpu-cputype.c where will be CPU-type description --
mostly based on /proc/cpuinfo.

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agotests: update JSON outputs
Karel Zak [Thu, 12 Nov 2020 10:40:22 +0000 (11:40 +0100)] 
tests: update JSON outputs

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolib/jsonwrt: use proper output function
Karel Zak [Thu, 12 Nov 2020 10:38:55 +0000 (11:38 +0100)] 
lib/jsonwrt: use proper output function

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolibsmartcols: use lib/jsonwrt.c for JSON
Karel Zak [Thu, 12 Nov 2020 10:21:50 +0000 (11:21 +0100)] 
libsmartcols: use lib/jsonwrt.c for JSON

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolib/jsonwrt: add new functions to write in JSON
Karel Zak [Thu, 12 Nov 2020 10:19:13 +0000 (11:19 +0100)] 
lib/jsonwrt: add new functions to write in JSON

We need JSON formatting stuff also outside libsmartcols.

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolibblkid: udf: add support for unclosed sequential Write-Once media
Pali Rohár [Sun, 8 Nov 2020 13:24:06 +0000 (14:24 +0100)] 
libblkid: udf: add support for unclosed sequential Write-Once media

5 years agolibblkid: udf: add support for multisession via session_offset hint
Pali Rohár [Thu, 5 Nov 2020 18:23:23 +0000 (19:23 +0100)] 
libblkid: udf: add support for multisession via session_offset hint

To read multisession UDF disc it is required to probe VSD and AVDP from the
selected session (specified by session_offset) and then read other volume
descriptors from absolute location specified in AVDP, which is in most
cases in previous session.

So it is required for udf detector to be able to read data from any
location of disc and therefore blkid's --offset argument cannot be used to
access multisession optical disc.

Only blkid's --hint session_offset argument can be used to instruct blkid
to read multisession optical disc or disc images correctly.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
5 years agolibblkid: iso9660: add support for multisession via session_offset hint
Pali Rohár [Thu, 5 Nov 2020 18:22:58 +0000 (19:22 +0100)] 
libblkid: iso9660: add support for multisession via session_offset hint

The only required change is to read disc from offset specified by
session_offset instead of beginning of disc (offset 0).

So either blkid's --offset or --hint session_offset argument would work for
correct detection of multisession ISO9660 optical disc or disc image.

Although the ISO9660 specification allows also non-2kB sector sizes,
current blkid implementation has hardcoded ISO9660 sector size to 2kB.
Therefore there is check that session_offset is multiple of 2048.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
5 years agolibblkid: fix blkid_probe_get_sb() to use hint offset calculation
Pali Rohár [Sun, 8 Nov 2020 00:51:28 +0000 (01:51 +0100)] 
libblkid: fix blkid_probe_get_sb() to use hint offset calculation

5 years agolibblkid: allow to specify offset defined by hint for blkid_probe_get_idmag()
Pali Rohár [Thu, 5 Nov 2020 18:22:22 +0000 (19:22 +0100)] 
libblkid: allow to specify offset defined by hint for blkid_probe_get_idmag()

Extends struct blkid_idmag with a new member hoff which specify name of the
hint used for blkid_probe_get_hint() function to retrieve offset to kboff.

blkid_probe_get_idmag() will use supplied hint offset in bytes as a start
position from which the final offsets for magic strings are calculated.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
5 years agolibblkid: detect session_offset hint for optical discs
Pali Rohár [Thu, 5 Nov 2020 18:21:15 +0000 (19:21 +0100)] 
libblkid: detect session_offset hint for optical discs

When offset and session_offset hint are not specified then sets
session_offset hint from CDROMMULTISESSION ioctl which returns start
position of the last session of multisession optical disc.

It is expected that session_offset hint contains position offset in bytes
where starts session of multisession optical disc which should be read.

Filesystems designed for optical discs are expected to use this value when
dealing with multisession optical disc to know where they should start
reading optical disc or image of optical disc.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
5 years agolibblkid: do size correction of optical discs also by last written sector
Pali Rohár [Thu, 5 Nov 2020 18:18:26 +0000 (19:18 +0100)] 
libblkid: do size correction of optical discs also by last written sector

Everything after last written sector is undefined.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
5 years agolibblkid: detect CD/DVD discs in packet writing mode
Pali Rohár [Thu, 5 Nov 2020 18:16:27 +0000 (19:16 +0100)] 
libblkid: detect CD/DVD discs in packet writing mode

Packet writing mode for CD and DVD discs is provided by kernel module
pktcdvd.ko which exports block devices /dev/pktcdvd/pktcdvd*.

These block devices do not accept CDROM_DRIVE_STATUS ioctl, therefore
current blkid code does not detect them as BLKID_FL_CDROM_DEV and also
does not do necessary size correction.

Extend detection of CD/DVD discs by additional CDROM_LAST_WRITTEN ioctl
which is accepted also by pktcdvd.ko.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
5 years agoMerge branch 'libblkid' of https://github.com/ferivoz/util-linux
Karel Zak [Tue, 10 Nov 2020 12:37:30 +0000 (13:37 +0100)] 
Merge branch 'libblkid' of https://github.com/ferivoz/util-linux

5 years agotests: (ul) remove another 'dim' input
Karel Zak [Tue, 10 Nov 2020 12:36:32 +0000 (13:36 +0100)] 
tests: (ul) remove another 'dim' input

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolibblkid: limit amount of parsed partitions
Samanta Navarro [Tue, 10 Nov 2020 10:48:04 +0000 (11:48 +0100)] 
libblkid: limit amount of parsed partitions

The linux kernel does not support more than 256 partitions
(DISK_MAX_PARTS). The atari and mac block devices have no such limits.

Use dos logical partition limit for atari as well (100).
Use the kernel limit for mac (256).

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>