Jordan Williams [Fri, 5 Apr 2024 14:49:17 +0000 (07:49 -0700)]
meson: Only build libmount when required
It is not currently possible to build any part of util-linux without
building libmount when using Meson.
The libuuid library is commonly used on macOS, where it is not possible
to build libmount.
To address this, this PR makes it possible to build without libmount and
libblkid.
Options have been added to allow toggling whether to build targets that
require libmount.
This makes it possible to fully disable building libmount.
The python object had to be defined outside of the meson.build file in
libmount/python since this may no longer be included.
The python object is used for tests.
Signed-off-by: Jordan Williams <jordan@jwillikers.com>
Jordan Williams [Fri, 5 Apr 2024 15:30:02 +0000 (08:30 -0700)]
meson: Use libblkid as a dependency
Several utilities depend on libblkid internally.
Currently, link_with and global include directories are used to
associate targets with libblkid.
This PR uses Meson's dependencies argument for targets to define this
relationship instead.
This carries include directories along with the library to link.
An additional dependency is declared for the static libblkid library.
A couple of executables use this dependency explicitly.
Signed-off-by: Jordan Williams <jordan@jwillikers.com>
Jordan Williams [Fri, 5 Apr 2024 15:33:22 +0000 (08:33 -0700)]
meson: Use libmount as a dependency
Several utilities depend on libmount internally.
Currently, link_with and global include directories are used to
associate targets with libmount.
This PR uses Meson's dependencies argument for targets to define this
relationship instead.
This carries include directories along with the library to link.
An additional dependency is declared for the static libmount library.
A couple of executables use this dependency explicitly.
Signed-off-by: Jordan Williams <jordan@jwillikers.com>
Karel Zak [Fri, 5 Apr 2024 08:57:13 +0000 (10:57 +0200)]
Merge branch 'meson-optional-rt' of https://github.com/jwillikers/util-linux
* 'meson-optional-rt' of https://github.com/jwillikers/util-linux:
meson: Only pick up the rt library once
meson: Add build-lsfd option and make rt dependency optional
Karel Zak [Fri, 5 Apr 2024 07:40:48 +0000 (09:40 +0200)]
Merge branch 'PR/libsmartcols-json-empty' of github.com:karelzak/util-linux-work
* 'PR/libsmartcols-json-empty' of github.com:karelzak/util-linux-work:
libsmartcols: print empty arrays in better way
lib/jsonwrt: introduce ul_jsonwrt_empty()
Karel Zak [Wed, 3 Apr 2024 11:57:18 +0000 (13:57 +0200)]
lib/jsonwrt: introduce ul_jsonwrt_empty()
The new function optimizes the printing of empty objects and arrays in
a "pretty" way, instead of using the ul_jsonwrt_..._open() and
ul_jsonwrt_..._close() functions, which add extra line breaks to the
output.
Commit 5d71d711d07a ("libblkid: topolicy/ioctl: use union for multiple data types")
incorrectly assumed that set_ulong and set_int refer to the type
returned by the kernel. Instead the different function pointer names
refer to the types of the function pointers.
However all ioctls, except for the later added BLKGETDISKSEQ, return
32bit integers.
This made libblkid also interpret the upper 32bits too, leading to
garbage values.
Introduce a new member 'kernel_size' to also handle the 64bit
BLKGETDISKSEQ.
Drop data.ul as it is no actually used.
Closes #2904 Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
Karel Zak [Tue, 2 Apr 2024 10:58:02 +0000 (12:58 +0200)]
Merge branch 'lsns--Q' of https://github.com/masatake/util-linux
* 'lsns--Q' of https://github.com/masatake/util-linux:
tests: (lsns) add a case testing -Q, --filter option
tests: (test_mkfds::userns) add a new factory
tests: (test_mkfds::multiplexing) fix the factory description
lsns: add -H, --list-columns option
lsns: implement -Q, --filter option
lsfd: (man) fix the decoration of an optional parameter
lsns: add a missing '=' character in the help message
lsns: (man) make the namespace parameter optional
lsblk: (refactor) refer to a parameter instead of a file static var
Jordan Williams [Fri, 29 Mar 2024 17:14:44 +0000 (12:14 -0500)]
meson: Add build-lsfd option and make rt dependency optional
A dependency on the rt library is unnecessarily required when checking
for the clock_gettime and timer_create functions.
This causes the build to fail if the rt library is not found.
This should not fail the build as rt is only required for the checks.
Additionally, the lsfd executable and some tests require rt.
There is currently no option to toggle building lsfd.
This PR makes it possible to build without the rt library.
Function checks no longer require rt for the build.
The function checks for the rt library only run when rt is available.
This PR adds an option to allow building without lsfd.
This makes it possible to build without the executable that requires rt.
To not require rt for the test, a additional check has been added.
The effected tests won't be built unless rt has been found.
Signed-off-by: Jordan Williams <jordan@jwillikers.com>
Jordan Williams [Fri, 29 Mar 2024 19:00:01 +0000 (14:00 -0500)]
meson: Fix false positive detection of mempcpy on macOS
The has_function check incorrectly detects mempcpy on macOS.
This function is not available on macOS and should not be detected.
Likely, this has to do with Meson's detection of compiler built-ins.
Using a specific prefix and defining _GNU_SOURCE fixes the detection.
Signed-off-by: Jordan Williams <jordan@jwillikers.com>
Karel Zak [Mon, 1 Apr 2024 10:14:50 +0000 (12:14 +0200)]
libblkid: Fix segfault when blkid.conf doesn't exist
* Move 'line' and 'uevent' to the beginning of the LIBECONF code.
* Remove unwanted space between function name and arguments.
* Check for 'line' pointer before dereferencing.
References: https://github.com/util-linux/util-linux/pull/2883 Signed-off-by: Karel Zak <kzak@redhat.com>
Oldřich Jedlička [Sat, 30 Mar 2024 13:45:10 +0000 (14:45 +0100)]
libblkid: check OPAL lock only when necessary
When the HW OPAL encryption is used, the LUKS2 subsystem field is "HW-OPAL"
(see also [1]). Finish the probe only in case LUKS2 is set to use HW OPAL
and the disk is locked.
Thomas Weißschuh [Sat, 30 Mar 2024 10:14:47 +0000 (11:14 +0100)]
libblkid: introduce luks opal prober
Accesses to a disk locked with OPAL trigger IO errors logged by the
kernel which should be avoided.
Running the normal luks prober first breaks the ordering of probers
leading to incorrect detections, for example detecting mdadm superblocks
before version 1.1 as luks.
Introduce a new prober that only runs on OPAL-locked disks to avoid
these false-positives.
Jordan Williams [Fri, 29 Mar 2024 21:56:43 +0000 (16:56 -0500)]
meson: Don't define HAVE_ENVIRON_DECL when environ is unavailable
HAVE_ENVIRON_DECL is being defined to 0 by cfg_data.set10().
The code only checks whether or not is defined.
This leads to it not being declared appropriately.
Use cfg_data.set() instead of cfg_data.set10() to define it when true.
Signed-off-by: Jordan Williams <jordan@jwillikers.com>
Karel Zak [Wed, 27 Mar 2024 10:46:01 +0000 (11:46 +0100)]
Merge branch 'blkid/json' of https://github.com/t-8ch/util-linux
* 'blkid/json' of https://github.com/t-8ch/util-linux:
blkid: add json output format
blkid: (tests) test output formats
blkid: (tests) use correct blkid binary
Karel Zak [Tue, 26 Mar 2024 11:45:24 +0000 (12:45 +0100)]
lsipc: fix semaphore USED counter
The code incorrectly counts only with the first item in the linked
list (due to a typo). It seems rather fragile to use "semds" and
"semdsp" as variable names in the same code ...
# lsipc -gs
Old:
KEY ID PERMS OWNER NSEMS RESOURCE DESCRIPTION LIMIT USED USE%
SEMMNI Number of semaphore identifiers 32000 3 0.01%
SEMMNS Total number of semaphores 1024000000 369 0.00%
SEMMSL Max semaphores per semaphore set. 32000 - -
SEMOPM Max number of operations per semop(2) 500 - -
SEMVMX Semaphore max value 32767 - -
Fixed:
KEY ID PERMS OWNER NSEMS RESOURCE DESCRIPTION LIMIT USED USE%
SEMMNI Number of semaphore identifiers 32000 3 0.01%
SEMMNS Total number of semaphores 1024000000 156 0.00%
SEMMSL Max semaphores per semaphore set. 32000 - -
SEMOPM Max number of operations per semop(2) 500 - -
SEMVMX Semaphore max value 32767 - -
Addresses: https://issues.redhat.com/browse/RHEL-30269 Signed-off-by: Karel Zak <kzak@redhat.com>
Tim Hallmann [Sun, 24 Mar 2024 19:14:30 +0000 (20:14 +0100)]
rev: Check for wchar conversion errors
Commit c9cc84621ca98ef85499e83ca56f05f12055f193 introduced a regression
where only the actual EOF is handled, not other error conditions
returning WEOF. This leads to an infinite loop upon encountering
conversion errors. For example (using LC_CTYPE="en_US.UTF-8"):
Jordan Williams [Wed, 20 Mar 2024 16:41:49 +0000 (11:41 -0500)]
meson: Only build blkzone and blkpr if the required linux header exists
Checks for the required headers for blkzone and blkptr are done for
Autotools.
This logic wasn't carried over to Meson.
This PR just adds the same checks.
Fixes #2850.
Signed-off-by: Jordan Williams <jordan@jwillikers.com>
The blamed commit converted script to use the generic pty code that
was added by commit 6954895cae34 ("lib/pty-session: add generic PTY
container code").
Commit ec10634e7ec4 says the new pty stuff is based on script.
However, there is difference in signal handling.
Before the commit, only the signals that the script was interested
in were blocked and handled by signalfd.
After the commit, all signals are blocked and only the interested
signals are handled.
This causes regression in the following scenario:
1. run `script` via /etc/profile.d for ssh session
2. login to a ssh session using bash
3. run `sudo -i`
4. wait until ssh session timeout
Karel Zak [Tue, 5 Mar 2024 09:14:08 +0000 (10:14 +0100)]
Merge branch 'blockdev' of https://github.com/EvgeniyRogov/util-linux
* 'blockdev' of https://github.com/EvgeniyRogov/util-linux:
- Fixed report error code in blockdev. - Minor: Added a period at the end of "--rereadpt" description.
Karel Zak [Mon, 4 Mar 2024 11:38:35 +0000 (12:38 +0100)]
Merge branch 'lsfd--github-issue-2819' of https://github.com/masatake/util-linux
* 'lsfd--github-issue-2819' of https://github.com/masatake/util-linux:
tests: (lsfd::mkfds-inotify) consider environments not having / as a mount point
Stanislav Brabec [Wed, 28 Feb 2024 14:06:14 +0000 (15:06 +0100)]
setterm: Document behavior of redirection
Debugging an error of setterm, I realized that setterm --powerdown operates
on stdout but setterm --powersave operates on stdin. Such unexpected
behavior should be documented.
I prefer a less accurate generic "always redirect both stdin and stdout"
over recommending of the correct I/O stream for each option separately.
Karel Zak [Thu, 29 Feb 2024 08:50:59 +0000 (09:50 +0100)]
Merge branch 'lsfd--btrfs' of https://github.com/masatake/util-linux
* 'lsfd--btrfs' of https://github.com/masatake/util-linux:
tests: (lsfd::mkfds-inotify-btrfs) test INOTIFY.INODES cooked output
lsfd: extend nodev table to decode "btrfs" on SOURCE column
lsfd: (refactor) rename a member of struct proc
lsfd: (refactor) rename a local variable and a parameter
lsfd: (refactor) split the function processing mountinfo file
lsfd: (refactor) store a mnt_namespace object to struct process
lsfd: (refactor) use a binary tree as the implementation for mnt_namespaces
lsfd: read /proc/$pid/ns/mnt earlier
lsfd: (refactor) rename add_nodevs to read_mountinfo
lsfd: make the way to read /proc/$pid/mountinfo robust
lsfd: (cosmetic) normalize whitespaces