]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
4 years agolibblkid: udf: add support for APPLICATION_ID
Pali Rohár [Sat, 5 Dec 2020 19:43:22 +0000 (20:43 +0100)] 
libblkid: udf: add support for APPLICATION_ID

iso9660 superblock code already sets APPLICATION_ID to Application
Identifier from ISO9660 Supplementary Volume Descriptor.

In udf similar meaning has Application Identifier from UDF Primary Volume
Descriptor. Therefore exports it as APPLICATION_ID label.

More tools for generating hybrid ISO+UDF images (e.g. genisoimage, mkisofs
or nero) set Application Identifier in UDF Primary Volume Descriptor to
just empty string. But they set Implementation Identifier in UDF Primary
Volume Descriptor to their tool name.

So if Application Identifier is empty then exports Implementation
Identifier as APPLICATION_ID label.

Please note that Application Identifier and Implementation Identifier are
stored in UDF only in ASCII, not UNICODE.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agolibblkid: udf: check that dstrings are encoded in OSTA Compressed Unicode
Pali Rohár [Sat, 5 Dec 2020 19:39:35 +0000 (20:39 +0100)] 
libblkid: udf: check that dstrings are encoded in OSTA Compressed Unicode

dstring structures are in UL_ENCODE_LATIN1/UL_ENCODE_UTF16BE encodings only
when corresponding desc_charset structures are set to the OSTA Compressed
Unicode. So add missing checks.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agoMerge branch 'col-bug1198' of https://github.com/kerolasa/util-linux
Karel Zak [Thu, 3 Dec 2020 14:09:19 +0000 (15:09 +0100)] 
Merge branch 'col-bug1198' of https://github.com/kerolasa/util-linux

* 'col-bug1198' of https://github.com/kerolasa/util-linux:
  col: make input to tolerate invalid wide characters

4 years agolibsmartcols: sanitize variable names on export output
Karel Zak [Thu, 3 Dec 2020 11:14:10 +0000 (12:14 +0100)] 
libsmartcols: sanitize variable names on export output

The shells are very restrictive about variable names, only [:alnum:]
chars are allowed (and alphabetic chars as the first char).  The
library will replace "bad" chars with "_". The char '%' at the end is
replaced by _PCT.

Addresses: https://github.com/karelzak/util-linux/issues/1201
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agocol: make input to tolerate invalid wide characters
Sami Kerola [Thu, 26 Nov 2020 22:01:39 +0000 (22:01 +0000)] 
col: make input to tolerate invalid wide characters

The getwchar(3) will choke and exit if invalid character is encountered.
This change will make col(1) to print broken multibyte characters as
\x{hex} string.

Reported-by: Vitaly Lipatov <lav@etersoft.ru>
Addresses: https://github.com/karelzak/util-linux/issues/1198
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agoMerge branch 'dankamongmen/libblkid-manual-fix' of https://github.com/dankamongmen...
Karel Zak [Wed, 2 Dec 2020 11:06:25 +0000 (12:06 +0100)] 
Merge branch 'dankamongmen/libblkid-manual-fix' of https://github.com/dankamongmen/util-linux

4 years agotravis: disable OSX for now
Karel Zak [Tue, 1 Dec 2020 10:44:09 +0000 (11:44 +0100)] 
travis: disable OSX for now

For weeks we have a problem with timeout on OSX on travis, not sure
how to fix it ... volunteer wanted :-)

 ==> ./bootstrap --prefix=/usr/local/Cellar/cmake/3.19.1 --no-system-libs --paral
 ==> make

 No output has been received in the last 10m0s, this potentially indicates a stalled build or something wrong with the build itself.
 Check the details on how to adjust your build configuration on: https://docs.travis-ci.com/user/common-build-problems/#Build-times-out-because-no-output-was-received

 The build has been terminated

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agofuzzers: make tests setup more robust
Karel Zak [Tue, 1 Dec 2020 10:35:02 +0000 (11:35 +0100)] 
fuzzers: make tests setup more robust

- use robust functions like write_all()
- don't use assert() to check write/open/etc return values, because oss-fuzz.com
  report foreign (system, libc, ...) issues as our fails

Addresses: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28009
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: (blkid) add support for multisession images
Karel Zak [Mon, 30 Nov 2020 09:33:20 +0000 (10:33 +0100)] 
tests: (blkid) add support for multisession images

This commit adds support for multisession filesystem images to
standard low-probe blkid tests. The expected image name is

 <name>-multi-<offset>[-<offset> ...][-<something>].img

For example:
  iso-multi-0-174-348-genisoimage.img.xz

triggers three sub-tests:
  : iso-multi-genisoimage-0     ... OK
  : iso-multi-genisoimage-174   ... OK
  : iso-multi-genisoimage-348   ... OK

Addresses: https://github.com/karelzak/util-linux/issues/1161
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibblkid: fix some typos in function comments
nick black [Fri, 27 Nov 2020 03:52:20 +0000 (22:52 -0500)] 
libblkid: fix some typos in function comments

4 years agolibblkid: initialize magic strings in robust way
Karel Zak [Wed, 25 Nov 2020 14:45:23 +0000 (15:45 +0100)] 
libblkid: initialize magic strings in robust way

It is the worst habit to depend on the order of the members of the
structure ...

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge remote-tracking branch 'pali/multisesssion'
Karel Zak [Wed, 25 Nov 2020 13:48:30 +0000 (14:48 +0100)] 
Merge remote-tracking branch 'pali/multisesssion'

* pali/multisesssion:
  libblkid: udf: add support for unclosed sequential Write-Once media
  libblkid: udf: add support for multisession via session_offset hint
  libblkid: iso9660: add support for multisession via session_offset hint
  libblkid: fix blkid_probe_get_sb() to use hint offset calculation
  libblkid: allow to specify offset defined by hint for blkid_probe_get_idmag()
  libblkid: detect session_offset hint for optical discs
  libblkid: do size correction of optical discs also by last written sector
  libblkid: detect CD/DVD discs in packet writing mode
  libblkid: overwrite existing hint
  libblkid: export blkid_probe_reset_hints()
  blkid: add --hint <name>=value
  libblkid: add blkid_probe_{set,get}_hint()

4 years agolslogins: call close() for usable FD [coverity scan]
Karel Zak [Wed, 25 Nov 2020 13:02:11 +0000 (14:02 +0100)] 
lslogins: call close() for usable FD [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge remote-tracking branch 'sami/uuidd-work'
Karel Zak [Tue, 24 Nov 2020 12:12:22 +0000 (13:12 +0100)] 
Merge remote-tracking branch 'sami/uuidd-work'

* sami/uuidd-work:
  uuidd: fix misleading indentation
  uuidd: make timeout to take effect when debug is not defined
  uuidd: remove unnecessary bulk request size limit
  uuidd: add uuidd specific data types that are used in protocol
  uuidd: reorder bulk time and random generation code
  uuidd: document uuidd protocol
  uuidd: override operation type when performing bulk request
  uuidd: move option parsing to separate function
  uuidd: add command-line option values struct
  uuidd: use pid_t type when referring to process id

4 years agobuild-sys: do not use extra subdir for getopt examples
Karel Zak [Tue, 24 Nov 2020 11:46:03 +0000 (12:46 +0100)] 
build-sys: do not use extra subdir for getopt examples

This is unnecessary, we have ${docsdir}/util-linux which is good
enough for these two getopt examples. I guess the "getopt"
subdirectory is legacy from time getopt has been merged into
util-linux.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotravis: try update to xcode10.1
Karel Zak [Tue, 24 Nov 2020 10:31:45 +0000 (11:31 +0100)] 
travis: try update to xcode10.1

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolsblk: add dependence between CD/DVD block and packet devices
Karel Zak [Mon, 23 Nov 2020 14:16:39 +0000 (15:16 +0100)] 
lsblk: add dependence between CD/DVD block and packet devices

This dependence is defined by

  $ cat /sys/class/pktcdvd/device_map
  pktcdvd0 252:0 11:0

Unfortunately, there is not any direct sysfs way how to refer this
relationship in /sys/{block,dev/block}. So, we have to read the
device_map file and then compare device numbers with the list.

$ lsblk /dev/sr0
NAME       MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sr0         11:0    1 1024M  0 rom
└─pktcdvd0 252:0    1    0B  0 disk

Addresses: https://github.com/karelzak/util-linux/issues/1185
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agouuidd: fix misleading indentation
Sami Kerola [Sat, 21 Nov 2020 22:16:48 +0000 (22:16 +0000)] 
uuidd: fix misleading indentation

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agouuidd: make timeout to take effect when debug is not defined
Sami Kerola [Sat, 21 Nov 2020 22:12:36 +0000 (22:12 +0000)] 
uuidd: make timeout to take effect when debug is not defined

The trailing comma made code to compile without issues, but meant all_done()
was called only when --debug was in defined in command-line.

Fixes: 3d6250e96b0041a3cbe2f8dd3e746cca5d6ac121
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agouuidd: remove unnecessary bulk request size limit
Sami Kerola [Sat, 21 Nov 2020 21:24:10 +0000 (21:24 +0000)] 
uuidd: remove unnecessary bulk request size limit

Limiting random query to 1000 uuid's was pointless when the next line will
further restrict upper limit to 63 entries.  The 63 entries is what fits to
the uuidd communication buffer with the header.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agouuidd: add uuidd specific data types that are used in protocol
Sami Kerola [Sat, 21 Nov 2020 16:57:43 +0000 (16:57 +0000)] 
uuidd: add uuidd specific data types that are used in protocol

Use a typedef for types that are sensitive what comes to uuidd protocol
field widths, read write sizes, and related checks.

Proposed-by: Karel Zak <kzak@redhat.com>
Reference: https://github.com/karelzak/util-linux/pull/1196#discussion_r528595794
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agouuidd: reorder bulk time and random generation code
Sami Kerola [Sat, 21 Nov 2020 18:13:45 +0000 (18:13 +0000)] 
uuidd: reorder bulk time and random generation code

Write the data and response length values in same close to order they appear
in protocol.  This should make code a little easier to read.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agouuidd: document uuidd protocol
Sami Kerola [Sat, 21 Nov 2020 16:38:58 +0000 (16:38 +0000)] 
uuidd: document uuidd protocol

Seeing what can be expected should make it easier to understand what the
code does.

Notice that simply writing down the resposes one can start wondering deeper
questions, such as, why does the time bulk response reply only one uuid
followed by number how many were requested?  Was that a some type of TODO
note?

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agouuidd: override operation type when performing bulk request
Sami Kerola [Sat, 21 Nov 2020 10:14:17 +0000 (10:14 +0000)] 
uuidd: override operation type when performing bulk request

Relying to single vs bulk requests to be exactly two steps away from each
other was an unnecessary dirty trick.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agouuidd: move option parsing to separate function
Sami Kerola [Fri, 20 Nov 2020 22:27:34 +0000 (22:27 +0000)] 
uuidd: move option parsing to separate function

Moving the option parsing to a separate function will allow moving some
variables from main() heap to be in scope that free them later.  That should
make the uuidd to have a little bit smaller runtime memory allocation.

The static long options is changed to be local variable.  That should make
it to be part of heap for a bit, until removed.  Earlier the variable was in
data segment and permanently in runtime memory.  Whether this makes any
impact either way is not entirely clear, but hope is the runtime memory
allocation is tiny bit smaller.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agouuidd: add command-line option values struct
Sami Kerola [Fri, 20 Nov 2020 22:17:22 +0000 (22:17 +0000)] 
uuidd: add command-line option values struct

The struct will help seeing where the variable values are coming from.  This
will also help upcoming refactoring.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agouuidd: use pid_t type when referring to process id
Sami Kerola [Fri, 20 Nov 2020 22:05:46 +0000 (22:05 +0000)] 
uuidd: use pid_t type when referring to process id

Earlier use of a variable that holds switch enabling boolean to hold process
id was a little bit strange, and not exactly correct.  An int should be good
enough to hold any pid, but it is better to be precise and use the type that
is meant for the job.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agoMerge branch 'master' of https://github.com/pali/util-linux
Karel Zak [Mon, 23 Nov 2020 09:21:17 +0000 (10:21 +0100)] 
Merge branch 'master' of https://github.com/pali/util-linux

* 'master' of https://github.com/pali/util-linux:
  libblkid: drbdmanage: use blkid_probe_strncpy_uuid instead of blkid_probe_set_id_label

4 years agoMerge branch 'privfix' of https://github.com/ericonr/util-linux
Karel Zak [Mon, 23 Nov 2020 09:19:01 +0000 (10:19 +0100)] 
Merge branch 'privfix' of https://github.com/ericonr/util-linux

4 years agolibblkid: drbdmanage: use blkid_probe_strncpy_uuid instead of blkid_probe_set_id_label
Pali Rohár [Sun, 22 Nov 2020 18:44:09 +0000 (19:44 +0100)] 
libblkid: drbdmanage: use blkid_probe_strncpy_uuid instead of blkid_probe_set_id_label

Function blkid_probe_strncpy_uuid() is better suitable for setting UUID
than function blkid_probe_set_id_label().

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agosetpriv: allow using [-+]all for capabilities.
Érico Rolim [Wed, 18 Nov 2020 14:35:26 +0000 (11:35 -0300)] 
setpriv: allow using [-+]all for capabilities.

The initial change to lib/caputils that allowed this was commit
5d95818757941bc609e5aeec5e2218f7d35a6e19, which made it possible to
trust the value returned by cap_last_cap().

The error message was also somewhat misleading, since cap_last_cap()
being smaller than CAP_LAST_CAP happens when setpriv itself is built
with kernel headers older than the currently running kernel, not due to
libcap-ng.

4 years agosetpriv: small clean-up.
Érico Rolim [Fri, 20 Nov 2020 15:33:23 +0000 (12:33 -0300)] 
setpriv: small clean-up.

- Add _() calls for some strings which were missing it.
- In print_caps(), use the same error checking done in
  list_known_caps(); it is expected that libcap-ng will always return a
  string, even if it's only "cap_%d".

4 years agoMerge branch 'w45'
Karel Zak [Fri, 20 Nov 2020 11:01:22 +0000 (12:01 +0100)] 
Merge branch 'w45'

* w45:
  fdformat: remove command from default build
  more: improve error messaging when input file is directory
  ul: make set_column() zero check more obvious
  colrm: fix argument parsing
  rfkill: stop execution when rfkill device cannot be opened
  cifuzz: reindent yaml file
  man: make tilde and caret characters to render correctly

4 years agolib/caputils: split to multiple functions, add test
Karel Zak [Fri, 20 Nov 2020 10:21:41 +0000 (11:21 +0100)] 
lib/caputils: split to multiple functions, add test

Let's split the code to make it possible to test separately bsearch as
well as procfs based cap_last_cap().

 $ ./test_caputils --last-by-bsearch
 last cap: 39
 $ ./test_caputils --last-by-procfs
 last cap: 39
 $ ./test_caputils --last
 last cap: 39

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/procutils: improve proc_is_procfs(), add test
Karel Zak [Fri, 20 Nov 2020 09:38:01 +0000 (10:38 +0100)] 
lib/procutils: improve proc_is_procfs(), add test

* add delay between attempts
* zeroize errno and check for EAGAIN (like in other code)
* add small test program
   ./test_procutils --is-procfs [<dir>]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch 'caps' of https://github.com/ericonr/util-linux
Karel Zak [Fri, 20 Nov 2020 09:21:19 +0000 (10:21 +0100)] 
Merge branch 'caps' of https://github.com/ericonr/util-linux

* 'caps' of https://github.com/ericonr/util-linux:
  lib/caputils: add fall back for last cap using prctl.
  lib/procutils: add proc_is_procfs helper.

4 years agolscpu: show the number of physical socket on aarch64 machine without ACPI PPTT
Masayoshi Mizuma [Fri, 20 Nov 2020 05:06:09 +0000 (00:06 -0500)] 
lscpu: show the number of physical socket on aarch64 machine without ACPI PPTT

Show the number of the number of physical socket even if the sysfs doesn't
have the physical socket information.

Note, lscpu shows the number of physical socket as 'Socket(s):' only if
root user runs it because accessing the DMI table requires root
privilege.

Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
4 years agolscpu: add helper to get physical sockets
Masayoshi Mizuma [Fri, 20 Nov 2020 05:06:08 +0000 (00:06 -0500)] 
lscpu: add helper to get physical sockets

Add a helper function, get_number_of_physical_sockets_from_dmi(),
to get physical sockets from DMI table in case of the sysfs for
cpu topology doesn't have the physical socket information.

get_number_of_physical_sockets_from_dmi() parse the DMI table
and counts the number of SMBIOS Processor Information (Type04)
structure.

Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
4 years agolscpu-dmi: Move some functions related to DMI to lscpu-dmi
Masayoshi Mizuma [Fri, 20 Nov 2020 05:06:07 +0000 (00:06 -0500)] 
lscpu-dmi: Move some functions related to DMI to lscpu-dmi

Move some functions related to DMI to lscpu-dmi.

Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
4 years agolscpu-virt: split hypervisor_from_dmi_table()
Masayoshi Mizuma [Fri, 20 Nov 2020 05:06:06 +0000 (00:06 -0500)] 
lscpu-virt: split hypervisor_from_dmi_table()

Split hypervisor_from_dmi_table() to parsing dmi table and checking the
hypervisor vendor.

Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
4 years agolscpu: use cluster on aarch64 machine which doesn't have ACPI PPTT
Masayoshi Mizuma [Fri, 20 Nov 2020 05:06:05 +0000 (00:06 -0500)] 
lscpu: use cluster on aarch64 machine which doesn't have ACPI PPTT

lscpu may show the wrong number of sockets if the machine is aarch64 and
doesn't have ACPI PPTT.

That's because lscpu shows the number of sockets by using a sysfs entry
(cpu/cpuX/topology/core_siblings). The sysfs entry is set by MPIDR_EL1
register if the machine doesn't have ACPI PPTT. MPIDR_EL1 doesn't show
the physical socket information directly. It shows the affinity level.

According to linux/arch/arm64/kernel/topology.c:store_cpu_topology(),
the top level of affinity is called as 'Cluster'.

Use Cluster instead of Socket on the machine which doesn't have ACPI PPTT.

This patch is useful for aarch64 machine which is based on ARM
SBBR v1.0 and v1.1, the specs don't require ACPI PPTT. ARM SBBR v1.2
requires ACPI PPTT.

Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
4 years agolib/signames: change license to public domain
Karel Zak [Thu, 19 Nov 2020 11:04:08 +0000 (12:04 +0100)] 
lib/signames: change license to public domain

The file is simple list of signal names and trivial function to search
in the list. We do not need any extra license here and as public
domain it will be more portable to other tools (GPL and BSD) in the
util-linux.

All previous contributors (Sami, Niklas and me) agree with this change.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: fix resource leak [coverity scan]
Karel Zak [Thu, 19 Nov 2020 11:00:58 +0000 (12:00 +0100)] 
lscpu: fix resource leak [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: fix possible null dereferences [coverity scan]
Karel Zak [Thu, 19 Nov 2020 10:57:19 +0000 (11:57 +0100)] 
lscpu: fix possible null dereferences [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoumount: ignore --no-canonicalize,-c for non-root users
Karel Zak [Thu, 19 Nov 2020 10:12:06 +0000 (11:12 +0100)] 
umount: ignore --no-canonicalize,-c for non-root users

It seems better to ignore this option than drop-permissions and later
exit with EPERMs. This change makes umount(8) more compatible with
fuser user umounts by systemd where -c is used to reduce overhead etc.

Addresses: https://github.com/karelzak/util-linux/issues/1192
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibmount: don't use "symfollow" for helpers on user mounts
Karel Zak [Thu, 19 Nov 2020 08:49:16 +0000 (09:49 +0100)] 
libmount: don't use "symfollow" for helpers on user mounts

Addresses: https://github.com/karelzak/util-linux/issues/1193
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/caputils: add fall back for last cap using prctl.
Érico Rolim [Sun, 15 Nov 2020 04:34:41 +0000 (01:34 -0300)] 
lib/caputils: add fall back for last cap using prctl.

This allows the rest of the programs using cap_last_cap to trust the
value returned by it, since it will either be obtained from procfs
(straight from kernel) or with prctl.

Also checked if the file under /proc is actually mounted in a procfs.

4 years agolib/procutils: add proc_is_procfs helper.
Érico Rolim [Wed, 18 Nov 2020 17:07:10 +0000 (14:07 -0300)] 
lib/procutils: add proc_is_procfs helper.

Also add missing include in procutils.h for the definition of pid_t.

4 years agoMerge branch 'hwclock-syscall-nr' of https://github.com/pinotree/util-linux
Karel Zak [Wed, 18 Nov 2020 09:32:39 +0000 (10:32 +0100)] 
Merge branch 'hwclock-syscall-nr' of https://github.com/pinotree/util-linux

* 'hwclock-syscall-nr' of https://github.com/pinotree/util-linux:
  hwclock: do not assume __NR_settimeofday_time32

4 years agohwclock: do not assume __NR_settimeofday_time32
Pino Toscano [Tue, 17 Nov 2020 10:32:45 +0000 (11:32 +0100)] 
hwclock: do not assume __NR_settimeofday_time32

Check that __NR_settimeofday_time32 exists before trying to use it as
syscall number.

Signed-off-by: Pino Toscano <toscano.pino@tiscali.it>
4 years agobuild-sys: do not build plymouth-ctrl.c w/ disabled plymouth
Pino Toscano [Tue, 17 Nov 2020 10:27:48 +0000 (11:27 +0100)] 
build-sys: do not build plymouth-ctrl.c w/ disabled plymouth

Do not build plymouth-ctrl.c in agetty and sulogin in case the plymouth
support is disabled.

Signed-off-by: Pino Toscano <toscano.pino@tiscali.it>
4 years agolscpu-virt: fix return type of read_hypervisor_cpuid for non x86.
Érico Rolim [Sun, 15 Nov 2020 14:53:39 +0000 (11:53 -0300)] 
lscpu-virt: fix return type of read_hypervisor_cpuid for non x86.

4 years agofdformat: remove command from default build
Sami Kerola [Wed, 11 Nov 2020 21:10:32 +0000 (21:10 +0000)] 
fdformat: remove command from default build

It should be safe assumption a command related to floppy disks does not
need to be part of default build.  Notice that the reference commit removed
floppy driver from linux about year ago.  Virtual floppies might exist they
should not need low-level formatting.  But if someone really needs this
enabling the build in that case is better than pushing the binary by
default to many many systems that install util-linux.

Reference: https://github.com/torvalds/linux/commit/47d6a7607443ea43dbc4d0f371bf773540a8f8f4
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agomore: improve error messaging when input file is directory
Sami Kerola [Wed, 11 Nov 2020 20:41:17 +0000 (20:41 +0000)] 
more: improve error messaging when input file is directory

Before this change the error message about directory was not informative,
and a little bit out of place.

    $ touch empty ; ./more ./empty /
    ::::::::::::::
    ./empty
    ::::::::::::::
    magic failed: cannot read fd 4 (Is a directory)
    ::::::::::::::
    /
    ::::::::::::::

After the change messaging is reverted back to what it used to be.

    $ ./more ./empty /
    ::::::::::::::
    ./empty
    ::::::::::::::

    *** /: directory ***

And while on it lets remove repeated fstat() call.

Fixes: 09070e1a658e70ec203150e4fa5f486b32771858
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agoul: make set_column() zero check more obvious
Sami Kerola [Wed, 21 Oct 2020 20:17:51 +0000 (21:17 +0100)] 
ul: make set_column() zero check more obvious

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agocolrm: fix argument parsing
Sami Kerola [Mon, 19 Oct 2020 20:57:04 +0000 (21:57 +0100)] 
colrm: fix argument parsing

Short options had all sortss of characters listed, that were clearly copied
from col(1) command getopt_long() invocation.  Luckily both -V and -h were
part of the short options, but lets get rid of the unnecessary ones.

Fixes: 1647d032a7bfcba36d3dabe627b858b372210d05
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agorfkill: stop execution when rfkill device cannot be opened
Sami Kerola [Fri, 23 Oct 2020 19:39:24 +0000 (20:39 +0100)] 
rfkill: stop execution when rfkill device cannot be opened

Without this two error messages are printed when rfkill device
cannot be opened.

    $ rfkill
    rfkill: cannot open /dev/rfkill: No such file or directory
    rfkill: cannot read /dev/rfkill: Bad file descriptor

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agocifuzz: reindent yaml file
Sami Kerola [Tue, 1 Sep 2020 19:23:36 +0000 (20:23 +0100)] 
cifuzz: reindent yaml file

Fixex two yamllint indentation warning, the truthy is false positive.

    util-linux $ yamllint ./.github/workflows/cifuzz.yml
      6:1       warning  truthy value should be one of [false, true]  (truthy)
      14:2      error    wrong indentation: expected 2 but found 1  (indentation)
      22:4      error    wrong indentation: expected 5 but found 3  (indentation)

Reference: https://github.com/adrienverge/yamllint
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agoman: make tilde and caret characters to render correctly
Sami Kerola [Sun, 30 Aug 2020 19:02:50 +0000 (20:02 +0100)] 
man: make tilde and caret characters to render correctly

As mentioned in 'Generating optimal glyphs' title in the manual page
mentioned in reference:

    Where a proper caret (^) that renders well in both a terminal and PDF is
    required, use "\(ha".

    Using a naked "~" character results in a poor rendering in PDF.  Instead
    use "\(ti".

Reference: https://man7.org/linux/man-pages/man7/man-pages.7.html#STYLE_GUIDE
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agolscpu: fix memory leaks
Karel Zak [Fri, 13 Nov 2020 09:20:33 +0000 (10:20 +0100)] 
lscpu: fix memory leaks

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu-arm: Add "BIOS Vendor ID" and "BIOS Model name" to show the SMBIOS information.
Masayoshi Mizuma [Fri, 13 Nov 2020 09:06:26 +0000 (10:06 +0100)] 
lscpu-arm: Add "BIOS Vendor ID" and "BIOS Model name" to show the SMBIOS information.

After commit: 367c85c47 ("lscpu: use SMBIOS tables on ARM for lscpu"),
Model name for A64FX shows like as:

   Model name:       461F0010

That's because 367c85c47 changes to get the modelname from Processor
Version of SMBIOS.

To fix that, use the hard corded table to show the "Model name" and
add two new lines; "BIOS Vendor ID" and "BIOS Model name" to show the
SMBIOS information.

lscpu shows the SMBIOS information when root user runs it because
accessing the SMBIOS information requires root privilege.

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

Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: Even more Arm part numbers
Jeremy Linton [Tue, 10 Nov 2020 16:05:04 +0000 (10:05 -0600)] 
lscpu: Even more Arm part numbers

Over the past two years Arm has published further MIDR/part numbers
on https://developer.arm.com/ip-products/processors/cortex-a.

Lets sync the arm_part structure for A65, A76AE, A77 and A78*.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
4 years agolscpu: (arm) reuse parsed vendor ID
Karel Zak [Tue, 10 Nov 2020 12:22:53 +0000 (13:22 +0100)] 
lscpu: (arm) reuse parsed vendor ID

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: remove unused code
Karel Zak [Tue, 10 Nov 2020 12:09:21 +0000 (13:09 +0100)] 
lscpu: remove unused code

lscpu-dmi.c is no more used by new lscpu code.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>