Karel Zak [Tue, 10 Dec 2024 11:24:59 +0000 (12:24 +0100)]
Merge branch 'ft-algorithm-params' of https://github.com/LiviaMedeiros/util-linux
* 'ft-algorithm-params' of https://github.com/LiviaMedeiros/util-linux:
zramctl: rename `--params` into `--algorithm-params`
zramctl: add support for `algorithm_params`
Zhaoming Luo [Mon, 9 Dec 2024 11:16:11 +0000 (19:16 +0800)]
hwclock: Support GNU Hurd
* configure.ac: add HURD so it can be used in conditional in am files
* sys-utils/Makemodule.am: compile hwclock for GNU Hurd
* sys-utils/hwclock-rtc.c: compile for GNU Hurd
* sys-utils/hwclock.c: compile for GNU Hurd
* sys-utils/hwclock.h: compile for GNU Hurd
Zhaoming Luo [Mon, 9 Dec 2024 02:11:54 +0000 (10:11 +0800)]
hwclock: Remove ioperm declare as it causes nested extern declare warning
The extern declaration causes the following warning:
```
CC sys-utils/hwclock-hwclock-cmos.o
sys-utils/hwclock-cmos.c: In function 'i386_iopl':
sys-utils/hwclock-cmos.c:356:20: warning: nested extern declaration of 'ioperm' [-Wnested-externs]
356 | extern int ioperm(unsigned long from, unsigned long num, int turn_on);
| ^~~~~~
sys-utils/hwclock-cmos.c:356:20: warning: redundant redeclaration of 'ioperm' [-Wredundant-decls]
In file included from sys-utils/hwclock-cmos.c:68:
/usr/include/i386-gnu/sys/io.h:29:12: note: previous declaration of 'ioperm' with type 'int(long unsigned int, long unsigned int, int)'
29 | extern int ioperm (unsigned long int __from, unsigned long int __num,
| ^~~~~~
CCLD hwclock
```
Karel Zak [Fri, 6 Dec 2024 09:05:25 +0000 (10:05 +0100)]
Merge branch 'posix-argument-order' of https://github.com/nilfsuser5678/util-linux
* 'posix-argument-order' of https://github.com/nilfsuser5678/util-linux:
libmount: exec mount helpers with posixly correct argument order
libmount/context_mount: fix argument number comments
nilfsuser5678 [Fri, 29 Nov 2024 17:27:12 +0000 (17:27 +0000)]
libmount: exec mount helpers with posixly correct argument order
This improves compatibility with non-gnu userspaces.
On systems where the libc provides posix getopt instead of gnu getopt,
mount helpers which use getopt to parse arguments will not parse
options which appear after non-option arguments. This patch ensures
mount/unmount work as expected in this situation.
mount: fix expected argument order for mount helpers in tests
Reads of ext superblocks can race with updates. If libblkid observes a
checksum mismatch, re-read the superblock with O_DIRECT in order to get
a consistent view of its contents. Only if the O_DIRECT read fails the
checksum should it be reported to have failed.
This fixes a problem where devices that were named by filesystem label
failed to be found when systemd attempted to mount them on boot. The
problem was caused by systemd-udevd using libblkid. If a read of a
superblock resulted in a checksum mismatch, udev will remove the
by-label links which result in the mount call failing to find the
device. The checksum mismatch that was triggering the problem was
spurious, and when we use O_DIRECT, or even perform a subsequent retry,
the superblock is correctly read. This resulted in a failure to mount
/boot in one out of every 2,000 or so attempts in our environment.
e2fsprogs fixed[1] an identical version of this bug that afflicted
resize2fs during online grow operations when run from cloud-init. The
fix there was also to use O_DIRECT in order to read the superblock.
This patch uses a similar approach: read the superblock with O_DIRECT in
the case where a bad checksum is detected.
Karel Zak [Mon, 25 Nov 2024 11:38:00 +0000 (12:38 +0100)]
Merge branch 'su-runuser-improvements' of https://github.com/calestyo/util-linux
* 'su-runuser-improvements' of https://github.com/calestyo/util-linux:
man pages: document `--user` option for `runuser`
man pages: use `user` rather than `username`
bash-completion: add `--pty` and `--no-pty` options for `su` and `runuser`
bash-completion: complete `--user` only for `runuser`, not for `su`
Karel Zak [Mon, 25 Nov 2024 11:10:37 +0000 (12:10 +0100)]
zramctl: add COMP-RATIO column
* Improve get_mm_stat() to return both numbers and strings.
* Add get_mm_stat_number() and get_mm_stat_string() functions.
* Add a new COL_COMPRATIO column.
Based on https://github.com/util-linux/util-linux/pull/3293
Co-Author: davidemanini Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Thu, 21 Nov 2024 09:24:07 +0000 (10:24 +0100)]
login,libblkid: use econf_readConfig rather than deprecated econf_readDirs
Fixes:
lib/logindefs.c: In function ‘load_defaults’:
lib/logindefs.c:257:9: warning: ‘econf_readDirs’ is deprecated: Use the econf_readConfig/econf_readConfigWithCallback instead [-Wdeprecated-declarations]
257 | error = econf_readDirs(&file,
| ^~~~~
libblkid/src/config.c: In function 'blkid_read_config':
libblkid/src/config.c:164:17: error: 'econf_readDirs' is deprecated: Use the econf_readConfig/econf_readConfigWithCallback instead [-Werror=deprecated-declarations]
164 | error = econf_readDirs(&file,
| ^~~~~
* check for econf_readConfig() by ./configure and moson
* add UL_VENDORDIR_PATH into pathnames.h to avoid #ifdef in code
* use #ifdef HAVE_ECONF_READCONFIG to switch between econf_readDirs()
and the econf_readConfig()
Bitfields have their uses, but the uses here didn't make any sense.
Code generated to read or write bitfields is more complicated (and
slower) because, well, the bits need to be manipulated with special
instructions. So bitfields should be used when we have a structure
that is repeated hundreds or thousands of times in memory and those
saving are higher than the cost of having more complicated code. This
can happen for example in the kernel code. But the code here has
structures that are instantiated once or or at most few times.
In addition, a bitfield often does not save any memory because of
alignment requirements. In the majority of cases modified here, the
bitfield was the last field in a structure, so no memory savings were
made.
(To be clear: those small savings are not particularly important. The
motivation for this patch is to eradicate the antipattern of making
things more complicated without any benefit.)
Currently, additional locations (such as /run or /usr/lib) are only
read if /etc/issue does not exist. This behavior makes it difficult to use
local settings (/etc) together with generated (/run) and distribution-specific
(/usr/lib) files. Let's read all the locations.
If the output of issue files is unwanted, the option --noissue can be
used, or the default locations can be ignored by using --issue-file
<list>.
Fixes: https://github.com/util-linux/util-linux/issues/3279
Addresses: https://github.com/systemd/systemd/issues/35071 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 19 Nov 2024 10:54:00 +0000 (11:54 +0100)]
libmount: support X-mount.noloop
libmount automatically creates a loop device and mounts it if the
source of the mount is a regular file that contains a well-known
filesystem. However, in some cases, this feature may be unwanted. The
new mount option "X-mount.noloop" forces libmount to use the file
directly as the mount source.
Addresses: https://github.com/util-linux/util-linux/pull/3288 Signed-off-by: Karel Zak <kzak@redhat.com>
With --file, shen the file is created by mkswap, stat() fails with -ENOENT
and the st_mode field is not populated, so the IS_REG() check fails. But if
we created by mkswap, we know it's just a regular file and we should apply
the selinux label.
Reported in https://bugzilla.redhat.com/show_bug.cgi?id=2324811#c56.
Skip tmpfs-sensitive tests if fstype cannot be determined
In certain isolation environments (f.e. Debian's sbuild+unshare),
`/proc/mounts` does not have an entry for the directory we're building in.
Then, findmnt as used in the tests returns nothing. As the build directory
might very well be on tmpfs (and often is, in Debian), disable the two tests
known to fail on tmpfs.
In yet another scenario, if ran in a Docker/podman container, the fstype
will read "overlay", which in the end can also be tmpfs, and we see problems
there, too.
Karel Zak [Fri, 15 Nov 2024 10:53:37 +0000 (11:53 +0100)]
mesg: remove ability to compile with fchmod(S_IWOTH)
The default is to use mesg(1) to modify write access for the "tty"
group, but there is an obscure legacy. If mesg(1) is compiled with the
option "--disable-use-tty-group", then it defaults to using
fchmod(S_IWGRP | S_IWOTH). This means that your tty is then writable
for everyone. Let's get rid of this ugly feature.
Reported-by: Chris Hofstaedtler <zeha@debian.org> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Fri, 15 Nov 2024 10:32:34 +0000 (11:32 +0100)]
meson: add -D tty-setgid=[false|true]
If your distribution does not define permissions for installed
binaries and follows the upstream guidelines, disabling the tty
group's setgid could be a beneficial decision in certain situations.
Karel Zak [Fri, 15 Nov 2024 10:30:17 +0000 (11:30 +0100)]
autotools: add --disable-makeinstall-tty-setgid
If your distribution does not define permissions for installed
binaries and follows the upstream guidelines, disabling the tty
group's setgid could be a beneficial decision in certain situations.
Ameer Hamza [Fri, 4 Oct 2024 16:57:44 +0000 (21:57 +0500)]
libblkid: zfs: Use nvlist for detection instead of Uber blocks
Currently, blkid relies on the presence of Uber blocks to detect ZFS
partition types. However, Uber blocks are not consistently dumped for
cache and spare vdevs, particularly in pools created prior to
https://github.com/openzfs/zfs/commit/d9885b3. Additionally, indirect
vdevs are incorrectly detected by blkid due to the presence of Uber
blocks in the label. ZFS itself does not depend on Uber blocks either
when reading ZFS labels; instead, it parses the nvlist.
This commit aligns blkid's approach with ZFS by parsing the nvlist in
the label to detect ZFS partition types, requiring at least one valid
label for successful detection. This change also ensures compatibility
with wipefs, as it now uses nvlist headers for offsets instead of the
Uber Magic offset. Consequently, running wipefs -a will zero out the
nvlist header in each label, fully removing the ZFS partition type and
making the pool unimportable. Previously, wipefs -a did not clear all
the Uber blocks or delete all nvlist headers, allowing pools to remain
importable even after wiping.
Robin Jarry [Tue, 5 Nov 2024 10:22:06 +0000 (11:22 +0100)]
lsirq,irqtop: add threshold option
Add a new option to filter out IRQs whose counters are below the
specified value. The argument supports plain integers and human readable
values (e.g. 1.2K).
Karel Zak [Wed, 6 Nov 2024 09:18:17 +0000 (10:18 +0100)]
nsenter: improve portability to older kernels
The pidfd cannot be used to enter namespaces using setns() before
Linux 5.7. To ensure compatibility with older kernels, we will check
the kernel version before using pidfd_open() and, if necessary, fall
back to using the classic /proc/#/ns/ files.
Reported-by: Alex Xu Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 5 Nov 2024 10:17:10 +0000 (11:17 +0100)]
Merge branch 'PR/nsenter-pidfd' of https://github.com/karelzak/util-linux-work
* 'PR/nsenter-pidfd' of https://github.com/karelzak/util-linux-work:
nsenter: Rewrite --user-parent to use pidfd
include/pidfd-utils: add namespaces ioctls
nsenter: reuse pidfd for --net-socket
nsenter: use macros to access the nsfiles array
nsenter: use pidfd to enter target namespaces
nsenter: use separate function to enter namespaces
nsenter: add functions to enable/disable namespaces
Karel Zak [Tue, 5 Nov 2024 10:10:31 +0000 (11:10 +0100)]
libsmartcols: make __attributes__ more portable
Let's use what is already used for libmount. The header file is a public
header and does not require support for the __attribute__() compiler
feature. We need an additional #ifdef to ensure portability.
Karel Zak [Tue, 5 Nov 2024 10:08:26 +0000 (11:08 +0100)]
Merge branch 'smartcols-printf' of https://github.com/rjarry/util-linux
* 'smartcols-printf' of https://github.com/rjarry/util-linux:
treewide: use scols printf api where possible
libsmartcols: add printf api to fill in column data
Karel Zak [Tue, 5 Nov 2024 10:00:11 +0000 (11:00 +0100)]
Merge branch 'mkfds--minor-fixes' of https://github.com/masatake/util-linux
* 'mkfds--minor-fixes' of https://github.com/masatake/util-linux:
tests: (test_mkfds::make-regular-file) fix the default union member for \"readable\" parameter
test_mkfds: reserve file descriptors in the early stage of execution
Anjali K [Mon, 4 Nov 2024 06:32:26 +0000 (12:02 +0530)]
lscpu: fix incorrect number of sockets during hotplug
lscpu sometimes shows incorrect 'Socket(s)' value if a hotplug operation
is running.
On a 32 CPU 2-socket system, the expected output is as shown below:
Architecture: ppc64le
Byte Order: Little Endian
CPU(s): 32
On-line CPU(s) list: 0-31
Model name: POWER10 (architected), altivec supported
Model: 2.0 (pvr 0080 0200)
Thread(s) per core: 8
Core(s) per socket: 2
Socket(s): 2
On the same system, if hotplug is running along with lscpu, it shows
"Socket(s):" as 3 and 4 incorrectly sometimes.
Architecture: ppc64le
Byte Order: Little Endian
CPU(s): 32
On-line CPU(s) list: 0-11,16-31
Off-line CPU(s) list: 12-15
Model name: POWER10 (architected), altivec supported
Model: 2.0 (pvr 0080 0200)
Thread(s) per core: 8
Core(s) per socket: 1
Socket(s): 3
The number of sockets is considered as the number of unique core_siblings
CPU groups. The issues causing the number of sockets to sometimes be
higher during hotplug is:
1. The core_siblings of CPUs on the same socket are different because a CPU
on the socket has been onlined/offlined in between. In the below example,
nr sockets was wrongly incremented for CPU 5 though CPU 4 and 5 are on the
same socket because their core_siblings was different as CPU 12 was onlined
in between.
CPU: 4
core_siblings: ff f0 0 0 0 0 0 0
CPU: 5
core_siblings: ff f8 0 0 0 0 0 0
2. The core_siblings file of a CPU is created when a CPU is onlined. It may
have an invalid value for some time until the online operation is fully
complete. In the below example, nr sockets is wrongly incremented because
the core_siblings of CPU 14 was 0 as it had just been onlined.
CPU: 14
core_siblings: 0 0 0 0 0 0 0 0
To fix this, make the below changes:
1. Instead of considering CPUs to be on different sockets if their
core_siblings masks are unequal, consider them to be on different sockets
only if their core_siblings masks don't have even one common CPU. Then CPUs
on the same socket will be correctly identified even if offline/online
operations happen while they are read if at least one CPU in the socket is
online during both reads.
2. Check if a CPU's hotplug operation has been completed before using its
core_siblings file
[kzak@redhat.com: - use xmalloc(),
- use ul_strtos32(),
- use err() on CPU_ALLOC() error]
Reported-by: Anushree Mathur <anushree.mathur@linux.vnet.ibm.com> Signed-off-by: Anjali K <anjalik@linux.ibm.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Robin Jarry [Thu, 31 Oct 2024 22:55:44 +0000 (23:55 +0100)]
treewide: use scols printf api where possible
Everywhere a string generated with xasprintf() is directly passed to
scols_line_refer_data(), use scols_line_sprintf() to remove the need for
an intermediate buffer.
Replace the (now redundant) private scols_line_asprintf() function.