Guixin Liu [Wed, 21 Aug 2024 08:49:54 +0000 (16:49 +0800)]
lscpu: optimize query virt pci device
The lscpu command needs to traverse the /proc/bus/pci/devices file
three times to check for any PCI devices related to virtualization.
If there are many PCI devices on the machine, this can lead to
increased execution time for lscpu. It would be beneficial to
consolidate these queries into a single check to optimize the
execution time of lscpu.
Use time command to test on a machine with 13000 PCI devices:
before:
real 0m13.506s
user 0m0.028s
sys 0m13.409s
after:
real 0m5.834s
user 0m0.018s
sys 0m5.771s
Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
Karel Zak [Thu, 22 Aug 2024 09:31:21 +0000 (11:31 +0200)]
Merge branch 'findmnt-Q' of https://github.com/masatake/util-linux
* 'findmnt-Q' of https://github.com/masatake/util-linux:
tests: (findmnt) add a case testing -Q option
findmnt: (man) write about -Q,--filter option
findmnt: add -Q,--filter option
findmnt: (refactor) convert add_column macro to a function
findmnt: (refactor) add a helper function making an instance of libscols_table
findmnt: (refactor) remove global variables shared between findmnt.c and fintmnt-verify.c
Karel Zak [Thu, 22 Aug 2024 06:56:52 +0000 (08:56 +0200)]
more: make sure we have data on stderr
more(1) uses more_poll() to monitor data on stdin, stderr, and
signals. It is used before read_command(), but this function only
reads from stderr. Therefore, if any other non-stderr event occurs,
this function will wait on read(). In this case, more(1) will not
react to signals anymore. We need to ensure that more(1) only waits in
more_poll().
Try
for x in {1..1000}; do echo "line $x"; done | more
to reproduce.
Reported-by: Radka Skvarilova <rskvaril@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Dmitry V. Levin [Sun, 11 Aug 2024 08:00:00 +0000 (08:00 +0000)]
meson: use a / b instead of join_paths(a, b)
According to [1], since meson 0.49.0, using the / operator on strings
is equivalent to calling join_paths().
As the expressions written using the / operator are shorter and nicer
than their equivalents written using join_paths(), and given that
we've been using this new operator since commit 5f2c862a4aff19f5bc732e677405f04e2d07c211, let's convert remaining
join_paths() invocations to use the / operator instead.
John Keeping [Tue, 6 Aug 2024 17:17:29 +0000 (18:17 +0100)]
libmount: propagate first error of multiple filesystem types
Use the same error handling logic as do_mount_by_pattern() to better
handle the case where EROFS is returned from the first filesystem in a
list but subsequent filesystems overwrite this status with, for example,
ENODEV.
This allows read-only devices to mount without the user needing to
explicitly specify "ro" while specifying a list of potential
filesystems, some of which may not be available.
Signed-off-by: John Keeping <jkeeping@inmusicbrands.com>
John Keeping [Tue, 6 Aug 2024 17:16:00 +0000 (18:16 +0100)]
libmount: extract common error handling function
Extract the logic for whether to continue trying more filesystem types
to a function so that it can be reused to make this consistent between
do_mount_by_pattern() and do_mount_by_types().
Signed-off-by: John Keeping <jkeeping@inmusicbrands.com>
lscpu: Skip aarch64 decode path for rest of the architectures
lscpu behaves differently when run sudo vs non-sudo on AMD architectures.
On sudo runs, it adds a BIOS model name and BIOS CPU family which it
does not add for the latter. However since this parsing from the DMI is
primarily catered to aarch64, for AMD platform the BIOS model name is
printed out as follows "AMD XXX Processor *Unknown* CPU @ X.XGHz" due
to the part number is not populated on the platform.
The issue boils down to an unconditional call to arm_decode() which
attempts to read the DMI path and populate the processor information
such as processor version and part number which is set to Unknown on AMD
CPUs.
81d6de9 (lscpu: remove the old code) changed the DMI path from
/sys/firmware/dmi/entries/4-0/raw (non-existent) to
/sys/firmware/dmi/tables/dmi (existent) which has brought this latent
issue to light as DMI was starting to be parsed incorrectly.
Therefore, do not perform aarch64 parsing for other architectures.
Before
------
$ lscpu
Vendor ID: AuthenticAMD
Model name: AMD EPYC XXXX X-Core Processor
CPU family: 26
$ sudo lscpu
Vendor ID: AuthenticAMD
BIOS Vendor ID: Advanced Micro Devices, Inc.
Model name: AMD EPYC XXXX X-Core Processor
BIOS Model name: AMD EPYC XXXX X-Core Processor Unknown CPU @ X.XGHz
BIOS CPU family: 107
CPU family: 26
After
-----
$ lscpu
Vendor ID: AuthenticAMD
Model name: AMD EPYC XXXX X-Core Processor
CPU family: 26
$ sudo lscpu
Vendor ID: AuthenticAMD
Model name: AMD EPYC XXXX X-Core Processor
CPU family: 26
Fixes: 81d6de9 ("lscpu: remove the old code") Co-developed-by: Karel Zak <kzak@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com> Signed-off-by: Pratik R. Sampat <pratikrajesh.sampat@amd.com>
Stanislav Brabec [Sun, 21 Jul 2024 13:01:42 +0000 (15:01 +0200)]
agetty: Prevent cursor escape
Starting with 5de97519, it is possible to escape the login dialog on the
screen by arrow characters or using escape sequences.
Since full processing of escape sequences and ignore them would be
complicated, use a work around: instead of sending ESC to output, send a
printable character.
It could cause a rendering regression in a very obscure condition: compiled
without IUTF8, encoding is ISO-11548-1 and BRAILLE PATTERN DOTS-1245 is
part of login name. I believe that it is out of supported combinations.
Karel Zak [Mon, 15 Jul 2024 10:15:28 +0000 (12:15 +0200)]
Merge branch 'kill--decode' of https://github.com/masatake/util-linux
* 'kill--decode' of https://github.com/masatake/util-linux:
kill: (test) add a case for testing -l 0xSIGMASK and -d $PID options
kill: add a feature decoding signal masks
The directory can be directly used by libuuid, for example, by running
"uuidgen --time" as root, even if the uuidd daemon is not installed.
In this case, we must create a clock.txt file with the uuidd group to
prevent any potential ownership mismatch if the uuidd daemon is
installed later. The 2xxx mode (setgid) forces open(O_CREAT) in
libuuid to create the file with the uuidd group.
Please note that mode 2755 is the standard used for years in RHEL.
David Gibson [Tue, 9 Jul 2024 05:44:31 +0000 (15:44 +1000)]
unshare: Add options to identity map the user's subordinate uids and gids
--map-users=auto, --map-groups=auto and --map-auto allow automatically
mapping the first block of user or group IDs owned by the effective user
from /etc/sub[ug]id to a block starting at user ID 0. Add options
--map-users=subids, --map-groups=subids and --map-subids to perform a
mapping of the same IDs, but as an identity mapping instead of to UID 0.
This is useful in similar situations to --map-current-user, but preserves
access to the user's subordinate IDs. That allows nested namespaces to
be created with more complex user mappings, either with unshare or with
a container runtime such as podman.
Fixes: https://github.com/util-linux/util-linux/issues/3120 Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
column: Adds option -S <num> so whitespaces are used instead of tabs in non table mode.
Entries are padded with whitespaces, then <num> spaces are added to separate the columns.
This should fix https://github.com/util-linux/util-linux/issues/1551
Karel Zak [Tue, 2 Jul 2024 09:14:06 +0000 (11:14 +0200)]
lib/fileutils: add ul_basename()
Unfortunately, the basename() function can be affected by the
creativity of different libc authors, resulting in varying behavior
across implementations.
Instead, use a local implementation to ensure consistency and
portability.
Karel Zak [Tue, 2 Jul 2024 07:32:19 +0000 (09:32 +0200)]
Merge branch 'automake/install-dependency' of https://github.com/t-8ch/util-linux
* 'automake/install-dependency' of https://github.com/t-8ch/util-linux:
autotools: Properly order install dependencies of pam_lastlog2
autotools: make pam install path configurable
Unfortunately, the behavior is different between DOS (original docs)
and GPT. Due to the need for backward compatibility, it is likely
impossible to change the default setting ...
Addresses: https://github.com/util-linux/util-linux/issues/3097 Signed-off-by: Karel Zak <kzak@redhat.com>
Thomas Weißschuh [Sun, 30 Jun 2024 09:23:53 +0000 (11:23 +0200)]
autotools: Properly order install dependencies of pam_lastlog2
As pam_lastlog2 is relinked during installation, all its dependencies
need to already be installed.
This is the same issue that affected pylibmount which was fixed in
commit 324330aca644 ("build-sys: Properly order install dependencies of pylibmount").
Extend the logic added in that commit to also apply to pam_lastlog2.
Closes: #3011 Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
While at it, also move the initial definition of
usesecurelib_exec_LTLIBRARIES into Makefile.am.
Also add "exec" to the target name which is recognized by automake to
mark the targets as architecture-specific.