Karel Zak [Mon, 5 Jan 2026 11:34:58 +0000 (12:34 +0100)]
Merge branch 'add_annotate_opt_lscpu' of https://github.com/cgoesche/util-linux-fork
* 'add_annotate_opt_lscpu' of https://github.com/cgoesche/util-linux-fork:
lscpu: add --annotate info to man page
bash-completion: (lscpu) add --annotate option
lscpu: add column header annotations for -C and -e
Karel Zak [Mon, 5 Jan 2026 11:32:13 +0000 (12:32 +0100)]
Merge branch 'fix_readprofile_mapfile_option' of https://github.com/cgoesche/util-linux-fork
* 'fix_readprofile_mapfile_option' of https://github.com/cgoesche/util-linux-fork:
readprofile: (manpage) fix incorrect file name in --mapfile description
Karel Zak [Mon, 5 Jan 2026 11:29:36 +0000 (12:29 +0100)]
Merge branch 'fix/check_long_opts_integrity_usage' of https://github.com/cgoesche/util-linux-fork
* 'fix/check_long_opts_integrity_usage' of https://github.com/cgoesche/util-linux-fork:
readprofile: fix memory leak related to boot_uname_r_str() in usage()
lslogins: ignore special long options in CI CHECK
setpriv: fix usage message inconsistency
newgrp: provide --command info in output message
logger: ignore libsystemd-dependent long opt in CI CHECK
ci: add usage message consistency check to CI CHECK phase
su-common: ignore runuser(1) specific long option in CI CHECK
nologin: ignore well-known shell command-line options in CI CHECK
unshare: fix inconsistency in usage message
flock: resolve consistency issue in the usage message
nsenter: ignore SELinux-specific long option in CI CHECK
namei: ignore SELinux-specific long option in CI CHECK
lsclocks: fix inconsistency in usage message
hwclock: mark non-standard long options to ignore in CI CHECK
tools: (get-options.sh) skip programs that do not use <struct option>
tools: (get-options.sh) ignore long opt definitions marked with IGNORECHECK=yes
tools: (checkusage.sh) verify the completeness of listed long options
ci: add usage message consistency check to CI CHECK phase
Add 'make checkusage' to the GitHub CI CHECK phase.
This ensures that all program's usage messages list all
long options defined in their respective source code.
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
tests: fdisk: add regression test for missing EBR gap between logical partitions
Add a DOS/MBR test case where the first logical partition starts at 6145
(extended start 2048). In the regressed behaviour fdisk allows the next
logical partition to start at prev_end+1, which would place its EBR
(start - 2048) inside the previous logical partition.
The expected behaviour is to require the next starting sector to be at least
prev_end + 2048 + 1 (e.g. 790528 in the testcase).
fdisk could accept adjacent logical partitions, causing the EBR for the new
logical partition to be written inside the previous partition’s data area.
This can corrupt the EBR chain.
Fix free-sector search to keep an EBR gap (first_lba) after logical partitions.
Kiran Rangoon [Mon, 29 Dec 2025 03:51:00 +0000 (22:51 -0500)]
tests: correct UUID timestamp test expectations
Update expected timestamps for additional test UUIDs to match actual
output. These test cases provide coverage for various timestamp ranges
including pre-epoch, historical, and far-future dates.
Signed-off-by: Kiran Rangoon <kiranrangoon0@gmail.com> Reviewed-by: Thomas Weißschuh <thomas@t-8ch.de>
Kiran Rangoon [Mon, 29 Dec 2025 03:50:59 +0000 (22:50 -0500)]
libuuid: fix timestamp overflow for pre-1970 dates
Use int64_t arithmetic to correctly handle timestamps before Unix epoch.
This fixes the overflow that was causing UUID timestamps from 1582 to
appear as far-future dates. Update test expectations accordingly.
Signed-off-by: Kiran Rangoon <kiranrangoon0@gmail.com> Reviewed-by: Thomas Weißschuh <thomas@t-8ch.de>
Masatake YAMATO [Mon, 29 Dec 2025 07:22:24 +0000 (16:22 +0900)]
lslocks: special-case PID for filtering (skip −1)
The PID column may be printed as −1 for locks that are not tied to a
process or are inaccessible to lslocks (e.g., permission constraints).
The libsmartcols filter engine does not support negative integers, so
PID = −1 cannot be compared reliably.
Attach the PID as cell userdata only when PID >= 0, and use that value
for filter evaluation. Rows with PID = −1 are thus excluded from PID
comparisons.
Masatake YAMATO [Mon, 15 Dec 2025 21:41:59 +0000 (06:41 +0900)]
lslocks: make SIZE filterable by normalizing to bytes
The SIZE column may be printed in raw bytes or human-readable
units (KB/MB, etc.), which makes number-based comparison impossible.
Normalize SIZE to a byte value and store it in the cell via
libsmartcols `scols_cell_set_userdata`. When evaluating filter
expressions, use the stored byte value instead of the printed SIZE.
This enables consistent numeric comparisons (e.g., -Q 'SIZE > 1M')
regardless of the output format.
Masatake YAMATO [Mon, 15 Dec 2025 20:15:30 +0000 (05:15 +0900)]
lslocks: (refactor) use global bytes in get_json_type_for_column()
`get_json_type_for_column()` used to take `representing_in_bytes`, but
every caller passed the global `bytes`. The parameter added no value
and split the ownership of the setting. Drop the parameter and read
the global `bytes` instead.
This aligns lslocks with lsblk and prepares for adding `-Q/--filter`.
lsblk also reads global `bytes` defined in lsblk.c
Karel Zak [Wed, 17 Dec 2025 11:06:35 +0000 (12:06 +0100)]
Merge branch 'feat/su_accept_gid_args' of https://github.com/cgoesche/util-linux-fork
* 'feat/su_accept_gid_args' of https://github.com/cgoesche/util-linux-fork:
unshare: use MAX_OF_UINT_TYPE instead of (type)-1
chfn: enable the use of the username or UID
unshare: use the new ul_get{grp,userpw}_str() routines
login: use new xgetuserpw() instead of xgetpwnam()
chsh: use new xgetuserpw() instead of xgetpwnam()
su: accept group name and GID in -g and -G options
tests: (su) test GID argument in --group option
lib: (pwdutils.c) new library routines to get a group/passwd struct by name or GID/UID
include/c.h: add MAX_OF_UINT_TYPE macro to get max num of an uint type
chmem: do not word a configuration failure as an instruction to the user
When the current machine does not support configuring/deconfiguring
memory, simply report that it cannot be done, instead of seemingly
telling the user to skip the configuring/deconfiguring.
Also, there is no need to mention `chmem` in the message: mentioning
just the recommended option (-e or -d) is enough. Also, consistently
terminate all four messages with a period.
This improves upon commit ab2e709600 ("chmem: improve messages").
Chris Webb [Mon, 15 Dec 2025 18:48:29 +0000 (18:48 +0000)]
unshare: fix user namespace bind mounts
unshare --user=<file> always fails because we no longer have CAP_SYS_ADMIN
in the parent user namespace after unsharing to create the new one. As with
unshare --mount=<file>, fork a child to make the bind mount instead.
Chris Webb [Mon, 15 Dec 2025 18:41:08 +0000 (18:41 +0000)]
unshare: remove get_mnt_ino() check in bind_ns_files_from_child()
get_mnt_ino() was originally introduced in c84f2590 where it was used
in a loop to wait for the parent process to unshare the mount namespace
before binding the namespace in its child.
The parent and child processes are now synchronised with eventfd, so
remove this vestigial check and the now-unused get_mnt_ino() function.
This allows bind_ns_files_from_child() to be used even when the mount
namespace isn't amongst the namespaces being unshared.
Chris Webb [Sun, 14 Dec 2025 23:18:33 +0000 (23:18 +0000)]
unshare: add --owner to set user namespace owner uid and gid
As well as the mappings between lower and upper ids, a user namespace is
associated with an owner user and group in its parent. These are set from
the uid and gid when the unshare() call is made, and determine which user
in the parent namespace has CAP_SYS_ADMIN in the child and can setns()
into it.
Add an --owner=<uid>:<gid> option which allows a privileged user to
create a user namespace on behalf of another user, mapping parent ids
and/or bind-mounting the namespace with privileges that the new owner
would not have.
Simplify the control flow around map_ids_from_child() vs mapping them
inline to avoid too many special cases. We reset mapuser and mapgroup to
-1 to signal that the mapping has been delegated to the child helper.
For completeness, we maintain the semantics of --map-root-user and
--map-current-user, binding the invoking user to root or itself in the
new namespace. However, when --owner is used, these must be handled by
a forked child as with --map-users and --map-groups.
Karel Zak [Thu, 11 Dec 2025 12:39:40 +0000 (13:39 +0100)]
fallocate: refactor --report-holes and --dig-holes output
This commit consolidates duplicate printf() calls and calculations by
introducing two new helper functions:
- update_holestat(): Tracks hole statistics and prints verbose output
for both HOLETYPE_FILE and HOLETYPE_DATA. Statistics are always
collected regardless of report mode.
- summary_holestat(): Prints summary output for file holes, data holes,
and "converted to sparse holes" message. Uses consistent formatting
with hole counts and percentages.
Changes:
- Made 'report' a global variable (like 'verbose')
- Renamed struct holes_report to struct holestat for consistency
- Changed struct fields to uintmax_t to eliminate casts in printf
- Removed 'report' parameter from dig_holes() function
- Unified dig and report modes to use single dig_holes() call
- All output strings wrapped in _() for translation
- Consistent printf() usage instead of mixed fprintf()
- Percentage format: "(%ju bytes, %.2f%% of the file)"
The refactoring eliminates ~40 lines of duplicate code while maintaining
all functionality and improving code maintainability.
Karel Zak [Wed, 10 Dec 2025 11:01:06 +0000 (12:01 +0100)]
Merge branch 'fix/consolidate_validate_pfd_ino' of https://github.com/cgoesche/util-linux-fork
* 'fix/consolidate_validate_pfd_ino' of https://github.com/cgoesche/util-linux-fork:
lib: (pidutils.c) use uint64_t instead of ino_t for seamless cross-compatibility
kill: use uint64_t as type for kill_control->pidfd_ino
lib: (pidfd-utils.c) remove extraneous _GNU_SOURCE feature test macro
lib: (pidfd-utils) new helper function to retrieve pidfd inode number
lib: (pidfd-utils.c) add a helper routine to check the pidfd fs type
kill: replace USE_KILL_WITH_PIDFD_INO ifdef with USE_PIDFD_INO_SUPPORT
include: (pidfd-utils.h) conditionally define pidfd inode support
libmount: add pidfs magic number for fstype check
include: (statfs_magic.h) add pidfs magic number
kill: use ul_get_valid_pidfd_or_err() to validate user provided pidfd inodes
include: add helper routines for opening and validating pidfds
Karel Zak [Tue, 9 Dec 2025 12:12:41 +0000 (13:12 +0100)]
libblkid: Keep NTFS name unmodified and mount driver independent
We need stable filesystem names (types) even though there are multiple
filesystem drivers. libmount now provides a way to map the stable
fs-types to various mount-types.
Karel Zak [Tue, 9 Dec 2025 12:02:11 +0000 (13:02 +0100)]
libmount: add option to override fs-type with mount-type
This patch introduces an internal libmount method to convert fs-type
(as provided by libblkid or udevd) to mount-type to specify a different
mount driver.
Currently, the mapping from fs-type to mount-type is hardcoded in
libmount as a temporary solution. The final implementation should
provide configuration files (e.g., /etc/mount/fs.d/<name>) for these
mappings.
The current default mapping is implemented only for NTFS. It can be
modified during compilation with:
./configure --with-ntfs-mounttype=TYPE
or
meson setup build -D ntfs-mounttype=TYPE
The default is "ntfs3".
Addresses: https://github.com/util-linux/util-linux/pull/3618
Addresses: https://github.com/systemd/systemd/pull/39982 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 25 Nov 2025 11:56:07 +0000 (12:56 +0100)]
libmount: read from udev, add --disable-libmount-udev-support
The library traditionally uses libblkid to obtain device properties
(such as FS-type if not specified). This can be a relatively costly
operation to scan the device and requires read access to the device.
All relevant libblkid information is usually cached by the udev DB.
This commit adds the possibility to reuse the information from udev,
with a fallback to libblkid if udev is not available.
Karel Zak [Mon, 8 Dec 2025 08:59:41 +0000 (09:59 +0100)]
Merge branch 'fix/login_shell_arg_null_str' of https://github.com/cgoesche/util-linux-fork
* 'fix/login_shell_arg_null_str' of https://github.com/cgoesche/util-linux-fork:
login: duplicate --shell argument to avoid nulling through explicit_bzero()