Karel Zak [Thu, 21 Aug 2025 09:35:17 +0000 (11:35 +0200)]
lscpu: use maximum CPU speed from DMI, avoid duplicate version string
* Read maximum CPU speed from DMI
* Don't use max speed if nonsensical
* Avoid appending "CPU @ speed" to the version string if it's already included.
(This is a code robustness improvement as DMI is currently read for ARMs only,
and the issue was detected on Intel.)
Fixes: https://github.com/util-linux/util-linux/commit/a772d7c493afcec32f0123fc947013f74db6e45d Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit c332544d215ccb466a64a441eb5a421b9fe8cdfd)
Karel Zak [Thu, 27 Nov 2025 15:46:22 +0000 (16:46 +0100)]
whereis: fix const qualifier warnings for C23
Fix const qualifier discarded warnings in dirlist_add_subdir() and
lookup() functions. These warnings are reported by gcc 15 which
defaults to the C23 standard.
The strchr() and strrchr() functions return pointers into const strings,
so the receiving variables must be declared as const char *.
Karel Zak [Thu, 27 Nov 2025 15:43:38 +0000 (16:43 +0100)]
logger: fix const qualifier warnings for C23
Fix const qualifier discarded warnings in valid_structured_data_param()
and valid_structured_data_id() functions. These warnings are reported by
gcc 15 which defaults to the C23 standard.
The strchr() and strstr() functions return pointers into const strings,
so the receiving variables must be declared as const char *.
Karel Zak [Thu, 27 Nov 2025 15:38:18 +0000 (16:38 +0100)]
lsfd: fix const qualifier warning in strnrstr
Fix const qualifier discarded warning in strnrstr().
This warning is reported by gcc 15 which defaults to the C23 standard.
The function returns a non-const pointer into the haystack parameter,
and callers modify the string through that pointer. Therefore, the
haystack parameter should be char * rather than const char *.
Karel Zak [Thu, 27 Nov 2025 15:35:56 +0000 (16:35 +0100)]
lsfd: fix const qualifier warning in new_counter_spec
Fix const qualifier discarded warning in new_counter_spec().
This warning is reported by gcc 15 which defaults to the C23 standard.
The function modifies the input string by inserting a null terminator
to split it into name and expression parts, so the parameter should
be char * rather than const char *.
Karel Zak [Thu, 27 Nov 2025 15:28:41 +0000 (16:28 +0100)]
libblkid: fix const qualifier warning in blkid_parse_tag_string
Fix const qualifier discarded warning in blkid_parse_tag_string().
This warning is reported by gcc 15 which defaults to the C23 standard.
The strchr() function returns a pointer into a const string, so
introduce a separate 'eq' variable to hold this const pointer for
finding the '=' separator. Also move the 'cp' variable declaration
into the block where it's actually used for quote handling.
Karel Zak [Thu, 27 Nov 2025 15:24:11 +0000 (16:24 +0100)]
libmount: fix const qualifier warning in mnt_parse_mountinfo_line
Fix const qualifier discarded warning in mnt_parse_mountinfo_line().
This warning is reported by gcc 15 which defaults to the C23 standard.
The strstr() function returns a pointer into a const string, so
introduce a separate 'sep' variable to hold this const pointer,
keeping 'p' for non-const unmangle() results that need to be freed.
Karel Zak [Thu, 27 Nov 2025 14:45:55 +0000 (15:45 +0100)]
libmount: fix const qualifier warnings for C23
Fix const qualifier discarded warnings in optlist_add_flags(),
mnt_opt_value_with(), and mnt_optstr_apply_flags() functions.
These warnings are reported by gcc 15 which defaults to the C23 standard.
The strchr() and strstr() functions return pointers into const strings,
so the receiving variables must be declared as const char *.
Karel Zak [Thu, 27 Nov 2025 14:41:21 +0000 (15:41 +0100)]
lsns: fix const qualifier warnings for C23
Fix const qualifier discarded warnings in read_persistent_namespaces()
and is_path_included() functions. These warnings are reported by gcc 15
which defaults to the C23 standard.
The strchr() and strstr() functions return pointers into const strings,
so the receiving variables must be declared as const char *.
Karel Zak [Thu, 27 Nov 2025 09:27:07 +0000 (10:27 +0100)]
lib, lscpu: fix const qualifier discarded warnings in bsearch
Fix compilation warnings from newer compilers with stricter
const-correctness checks. When bsearch() searches in const arrays,
the result pointer must also be const to avoid discarding the
const qualifier.
Fixed in:
- lib/color-names.c: searching in static const basic_schemes[]
- sys-utils/lscpu-cputype.c: searching in const pattern arrays
The warnings were:
lib/color-names.c:62:13: error: assignment discards 'const'
qualifier from pointer target type
[-Werror=discarded-qualifiers]
Munehisa Kamata [Tue, 28 Oct 2025 19:54:17 +0000 (12:54 -0700)]
wdctl: remove -d option leftover
-d option was removed in commit f56338b43973 ("wdctl: allow to specify more
than one device"), but the optstring wasn't updated at that time and wdctl
can still accept the option halfway as below:
$ wdctl -d
wdctl: option requires an argument -- 'd'
whereas it should say:
wdctl: invalid option -- 'd'
So update the optstring.
Fixes: f56338b43973 ("wdctl: allow to specify more than one device") Signed-off-by: Munehisa Kamata <kamatam@amazon.com>
(cherry picked from commit 56e2c86c2c7ea012b63cd896d9ca3daa34f19565)
Karel Zak [Thu, 30 Oct 2025 11:11:43 +0000 (12:11 +0100)]
libfdisk: (dos) fix off-by-one in maximum last sector calculation
The get_disk_ranges() function incorrectly capped the last usable
sector at UINT_MAX, which could cause an overflow when calculating
partition size for MBR partition tables.
MBR stores partition size as a 32-bit value with maximum UINT_MAX.
The partition size is calculated as: size = stop - start + 1
For a partition starting at sector 0:
- If stop = UINT_MAX: size = UINT_MAX + 1 (overflow!)
- If stop = UINT_MAX - 1: size = UINT_MAX (correct maximum)
This fixes the inconsistency where dos_init() correctly warns about
disks larger than UINT_MAX sectors (2TiB - 512 bytes for 512-byte
sectors), but get_disk_ranges() allowed creating partitions that
would overflow the 32-bit size field.
Addresses: https://issues.redhat.com/browse/RHEL-122367 Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit 578923fe582903628ecc0d2a434af0affa3660d2)
umount: consider helper return status for success message
If a helper function was executed to unmount, we simply return
without any user feedback. That can unintentionally surpress
verbose messages (`--verbose`) for non-root users who use udisks2
to mount filesystems, and unmount via the unmount.udisks2 helper.
It would be better to check the helper return status as well for
completeness and a more reliable way to test the success of the
unmount operation.
mnt_context_get_helper_status() is only called if the helper was
executed, i.e. mnt_context_helper_executed == 1, anything else
wouldnt make sense anyways.
Karel Zak [Tue, 23 Sep 2025 08:46:59 +0000 (10:46 +0200)]
liblastlog2: fix operator precedence in conditional assignments
Fix operator precedence in ll2_rename_user() where != comparison was
taking precedence over assignment, causing retval to be assigned 0 or 1
instead of the actual function return value.
Fixes: https://github.com/util-linux/util-linux/issues/3756 Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit 2348237f059ddb8ff4bc255235766771e1af3dd1)
Karel Zak [Thu, 2 Oct 2025 11:38:13 +0000 (13:38 +0200)]
bash-completion: add bits to dist tarball
The bits command was added in commit 6e1301d59 (text-utils: add bits
command) but the bash-completion file was not added to the autotools
Makemodule.am, causing it to be missing from release tarballs.
This resulted in meson build failures when using the tarball with
bash-completion installed, as meson.build references the file but
it doesn't exist in the tarball.
Fixes: https://github.com/util-linux/util-linux/issues/3766 Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit eb0e08a76e3ebd4571b957e727847060304c32bb)
- Only works on stable/* branches (releases are generated from stable branches)
- Supports util-linux versioning: vX.Y (major), vX.Y.Z (maintenance)
- Command-line options: --rc, --release-master, --release-update
- Safety check prevents --release-master on branches with existing releases
- Testing support via --last-release and --last-xy-release overrides
Version Schema:
Major releases: vX.Y-rc1, vX.Y-rc2, [vX.Y-rc3], vX.Y
Maintenance releases: vX.Y.Z-rc1, vX.Y.Z
Sam Fink [Wed, 17 Sep 2025 14:04:51 +0000 (10:04 -0400)]
libblkid: Fix probe_ioctl_tp assigning BLKGETDISKSEQ as physical sector size
Fix issue introduced by PR#2908 in probe_ioctl_tp where the BLKGETDISKSEQ ioctl
result is incorrectly assigned to the topology with
blkid_topology_set_physical_sector_size instead of blkid_topology_set_diskseq.
This issue was observed while using a Debian 13 container on a RHEL 9.4 host
attempting to format a volume. The physical sector size was incorrectly
reported as 3. This issue also presents with the fdisk command,
which also uses this library to resolve physical sector size of devices.
(Mentioning -u instead of -n, and falsely claiming emptiness.)
Now the above command will report:
blkid: invalid argument: no
(I don't think option -n needs to be mentioned, as it will be obvious
when inspecting the command line. Not mentioning the option allows
reusing an existing error message, avoiding needless ballooning and
allowing the patch to be applied to the stable branch.)
Karel Zak [Thu, 11 Sep 2025 07:35:58 +0000 (09:35 +0200)]
libmount: don't report fsconfig errors with "nofail"
The new kernel API returns EINVAL on FSCONFIG_CMD_CREATE if the mount
source is inaccessible. We do not want to report this as an error when
the "nofail" mount option is specified.
Note that EINVAL may also be returned by other fsconfig() settings, so
we need to check whether a source is specified and whether it is really
inaccessible. This is just a heuristic (as with the old mount(2)).
Fixes: https://github.com/util-linux/util-linux/issues/3741 Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit 8a7bc1ab00d91e8a17ca8cb2907ca3c2a73381dd)
Karel Zak [Wed, 3 Sep 2025 08:54:06 +0000 (10:54 +0200)]
libfdisk: (script) fix device name separator parsing
In the named-fields script format, the colon is used as the separator
between the device name and other values. The device name may also
contain colons. This commit ensures it is treated as a separator only
when there is a space before or after the colon.
Note that the device name is optional and may be omitted. There is no
escaping for problematic characters in the name. Use " : " as the
separator.
Fixes: https://github.com/util-linux/util-linux/issues/3723 Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit 4eab9175dfd62c1d1a0bbc43a49ca8a85e9adac7)
Jiang XueQian [Sat, 30 Aug 2025 09:02:59 +0000 (17:02 +0800)]
zramctl: ignore ENOENT when setting max_comp_streams
The `max_comp_streams` attribute of zram devices has been deprecated and
all writes were silently ignored by the kernel since 2016. It was
finally removed in 6.15, causing zramctl to fail on ENOENT, when it
should just ignore the error.
cgoesche [Fri, 22 Aug 2025 21:31:24 +0000 (17:31 -0400)]
getopt: document special symbols that should not be used as option characters
getopt(3) routines return `?` or `:` when an unknown option character is encountered
or an option is missing its required argument, respectively. It also disallows
`;` as an option character. Documenting this makes users aware that they may not use
these reserved symbols as option characters, e.g. `-?` which is used in some older programs.
Jérôme Poulin [Fri, 22 Aug 2025 03:54:17 +0000 (23:54 -0400)]
zramctl: fix MEM-USED column description
The MEM-USED column was incorrectly documented as showing current
memory consumption. This is due to confusing naming in the kernel's
zram implementation:
- Kernel field "mem_used_total" (3rd in mm_stat) = current memory usage
- Kernel field "mem_used_max" (5th in mm_stat) = peak memory usage
zramctl maps these as:
- TOTAL column <= mem_used_total (current usage)
- MEM-USED column <= mem_used_max (peak usage)
The misleading "MEM-USED" name suggests current usage, but it actually
shows the peak memory usage (high water mark) since device creation
or last reset. This is tracked by the kernel's max_used_pages which
only increases when current usage exceeds the stored maximum.
Fixed description from:
"memory zram have been consumed to store compressed data" to
"peak memory usage to store compressed data".
logger: fix incorrect warning message when both --file and a message are specified
Logger warns that when both --file and a message are given, the message is ignored.
It does the opposite. Fix the warning message to conform to the observed behavior.
Example:
echo "You will not see this file in the log" > file.txt
logger -f file.txt "You will see this message in the log"
tests/helpers/test_sigstate.c: explicitly reset SIGINT to default action after trapping
After upgrading bash to 5.3 to contain commit [1], if SIGINT was trapped in
asynchronous subshell, bash called set_signal_async_ignored to make sure
processes that are created by this asynchronous subshell to ignore SIGINT.
And it caused test case `kill/decode' failed, the signal INT was existed in
both of Blocked and Ignored
Karel Zak [Mon, 21 Jul 2025 06:16:25 +0000 (08:16 +0200)]
setpriv: Improve getgroups() Portability
setpriv(1) is Linux-only, and on Linux, getgroups() returns at least one group.
However, it's better to use more portable and generic code patterns and assume
that getgroups() can return zero.
Fixes: https://github.com/util-linux/util-linux/issues/3654 Reported-by: Alejandro Colomar <alx@kernel.org> Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit 434a5633a563066357bbc3f331838ed41041ec1a)
bash-completion: fix function name of enosys completion
The function "_enosys_module" referenced by the completion setting on
the last line of "bash-completion/enosys" is not defined in the
current master. As reported in Ref. [1], this causes the following
error on an attempt at argument completion for the "enosys" command:
Also, the function "_waitpid_module" defined in
"bash-completion/enosys" overwrites another completion function of the
same name defined in "bash-completion/waitpid". This patch renames
the function in "bash-completion/enosys" to the correct one,
"_enosys_module".
Karel Zak [Mon, 30 Jun 2025 10:20:13 +0000 (12:20 +0200)]
more: temporarily ignore stdin when waiting for stderr
more waits for user commands on stderr, but at the same time, it
monitors sigalfd and stdin (for data and POLLHUP|POLLNVAL). We need to
temporarily ignore stdin if there is new data waiting for read()
(e.g., dmesg | more); otherwise, more_key_command() will end in a busy
loop.
Fixes: https://github.com/util-linux/util-linux/issues/3634 Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit 85cbb5f5449be75d51b064681f0d92adf31f59be)