Zdenek Kabelac [Sat, 14 Mar 2026 13:39:41 +0000 (14:39 +0100)]
libblkid: check for private DM device before open
blkid_new_probe_from_filename() opens the device before calling
blkid_probe_set_device(), which checks sysfs_devno_is_dm_private()
and sets BLKID_FL_NOSCAN_DEV. But the open() itself bumps the
kernel open count, so a concurrent DM_DEVICE_REMOVE ioctl sees
EBUSY even though blkid never actually probes the device.
Move the private-device check before open() in
blkid_new_probe_from_filename(). The sysfs UUID is readable
without opening the block device, so this closes the race window
between udev-worker's blkid builtin and device-mapper remove.
Note: blkid_verify() in verify.c already does the check before
open() -- this patch makes the probe path consistent.
nsenter: (man) correct the markup and improve the formatting
Remove the mistaken angle brackets that were introduced last month
by commit f2a5997869, add the missing equals sign, and put both it
and the subsequent colon in bold as they are literal characters.
Also, indent the list of paths to make it clearer where it ends,
and so that the subsequent paragraph gets indented correctly.
nsenter: (usage) correct the formatting of eight option arguments
Angle brackets should wrap each placeholder separately: <file> and
<nsid>. Angle brackets should not enclose metacharacters (|) nor
literal ones (= and :).
(The mistaken formatting was introduced by commit f2a5997869.)
Karel Zak [Thu, 12 Mar 2026 10:10:15 +0000 (11:10 +0100)]
Merge branch 'improve/4070' of https://github.com/echoechoin/util-linux
* 'improve/4070' of https://github.com/echoechoin/util-linux:
man: add ENVIRONMENT section for smartcols support in various man pages
man: hide LIBSMARTCOLS_JSON in man pages that do not support --json
WanBingjiang [Sat, 28 Feb 2026 03:56:32 +0000 (11:56 +0800)]
man: add ENVIRONMENT section for smartcols support in various man pages
This update introduces an ENVIRONMENT section to the man pages
of several utilities. The section includes references to the common
environment variable for smart column output, ensuring consistent
documentation across tools that support the --json output format.
terminal-colors.d: (man) re-apply improvements lost in merge
Commit 3252142521 improved the man page formatting and wording,
but merge commit d708fc7db6 undid all those changes due to a
conflict resolution mess. Re-apply the improvements:
- do not show 'type' as an optional part in the synopsis
- indent the list of file types for clarity
- correct and improve several wordings
- fix grammar ("which provide" not "which provides")
- compact the examples section
Addresses: https://github.com/util-linux/util-linux/commit/3252142521 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 10 Mar 2026 12:31:09 +0000 (13:31 +0100)]
umount: fix --graceful option cosmetics and tests
- fix missing comma in man page option syntax
- fix typo "succesfully" -> "successfully"
- move --graceful before --namespace in help text
- shorten help text to single line
- improve man page description, add root-only note
- add test for non-existent path with --graceful
Addresses: https://github.com/util-linux/util-linux/pull/4059 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 10 Mar 2026 12:25:42 +0000 (13:25 +0100)]
Merge branch 'umount_graceful_option' of https://github.com/cgoesche/util-linux-fork
* 'umount_graceful_option' of https://github.com/cgoesche/util-linux-fork:
umount: add test for --graceful option
umount: new --graceful option to exit successfully even if filesystem is unmounted
Karel Zak [Tue, 10 Mar 2026 09:57:37 +0000 (10:57 +0100)]
Merge branch 'PR/meson-libcommon-duplicates' of https://github.com/karelzak/util-linux-work
* 'PR/meson-libcommon-duplicates' of https://github.com/karelzak/util-linux-work:
lib/meson: move caputils.c from lib_common to per-binary sources
lib/meson: remove unconditional procfs.c from lib_common_sources
lib/meson: remove duplicated source files from lib_common_sources
Ben Song [Mon, 2 Mar 2026 13:48:25 +0000 (21:48 +0800)]
docs: getopt: improve arg example in getopt-example
The option `wow!*\?` in original example is not the argument of
`--c-long`. Only `=` separated in optional option is allowed.
[karelzak@redhat.com: - fix tcsh quote style to use backtick-quote
matching actual script output, remove orphaned comment about
exclamation mark escaping]
Based-on-patch-by: Ben Song <bensongsyz@gmail.com>
Addresses: https://github.com/util-linux/util-linux/pull/4088 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 9 Mar 2026 11:18:20 +0000 (12:18 +0100)]
Merge branch 'patch-27' of https://github.com/mariobl/util-linux
* 'patch-27' of https://github.com/mariobl/util-linux:
Put file types in namei.1.adoc in a table structure
Convert code blocks into tables
Remove backticks from table in terminal-colors.d.5.adoc
Karel Zak [Mon, 9 Mar 2026 11:04:44 +0000 (12:04 +0100)]
lslogins: fix broken GROUP column output
The condition on COL_GROUP incorrectly checked `!grp->gr_name`
instead of `!user->group`. This caused the GROUP column to always
be empty because when gr_name is non-NULL (normal case) the
assignment was skipped, and when gr_name is NULL, xstrdup() would
crash.
Fixes: https://github.com/util-linux/util-linux/issues/4097 Fixes: 52a6e45bfe5ddee1fed20f2f4f7542cac6bf13c9 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 9 Mar 2026 10:25:58 +0000 (11:25 +0100)]
pam_lastlog2: add -lpam to Makemodule.am
If we don't add this, we don't actually link with PAM; compare the
before and after of pam_lastlog2.so -- without -lpam it does not list
libpam.so.0 as a NEEDED dependency.
Signed-off-by: Morgan Jones <me@numin.it> Signed-off-by: Karel Zak <kzak@redhat.com>
terminal-colors.d: (man) do not show 'type' as an optional part
That is: remove the square brackets from around 'type' in the synopsis.
Also, do not give the impression that a leading dot by itself is fine
before the 'type'. That is: a dot is required only when 'name' and/or
'@term' is present.
Also, do not colorize the square brackets as if they were part of the
placeholders. (And use ++double plus++ passthroughs for the opening
square brackets, to prevent asciidoctor from misinterpreting them.)
Indent the list of file types, for clarity.
And correct or improve some wordings, and remove an inconvenient
blank line in an example.
Karel Zak [Mon, 9 Mar 2026 10:03:54 +0000 (11:03 +0100)]
lib/meson: move caputils.c from lib_common to per-binary sources
caputils.c is GPL-licensed, and libcommon should only contain LGPL
or public domain code (as stated in lib/Makemodule.am). Move it out
of lib_common_sources and add it directly to the sources of binaries
that use it (unshare, nsenter, setpriv), matching autotools.
Addresses: https://github.com/util-linux/util-linux/issues/4085 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 9 Mar 2026 09:31:25 +0000 (10:31 +0100)]
lib/meson: remove unconditional procfs.c from lib_common_sources
procfs.c was listed in the base lib_common_sources and also added
conditionally under HAVE_OPENAT/HAVE_DIRFD (line 88). In autotools,
procfs.c is only added conditionally. Remove it from the base list
to match autotools and avoid duplication.
Addresses: https://github.com/util-linux/util-linux/issues/4085 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 9 Mar 2026 09:30:57 +0000 (10:30 +0100)]
lib/meson: remove duplicated source files from lib_common_sources
The files idcache.c, randutils.c, md5.c, sha1.c, strutils.c, and
strv.c were listed both in the base lib_common_sources string list
and then appended again via files() objects. Remove them from the
base list since the files() append is needed for the named variables
used by other meson.build files.
Addresses: https://github.com/util-linux/util-linux/issues/4085 Signed-off-by: Karel Zak <kzak@redhat.com>
If SIGCHLD is ignored, the wait call which waits for the umount command
to finish could fail with -1 and ECHILD. Since its return value is not
checked, the uninitialized status variable would be read, leading to
undefined behavior.
While at it, removed the additionally printed newline from errx message.
Just in case another exit handler relies on these signal handlers being
set to default, or to allow users to press ^C and let the program exit
as expected.
Karel Zak [Thu, 5 Mar 2026 08:35:54 +0000 (09:35 +0100)]
Merge branch 'PR/portability-hurd' of https://github.com/karelzak/util-linux-work
* 'PR/portability-hurd' of https://github.com/karelzak/util-linux-work:
agetty: simplify USE_SYSTEMD ifdef in output_special_char
agetty: introduce USE_NETLINK to separate netlink from reload
agetty: guard netlink-related code with AGETTY_RELOAD
libblkid: guard loop device code with __linux__ in cache
build-sys: move shells.c to common (non-Linux) sources
build-sys: move netlink sources from libcommon to agetty
Karel Zak [Tue, 3 Mar 2026 09:56:38 +0000 (10:56 +0100)]
lsmem: apply --sysroot prefix to all sysfs paths
Tests fail on architectures where /sys/module/memory_hotplug/parameters/
memmap_on_memory does not exist (e.g., loong64), because lsmem reads
from the real /sys instead of the --sysroot directory.
- Route memmap_on_memory read through ul_path API with a local handler
in print_summary(), so --sysroot prefix is respected.
- Apply --sysroot prefix to sysmemconfig (/sys/firmware/memory) before
the memory0 existence check.
lib/pager: Properly handle fork error return value
Most of the code checks for pager_process.pid != 0 to see if a pager is
running. If fork fails and returns -1, pager_process.pid is not 0, too.
This in turn leads to an issue if waitpid is eventually called with -1
as pid, which would wait for all children. Since there are no children,
the wait_for_pager function calls err with an EXIT_FAILURE value.
Calling printf is not signal safe and in general there are too many
branches in alarm_intr for what it's used for.
Check the signal flag outside of the handler and print messages when
needed. Also, disable the alarm and reset the signal handling when it's
not needed anymore.
Karel Zak [Tue, 3 Mar 2026 11:34:43 +0000 (12:34 +0100)]
agetty: simplify USE_SYSTEMD ifdef in output_special_char
Remove unnecessary duplicate #ifdef USE_SYSTEMD around the else
branch for utmpx-based user counting. Use the same pattern as
USE_NETLINK where the else and opening brace are split across the
endif boundary.
Karel Zak [Tue, 3 Mar 2026 11:30:34 +0000 (12:30 +0100)]
agetty: introduce USE_NETLINK to separate netlink from reload
The netlink functionality (network address display in issue file)
and the reload mechanism (inotify-based) are separate features that
shared the same AGETTY_RELOAD ifdef guard. Additionally, the netlink
code in output_special_char() used a different guard
(#if defined(RTMGRP_IPV4_IFADDR) && defined(RTMGRP_IPV6_IFADDR))
creating inconsistency.
Introduce USE_NETLINK, defined when AGETTY_RELOAD is enabled and
the required RTMGRP constants are available. Use it consistently
for all netlink-specific code (nl field, helper functions, socket
handling, escape sequences \4, \6, \a, \A).
Keep AGETTY_RELOAD for the inotify/reload mechanism only.
Karel Zak [Tue, 3 Mar 2026 11:00:43 +0000 (12:00 +0100)]
agetty: guard netlink-related code with AGETTY_RELOAD
The struct issue nl field and related helper functions use types
and headers (netaddrq.h, linux/netlink.h) that are only available
when AGETTY_RELOAD is defined. Guard the .nl.fd initializations
in main() and show_issue(), and wrap the netlink helper functions
(print_iface_best, print_addrq_bestofall, dump_iface_good,
dump_iface_all) with #ifdef AGETTY_RELOAD.
This fixes compilation on systems without inotify/netlink support
(e.g., GNU/Hurd).
Co-authored-by: Samuel Thibault <samuel.thibault@aquilenet.fr> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 3 Mar 2026 10:42:55 +0000 (11:42 +0100)]
libblkid: guard loop device code with __linux__ in cache
The is_loopdev() and loopdev_has_backing_file() functions from
loopdev.h are Linux-specific. Guard the loop device cache cleanup
in blkid_gc_cache() with __linux__ to allow compilation on
non-Linux systems like GNU/Hurd.
Co-authored-by: Samuel Thibault <samuel.thibault@aquilenet.fr> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 3 Mar 2026 10:41:50 +0000 (11:41 +0100)]
build-sys: move shells.c to common (non-Linux) sources
shells.c uses POSIX setusershell()/getusershell()/endusershell()
which are available on non-Linux systems (e.g., GNU/Hurd). Move it
from the Linux-only section to common libcommon sources.
The meson build already had shells.c in common sources, so only
the autotools build needed fixing.
Co-authored-by: Samuel Thibault <samuel.thibault@aquilenet.fr> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 3 Mar 2026 10:39:14 +0000 (11:39 +0100)]
build-sys: move netlink sources from libcommon to agetty
The netlink and netaddrq sources use Linux-specific headers
(linux/netlink.h, linux/rtnetlink.h) and cannot be compiled on
non-Linux systems like GNU/Hurd.
Move them out of libcommon and link directly into agetty (the only
user), following the same pattern as plymouth-ctrl.c. Also move the
corresponding test programs to the Linux-only section.
Co-authored-by: Samuel Thibault <samuel.thibault@aquilenet.fr> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 2 Mar 2026 11:52:48 +0000 (12:52 +0100)]
Merge branch 'pager_git' of https://github.com/stoeckmann/util-linux
* 'pager_git' of https://github.com/stoeckmann/util-linux:
lib/pager: Drop less workaround
lib/pager: Add LV support
lib/pager: Do not overwrite LESS environment var
libblkid: (probe) Account for IO bias when retrieving buffer from parent
The 'off' variable gets aligned to 'pr->io_size'. However when
delegating to the parent prober, the value for 'off' from the original
function parameter needs to be used.
Undo the bias before calling into the parent prober.
Fixes: 8a534253bc52 ("libblkid: (probe) read data in chunks") Closes: https://github.com/util-linux/util-linux/issues/4078 Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
WanBingjiang [Fri, 27 Feb 2026 08:34:27 +0000 (16:34 +0800)]
man: hide LIBSMARTCOLS_JSON in man pages that do not support --json
PR #4070 consolidated libsmartcols env vars into man-common/env-smartcols.adoc
and had all tools (including fdisk and cfdisk) include it. That documented
LIBSMARTCOLS_JSON in fdisk/cfdisk man pages although those tools do not
support --json output, which is misleading.
Use ifdef::smartcols-json[] in env-smartcols.adoc so the JSON env var
section is only rendered for man pages that set :smartcols-json: (column,
lsblk, findmnt, sfdisk). fdisk and cfdisk include the same file but do not
set the attribute, so they only show the debug-related variables.
lib/fileeq: Check arithmetic in ul_fileeq_set_size
Make sure that arithmetics do not overflow data types. Such overflows
could occur with large hardlink options or on 32 bit systems with large
files (due to size_t usage).
If possible, reduce sizes so operations can continue successfully.
Karel Zak [Thu, 26 Feb 2026 10:27:48 +0000 (11:27 +0100)]
tools/checkconfig: strip C comments before macro extraction
Strip C/C++ comments (// line comments, single-line /* */ and
multi-line /* */ blocks) before extracting HAVE_ and ENABLE_ macros.
This avoids false positives from macros mentioned in comments, e.g.
"when HAVE_PIDFD_* ..." in include/pidfd-utils.h.
Karel Zak [Thu, 26 Feb 2026 09:39:08 +0000 (10:39 +0100)]
tools: git-version-bump, accept X.Y-devel version on master branch
Allow "X.Y-devel" as a valid version format, restricted to the master
branch only. Release versions (X.Y, X.Y.Z, X.Y-rcN, X.Y.Z-rcN) still
require a stable/vX.Y branch.