Karel Zak [Thu, 14 May 2026 10:06:12 +0000 (12:06 +0200)]
agetty: move usage() and parse_args() before main()
Reorder functions so that output_version(), usage() and
parse_args() appear before main(), matching the convention used
across the project. Remove the now unnecessary forward
declarations for these functions.
Karel Zak [Thu, 14 May 2026 09:54:01 +0000 (11:54 +0200)]
agetty: move login argv initialization to utils.c
Introduce agetty_init_login_argv() that consolidates the login
command line setup: setting the program name, check_username(),
login_options_to_argv() with replace_u(), and the -h/-H/-f/--
flag logic.
Move LOGIN_ARGV_MAX to the shared header. The check_username(),
login_options_to_argv() and replace_u() helpers become static
in utils.c.
Karel Zak [Thu, 14 May 2026 09:21:48 +0000 (11:21 +0200)]
agetty: split out issue file functions to issuefile.c
Move issue file parsing, display and reload functions to a new
issuefile.c file: agetty_print_issue_file(), agetty_eval_issue_file(),
agetty_show_issue(), agetty_issue_is_changed(), agetty_reload(),
read_os_release(), output_special_char(), and all issuedir/issuefile
read helpers and network interface display functions.
Keep do_prompt(), get_logname() and wait_for_term_input() in
agetty.c as they are tightly coupled to the main login flow.
Karel Zak [Thu, 14 May 2026 09:11:01 +0000 (11:11 +0200)]
agetty: move struct issue and related defines to agetty.h
Move struct issue (renamed to struct agetty_issue),
ISSUE_SUPPORT, ISSUEDIR_SUPPORT, AGETTY_RELOAD and USE_NETLINK
defines to the shared header file in preparation for splitting
the issue file functions to a separate source file.
Karel Zak [Thu, 14 May 2026 08:37:35 +0000 (10:37 +0200)]
agetty: split out speed table and baud code to tty.c
Move speedtab[], struct Speedtab, bcode() and list_speeds() to a
new tty.c file as agetty_bcode() and agetty_list_speeds(). The
speed table is kept static in tty.c.
Add agetty_fprint_speed() to print the numeric baud rate for a
given speed code, replacing the open-coded speedtab[] lookup in
output_special_char() case 'b'.
Karel Zak [Thu, 14 May 2026 08:08:30 +0000 (10:08 +0200)]
agetty: move utility functions to utils.c
Move agetty_update_utmp(), agetty_xgethostname() and
agetty_xgetdomainname() to utils.c.
Move the SYSV_STYLE detection to agetty.h so it is available to
all split-out files. Change agetty_update_utmp() to take fakehost
as a parameter instead of accessing a file-scope static variable.
Karel Zak [Thu, 14 May 2026 07:41:12 +0000 (09:41 +0200)]
agetty: move struct options and F_* flags to agetty.h
Move struct options (renamed to struct agetty_options), MAX_SPEED
and all F_* flag definitions to the shared header file, making
them available to the split-out source files.
Karel Zak [Wed, 13 May 2026 13:18:13 +0000 (15:18 +0200)]
agetty: split out logging functions to utils.c
Move dolog(), agetty_exit_slowly(), agetty_log_err() and
agetty_log_warn() to a new utils.c file. These are foundational
functions used throughout agetty and need to be available to all
the split-out files.
Rename with agetty_ prefix to avoid symbol name collisions now
that the functions are no longer static.
Karel Zak [Wed, 13 May 2026 13:02:27 +0000 (15:02 +0200)]
agetty: move agetty.c to agetty-cmd/ directory
Create a dedicated agetty-cmd/ directory and move the monolithic
agetty.c there as a first step towards splitting it into smaller,
more maintainable files.
Update both autotools and meson build systems accordingly.
Karel Zak [Thu, 14 May 2026 11:05:12 +0000 (13:05 +0200)]
Merge branch 'PR/write-utmp-and-cleanup' of https://github.com/karelzak/util-linux-work
* 'PR/write-utmp-and-cleanup' of https://github.com/karelzak/util-linux-work:
write: cleanup indentation and whitespace
write: use mem2strcpy() for utmp strings
write: always use utmp as fallback
Furkan Caliskan [Wed, 13 May 2026 09:45:09 +0000 (12:45 +0300)]
chrt: Add support for SCHED_FLAG_DL_OVERRUN
When set on a SCHED_DEADLINE task, the kernel sends SIGXCPU to the
task if it exceeds its runtime budget within a period. Without this
flag the task is silently throttled until the next period. Useful
for real-time applications that need to detect when they are not
meeting their timing requirements.
Add -O/--deadline-overrun option to allow users to toggle this
feature using the deadline scheduling class.
Karel Zak [Wed, 13 May 2026 09:22:59 +0000 (11:22 +0200)]
write: use mem2strcpy() for utmp strings
The utmp fields ut_user and ut_line are fixed-size buffers not
guaranteed to be null-terminated. Using strncmp(), snprintf() or
memcmp() directly on these fields can read beyond the buffer content.
Use mem2strcpy() to safely copy utmp fields into properly terminated
local buffers before any string operations.
Karel Zak [Wed, 13 May 2026 09:13:03 +0000 (11:13 +0200)]
write: always use utmp as fallback
The systemd session list may not cover all terminals (e.g., screen,
tmux, or old-style logins). Remove the "if systemd else utmp" pattern
and always fall through to utmp when the target user or tty is not
found in systemd sessions.
Also make sd_get_sessions() and sd_session_get_username() failures
non-fatal — silently fall through to utmp instead of calling errx().
Addresses: https://redhat.atlassian.net/browse/RHEL-157244 Signed-off-by: Karel Zak <kzak@redhat.com>
Furkan Caliskan [Mon, 11 May 2026 14:10:30 +0000 (17:10 +0300)]
chrt: Add support for (GRUB) bandwidth reclaim
The SCHED_DEADLINE policy supports the (GRUB) Greedy Reclamation
of Unused Bandwidth algorithm. This allows tasks to reclaim
bandwidth that are left over by other deadline tasks that finish
their work early, or voluntarily yield the cpu.
Currently, chrt has no way to set the SCHED_FLAG_RECLAIM bit in
the sched_flags field of the sched_attr structure.
Add -G/--reclaim-grub option to allow users to toggle this feature
using the deadline scheduling class.
[kzak@redhat.com: - add missing #ifdef SCHED_FLAG_RECLAIM guards
- add comments to #else/#endif for SCHED_DEADLINE block] Signed-off-by: Furkan Caliskan <frn1furkan10@gmail.com>
Karel Zak [Tue, 12 May 2026 16:01:52 +0000 (18:01 +0200)]
tests: (getino) skip namespace subtests when not supported
Skip namespace subtests when the getino namespace ioctl is not
supported, and skip individual subtests when the corresponding
/proc/self/ns/* entry is not readable.
Karel Zak [Tue, 12 May 2026 13:10:02 +0000 (15:10 +0200)]
tests: (getino) skip namespace subtests when unshare is not supported
The namespace subtests use unshare to create isolated namespaces, but
this fails on QEMU and restricted CI containers where namespace
creation is not available. Skip the namespace subtests in this case.
Karel Zak [Tue, 12 May 2026 11:53:48 +0000 (13:53 +0200)]
Merge branch 'chrt_pidino_support' of https://github.com/cgoesche/util-linux-fork
* 'chrt_pidino_support' of https://github.com/cgoesche/util-linux-fork:
chrt: improve error message for invalid policy value
chrt: remove redundant initializations to 0 in struct members
chrt: deduplicate code for process tasks retrieval
chrt: report actual PID in error message when 0 is specified
tests: (chrt) simple PID:inode address format test
chrt: support the 'PID:inode' address format
Karel Zak [Tue, 12 May 2026 11:33:22 +0000 (13:33 +0200)]
tests: (lsblk) add bcachefs multi-device regression test
Add a dump from a system with a two-device bcachefs filesystem
(sdc1 + sdc2 mounted at /mnt/test) to verify that mount point
propagation works for all member devices.
Karel Zak [Tue, 12 May 2026 11:33:17 +0000 (13:33 +0200)]
tests: (lsblk) capture multi-device filesystem sysfs in mk-input.sh
Add capture of /sys/fs/btrfs/<uuid>/devices/ and
/sys/fs/bcachefs/<uuid>/dev-*/block symlinks so that dumps
generated on systems with multi-device btrfs or bcachefs
filesystems include the sysfs data needed for mount propagation
testing.
Also add a "mnt" output with KNAME,FSTYPE,MOUNTPOINT,MOUNTPOINTS
columns.
Karel Zak [Mon, 11 May 2026 13:25:19 +0000 (15:25 +0200)]
lsblk: add bcachefs multi-device mount propagation
Add support for bcachefs multi-device filesystems to show mount points
on all member devices, not just the one listed in mountinfo.
The implementation follows the existing btrfs/ZFS multi-device group
framework in mnt.c:
- Enumerate member devices via /sys/fs/bcachefs/<uuid>/dev-N/block
symlinks (similar to btrfs /sys/fs/btrfs/<uuid>/devices/).
- Cache and propagate mount entries to all group members.
The mountinfo entry caching (previously inlined in the btrfs scanner)
has been refactored into the shared fs_devs_cache_mounts() function
used by both btrfs and bcachefs. The function now also filters
mountinfo entries by filesystem type to avoid unnecessary comparisons
with unrelated mounts.
Additionally, fs_devs_add_filesystem() now skips duplicate entries to
prevent the same mount from being cached multiple times.
Note that bcachefs uses a non-standard colon-separated source format in
mountinfo (e.g. "/dev/sdc1:/dev/sdc2") rather than a single device
path. This format is not recognized by libmount's mnt_fs_streq_srcpath(),
so an extra is_source_member() helper is used to match individual
device paths within the compound source string.
Addresses: https://github.com/util-linux/util-linux/discussions/4316 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 12 May 2026 10:49:52 +0000 (12:49 +0200)]
script: fix "--" separator when used as option argument
The commit 7268e79b added "+" to the getopt_long() options string and
post-getopt "--" detection to support commands after the "--" separator.
The "+" prefix stops getopt at the first non-option argument, which
broke backward compatible "script file -c command" usage.
The commit 70507ab9ea fixed this by pre-scanning argv for "--" before
getopt and removing the "+" prefix to restore GNU getopt argument
permutation. However, the pre-scan was too naive — it treated any "--"
in argv as the separator, even when "--" was used as an argument to an
option (e.g., -I -- or --log-in --). The value can come from a
variable, e.g., script -I "$VAR" will break if $VAR is --.
Note that getopt_long() behavior with "--" depends on the option type:
- required_argument: "--" is consumed as the option value
- optional_argument: "--" is NOT consumed, treated as end-of-options
- no_argument: "--" is treated as end-of-options
Without "+" getopt also permutes arguments, which means non-option
arguments before "--" (like the outfile) become inaccessible after
getopt sets optind past "--". The pre-scan approach is necessary to
split the command part out of argv before getopt runs.
Fix the pre-scan by adding ul_find_argv_separator() to optutils.h.
The helper ul_is_option_with_arg() checks if a given argv entry is an
option that expects its value in the next argv entry, handling both
long options (via o->name) and short/bundled options (via o->val).
The separator search scans backward from each "--" counting consecutive
options-with-required-arg. They pair up (each consumes the next as its
value), so odd count means "--" is consumed as an option argument, even
count means it is the real separator. This correctly handles chained
cases like --log-in --log-in -- where the second --log-in is a value
for the first and "--" is the separator.
Karel Zak [Mon, 11 May 2026 11:25:20 +0000 (13:25 +0200)]
Merge branch 'PR/tests-subtest-lifecycle' of https://github.com/karelzak/util-linux-work
* 'PR/tests-subtest-lifecycle' of https://github.com/karelzak/util-linux-work:
tests: (findmnt) add missing ts_finalize_subtest
tests: add ts_finalize_subtest before return in functions
tests: add ts_finalize_subtest before continue in loops
tests: move ts_finalize_subtest after if/else blocks
tests: add subtest status tracking to ts_finalize_subtest
Karel Zak [Mon, 11 May 2026 11:24:58 +0000 (13:24 +0200)]
Merge branch 'PR/build-sys-libeconf-split' of https://github.com/karelzak/util-linux-work
* 'PR/build-sys-libeconf-split' of https://github.com/karelzak/util-linux-work:
meson: check slang headers only when slang library is found
meson: rename logindefs_c to lib_common_logindefs
meson: split shells.c out of lib_common into lib_common_shells
build-sys: drop libcommon_shells from binaries that only need ul_default_shell
lib: split ul_default_shell() from shells.c into default_shell.c
Karel Zak [Mon, 11 May 2026 09:59:23 +0000 (11:59 +0200)]
tests: (lsfd) fix IPv4 label in lsfd_check_udp_lite skip message
The local variable $ip is reset to empty for IPv4 (to form the
"udp" command name), so the skip message "no UDP-Lite available
(IPv$ip)" was printing "(IPv)" instead of "(IPv4)". Use $1
which retains the original argument.
Karel Zak [Mon, 11 May 2026 09:58:44 +0000 (11:58 +0200)]
Merge branch 'test_mkfds--make-udplite-optional' of https://github.com/masatake/util-linux
* 'test_mkfds--make-udplite-optional' of https://github.com/masatake/util-linux:
tests: (lsfd/mkfds-udp*) make UDPLite related test cases skippable
tests: (lsfd/option-inet{,-udp}) make UDPLite related test case skippable
tests: (lsfd) add a function checking the availability of UDPLite socket
tests: (lsfd::mkfds-udp) fix confusion between UDP and UDPLite
Karel Zak [Mon, 11 May 2026 09:12:43 +0000 (11:12 +0200)]
Merge branch 'fix/bits_return_value_check' of https://github.com/echoechoin/util-linux
* 'fix/bits_return_value_check' of https://github.com/echoechoin/util-linux:
bits: add --fail-width option to reject out-of-range CPU numbers
bits: add test for invalid token in cpulist_parse()
bits: improve error message for out-of-range cpulist_parse()
cpuset: Validate full tokens in cpulist_parse()
bits: fix return value check for cpulist_parse()
Karel Zak [Wed, 6 May 2026 11:28:16 +0000 (13:28 +0200)]
tests: add ts_finalize_subtest before continue in loops
In loops where ts_skip_subtest is called before continue,
add ts_finalize_subtest to properly close the subtest block
before skipping to the next iteration.
Karel Zak [Wed, 6 May 2026 11:25:05 +0000 (13:25 +0200)]
tests: move ts_finalize_subtest after if/else blocks
Move ts_finalize_subtest out of individual if/else branches and
place it unconditionally after the entire block. This enforces
the ts_init_subtest/ts_finalize_subtest pairing introduced in
the previous commit.
Previously, ts_skip_subtest or ts_failed_subtest was used as a
terminal action instead of ts_finalize_subtest. Now each subtest
is a proper init/finalize block, with ts_skip_subtest and
ts_failed_subtest only setting state within the block.
Karel Zak [Wed, 6 May 2026 11:19:11 +0000 (13:19 +0200)]
tests: add subtest status tracking to ts_finalize_subtest
Add TS_SUBFAILED and TS_SUBSKIPPED flags that are set by
ts_failed_subtest and ts_skip_subtest respectively, and
cleared by ts_init_subtest.
ts_finalize_subtest now checks these flags before running the
diff comparison. If the subtest was already marked as failed or
skipped, it respects that status instead of unconditionally
running ts_gen_diff (which could report OK over a previous
failure).
Remove ts_init_core_env from ts_skip_subtest — environment
reset is now handled exclusively by ts_finalize_subtest, making
ts_init_subtest/ts_finalize_subtest the only paired open/close
for every subtest.
Add runtime guards: ts_init_subtest and ts_finalize both call
ts_failed if TS_SUBNAME is still set from a previous subtest
that was never finalized. This makes missing ts_finalize_subtest
calls a hard test failure, detectable in CI.
Karel Zak [Mon, 4 May 2026 12:15:45 +0000 (14:15 +0200)]
meson: check slang headers only when slang library is found
The slcurses.h and slang*.h headers were detected unconditionally
in the generic header check loop. When the headers existed on the
system but slang was not actually used (ncurses preferred), irqtop
and cfdisk would include slcurses.h instead of ncurses.h, causing
build failures for ncurses-specific functions like vw_printw() and
resizeterm().
Move slang header checks after slang library detection, guarded by
lib_slang.found(), matching the autotools behavior where these
headers are only checked with --with-slang.
Karel Zak [Mon, 4 May 2026 12:04:34 +0000 (14:04 +0200)]
meson: rename logindefs_c to lib_common_logindefs
Rename the logindefs static library variable from logindefs_c to
lib_common_logindefs for consistency with lib_common_shells and
the autotools libcommon_logindefs.la naming.
Karel Zak [Mon, 4 May 2026 12:02:39 +0000 (14:02 +0200)]
meson: split shells.c out of lib_common into lib_common_shells
Remove shells.c from lib_common_sources and build it as a separate
static library (lib_common_shells) with lib_econf dependency.
Link lib_common_shells only into binaries that use the econf-dependent
shell enumeration functions (is_known_shell, print_shells,
open_etc_shells): chsh, su, runuser, login.
Other binaries that only need ul_default_shell() get it from
lib_common via default_shell.c and don't need libeconf.
Karel Zak [Mon, 4 May 2026 11:59:47 +0000 (13:59 +0200)]
build-sys: drop libcommon_shells from binaries that only need ul_default_shell
Now that ul_default_shell() lives in libcommon, binaries that only
call this function no longer need to link against libcommon_shells
(and transitively libeconf).
Remove libcommon_shells linkage from: flock, unshare, nsenter,
script, scriptlive, more.
Keep libcommon_shells for: login, chsh, su, runuser — these use
is_known_shell(), print_shells() or open_etc_shells() which depend
on libeconf.
Karel Zak [Mon, 4 May 2026 11:57:41 +0000 (13:57 +0200)]
lib: split ul_default_shell() from shells.c into default_shell.c
Move ul_default_shell() and UL_SHELL_* flags into a new
lib/default_shell.c and include/default_shell.h pair, and add the
new file to libcommon (autotools and meson).
ul_default_shell() has no dependency on libeconf -- it simply checks
$SHELL, passwd, and falls back to _PATH_BSHELL. Separating it from
shells.c (which depends on libeconf for /etc/shells enumeration)
allows binaries that only need the default shell lookup (flock,
script, scriptlive, more, exec_shell.c users) to avoid unnecessary
libeconf linkage.
Update callers that only use ul_default_shell() to include
default_shell.h instead of shells.h.
This patch enables support for the PID:inode address format.
It removes a sentinel value from ctl->pid that controls the PID
parsing behavior and introduces a dedicated variable parse_pid
(member of struct chrt_ctl), which makes the code a bit more
readable and coherent.
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Masatake YAMATO [Wed, 6 May 2026 09:39:13 +0000 (18:39 +0900)]
tests: (lsfd/option-inet{,-udp}) make UDPLite related test case skippable
Fixes #4311
Linux 7.1-rc1 has removed UDP Lite.
In the test case lsfd/option-inet, UDP Lite was must.
This change moves UDPLite related test parts to a new test
case lsfd/option-inet-udp and makes lsfd/option-inet-udp
skippable on the platform where UDPLite is not implemented.
Karel Zak [Thu, 7 May 2026 11:44:36 +0000 (13:44 +0200)]
Merge branch 'fix/drop_caches_container' of https://github.com/echoechoin/util-linux
* 'fix/drop_caches_container' of https://github.com/echoechoin/util-linux:
tests: skip fallocate/zero-range test when /proc/sys/vm/drop_caches is not writable
WanBingjiang [Thu, 7 May 2026 07:27:31 +0000 (15:27 +0800)]
tests: skip fallocate/zero-range test when /proc/sys/vm/drop_caches is not writable
The build (compat, ubuntu:18.04) CI job runs inside a Docker container
where /proc/sys/vm/drop_caches is read-only. Falling back to fallocate
--report-holes with stale VFS cache yields 0 holes instead of 1, causing
the test to fail.
WanBingjiang [Thu, 7 May 2026 01:47:25 +0000 (09:47 +0800)]
bits: add --fail-width option to reject out-of-range CPU numbers
By default, cpulist_parse() silently ignores values wider than the
cpuset size (fail=0). The new -f/--fail-width flag switches to fail=1,
causing bits to error out with "bit list wider than cpuset size" when
any CPU number exceeds the --width limit.