Karel Zak [Mon, 15 Apr 2024 07:07:12 +0000 (09:07 +0200)]
Merge branch 'lslocks--no-sleep-in-test-case' of https://github.com/masatake/util-linux
* 'lslocks--no-sleep-in-test-case' of https://github.com/masatake/util-linux:
lslocks: remove a unused local variable
lslocks: don't abort gathering per-process information even if opening a /proc/[0-9]* fails
Karel Zak [Mon, 15 Apr 2024 07:04:38 +0000 (09:04 +0200)]
Merge branch 'PR/autotools' of github.com:karelzak/util-linux-work
* 'PR/autotools' of github.com:karelzak/util-linux-work:
autotools: add --disable-enosys, check for linux/audit.h
autotools: check for sys/vfs.h and linux/bpf.h
Karel Zak [Mon, 15 Apr 2024 06:55:47 +0000 (08:55 +0200)]
Merge branch 'tinfo-disabler' of https://github.com/jwillikers/util-linux
* 'tinfo-disabler' of https://github.com/jwillikers/util-linux:
meson: Make ncurses dependency a disabler when not found
meson: Make tinfo dependency a disabler when not found
lsns: tolerate lsns_ioctl(fd, NS_GET_{PARENT,USERNS}) failing with ENOSYS
With the original code, "lsns/filedesc" test case failed on
"build (qemu-user, s390x)" and "build (qemu-user, riscv64)".
On the platforms, lsns_ioctl(fd, NS_GET_{PARENT,USERNS}) failed
with ENOSYS. The error stoped the iteration for gathering
information from /proc/[0-9]+. As a result, lsns printed
nothing. We don't expect this behavior.
Thomas Weißschuh [Sat, 13 Apr 2024 07:42:39 +0000 (09:42 +0200)]
Revert "lib/pager: Apply pager-specific fixes only when needed"
Less is not always detectable, as it can be hidden behind symlinks or
wrapper as for example in a default Debian installation.
Also testing for the literal string "less" does not match full path
specifications like "/usr/bin/less".
lslocks: don't abort gathering per-process information even if opening a /proc/[0-9]* fails
If a process ($pid) taking a lock is gone while running lslocks,
gathering per-process information for the process may fail in opening
/proc/$pid. Though lslocks should work with incomplete information,
the original code stopped gathering per-process information for the
other processes.
As a result of the original behavior, tests/ts/lslocks/lslocks really
failed in an environment where multiple test cases ran simultaneously.
Jordan Williams [Mon, 8 Apr 2024 16:37:01 +0000 (11:37 -0500)]
meson: Remove libblkid dependency on libmount
I added this incorrect dependency between libblkid and libmount.
The option to build libblkid should be allowed whether or not the
build-libmount feature is allowed.
Signed-off-by: Jordan Williams <jordan@jwillikers.com>
Jordan Williams [Mon, 8 Apr 2024 16:17:12 +0000 (11:17 -0500)]
meson: Require the sys/vfs.h header for libmount and fstrim
libmount and fstrim both include sys/vfs.h unconditionally.
To avoid an error at compile time, require this header for their
respective feature options to be enabled.
This avoids building them on systems without sys/vfs.h, such as macOS.
Fixes #2932.
Signed-off-by: Jordan Williams <jordan@jwillikers.com>
John Paul Adrian Glaubitz points out that libseccomp needs to release 2.6.0,
too.
Reviewed-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> Reviewed-by: Thomas Weißschuh <thomas@t-8ch.de> Signed-off-by: Chris Hofstaedtler <zeha@debian.org>
Karel Zak [Tue, 9 Apr 2024 10:16:21 +0000 (12:16 +0200)]
Merge branch 'logger/fixes' of https://github.com/t-8ch/util-linux
* 'logger/fixes' of https://github.com/t-8ch/util-linux:
logger: correctly format tv_usec
logger: rework error handling in logger_gettimeofday()
logger: handle failures of gettimeofday()
Karel Zak [Tue, 9 Apr 2024 10:07:12 +0000 (12:07 +0200)]
Merge branch 'lsfd--verify-proc-syscall-for-master' of https://github.com/masatake/util-linux
* 'lsfd--verify-proc-syscall-for-master' of https://github.com/masatake/util-linux:
tests: (lsfd::mkfds-multiplexing) skip if /proc/$pid/syscall is broken
tv_usec is an unspecified signed integer type.
The format string %u assumes an unsigned int, which is incorrect.
Especially on 32bit big-endian, where it can lead to invalid values.
3dd79293b5b655da9d913dedd8facb08959a7826 added -I option.
However, the code used bit flags (FL_DF and FL_DF_INODES) wrongly;
the code broke the output of -D option.
Jordan Williams [Mon, 8 Apr 2024 15:12:17 +0000 (10:12 -0500)]
meson: Disable targets requiring pam when it is missing
Several executables require the pam library.
The current behavior in Meson only requires this library when these
executables are explicitly enabled.
Unfortunately, by default, Meson will not throw an error when the
required pam library is missing while still trying to build these
executables.
To fix this, make the pam library a disabler which automatically
disables these executables if it is not found.
Signed-off-by: Jordan Williams <jordan@jwillikers.com>
Jordan Williams [Mon, 8 Apr 2024 14:33:19 +0000 (09:33 -0500)]
meson: Require Python dependency which can be embedded for pylibmount
Meson doesn't properly check that the necessary Python.h header file is
available for the pylibmount module.
Passing true for the embed keyword argument for the Python dependency
method ensures that this header file is available.
Signed-off-by: Jordan Williams <jordan@jwillikers.com>
Jordan Williams [Mon, 8 Apr 2024 13:30:24 +0000 (08:30 -0500)]
meson: Enforce sqlite dependency for liblastlog2
liblastlog2 requires the sqlite dependency.
Currently, Meson enforces this dependency to be available only when the
build-liblastlog2 feature is explicitly enabled.
liblastlog2 is built by default, so if sqlite is not available, the
build will be configured correctly, but fail to compile.
This commit fixes this case by automatically disabling the
build-liblastlog2 feature when it is auto and sqlite is not found.
Signed-off-by: Jordan Williams <jordan@jwillikers.com>
Karel Zak [Mon, 8 Apr 2024 07:55:59 +0000 (09:55 +0200)]
Merge branch 'test_mkfds-sockdiag-for-master' of https://github.com/masatake/util-linux
* 'test_mkfds-sockdiag-for-master' of https://github.com/masatake/util-linux:
tests: (test_mkfds::sockdiag) verify the recieved message to detect whether the socket is usable or not
lsfd: add LSFD_DEBUG env var for debugging
tests: (lsfd) skip some cases if NETLINK_SOCK_DIAG for AF_UNIX is not available
tests: (test_mkfds::sockdiag) new factory
tests: (lsfd-functions.bash,cosmetic) unify the style to define functions
tests: (lsfd) fix typoes in an error name
Karel Zak [Mon, 8 Apr 2024 07:48:10 +0000 (09:48 +0200)]
Merge branch 'xry111/pidfs' of https://github.com/xry111/util-linux
* 'xry111/pidfs' of https://github.com/xry111/util-linux:
lsfd: test: Adapt test cases for pidfs
lsfd: Support pidfs
lsfd: Refactor the pidfd logic into lsfd-pidfd.c
include: Include <unistd.h> in pidfd-utils.h for syscall()
Karel Zak [Mon, 8 Apr 2024 07:43:15 +0000 (09:43 +0200)]
Merge branch 'meson-make-libmount-optional' of https://github.com/jwillikers/util-linux
* 'meson-make-libmount-optional' of https://github.com/jwillikers/util-linux:
meson: Only build libmount when required
meson: Use libblkid as a dependency
meson: Use libmount as a dependency
Karel Zak [Mon, 8 Apr 2024 07:41:03 +0000 (09:41 +0200)]
Merge branch 'lsns--opened-ns' of https://github.com/masatake/util-linux
* 'lsns--opened-ns' of https://github.com/masatake/util-linux:
lsns: show namespaces only kept alive by open file descriptors
lsns: (refactor) use ul_new_path and procfs_process_init_path
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>
Xi Ruoyao [Wed, 3 Apr 2024 07:29:34 +0000 (15:29 +0800)]
lsfd: Refactor the pidfd logic into lsfd-pidfd.c
We'll reuse these logic for pidfd support on Linux >= 6.9. This should
be a no-functional change.
Besides moving the code, this change also renames anon_pidfd_data to
pidfd_data, and removes a redundant nullity check for free (because
free(NULL) will just do nothing per the C standard).
Masatake YAMATO [Sat, 24 Feb 2024 19:56:51 +0000 (04:56 +0900)]
lsns: show namespaces only kept alive by open file descriptors
Close #1884.
Quoted from the original issue comment submitted by @hesch:
It can happen, that a namespace is only kept alive by an open file
descriptor of a program as ilustrated by A.B:
1. 'ip netns add foo' - add a namespace
2. 'sleep 999 4< /run/netns/foo & sleep 2' - open the fd to the
namespace in a background job
3. 'ip netns delete foo' - delete the namespace (only deletes
the /run/netns/foo)
Now there exists a namespace with no process running in it and it has
no bind mount so it does not show up in /proc/mounts, but it is still
there and could be mounted back.
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>