(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)
Karel Zak [Tue, 29 Apr 2025 10:29:32 +0000 (12:29 +0200)]
hardlink: fix performance regression (inefficient signal evaluation)
During work on better verbose output, I found a regression between
v2.40 and v2.41 (and v2.42). In the new version, hardlink is 3-4 times
slower.
The problem is in the function where we verify signals. It calls the
function signal() even though no signal is delivered. It's called in
code loops where hardlink scans files, making it a performance-sensitive
area.
Another significant performance improvement is using an inline function
for handle_interrupt().
This simple patch improves hardlink performance by 10 times.
Fixes: http://github.com/util-linux/util-linux/commit/1453200e22dd4ec858be027653c167225f2fb358 Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit 87831fa19e241803f93556cbeaad153e6ba89b6c)
Karel Zak [Tue, 29 Apr 2025 09:49:23 +0000 (11:49 +0200)]
hardlink: Use macro for verbose output
Now that jlog() is a function, all gettext() arguments are evaluated
in all cases, including when output is unnecessary due to --quiet or
low verbose mode.
Fixes: https://github.com/util-linux/util-linux/issues/3548 Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit 5a2600c55f278c1252708cb3bdede92e27ccd04e)
Stanislav Brabec [Fri, 16 May 2025 01:10:14 +0000 (03:10 +0200)]
libblkid: Fix crash while parsing config with libeconf
As the whole econf_file structure is freed by econf_free(file) at the end
of blkid_read_config(), econf_file structure cannot be defined as static
and initialized only once. The econf_free() is not robust enough and keeps
a pointer to the garbage after the first call of blkid_read_config(). And
if /etc/blkid.conf does not exist, it is called second time.
Karel Zak [Thu, 22 May 2025 08:01:03 +0000 (10:01 +0200)]
lsblk: use ID_PART_ENTRY_SCHEME as fallback for PTTYPE
The udev database typically inherits the ID_PART_TABLE_TYPE property
from the entire disk device to its partitions. However, in some cases,
this property may be missing. Fortunately, blkid/udev also provides
ID_PART_ENTRY_SCHEME for all partitions.
Fixes: https://github.com/util-linux/util-linux/issues/3570 Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit 23a7e0865ad56c46a69084974182b9979592b867)
remove two leftover license lines from colors.{c,h}
Last March, commit 549a517857 replaced the SPDX line in three files
with a "No copyright is claimed" phrase, but forgot to remove from
two of those files the text lines that correspond to the SPDX.
The documentation comment for scols_column_set_data_func was missing the
second asterisk in its opening marker, causing the contents to be
omitted from the rendered documentation.
Using strerror is not safe in shared libraries as it is unknown
what the calling apps may do with the storage behind the scenes.
Using %m is ok, except in contexts that need to be as-safe.
Thomas Weißschuh [Sat, 19 Apr 2025 20:02:11 +0000 (22:02 +0200)]
include/mount-api-utils: include linux/unistd.h
If SYS_statmount/SYS_listmount is not provided by the libc,
util-linux will fall back to __NR_statmount/__NR_listmount from the
kernel UAPI headers.
However it is not guaranteed that these symbols are actually visible in
mount-api-utils.
Include linux/unistd.h which provides syscall numbers.
While this header is specific to Linux, the code is already using
linux/mount.h.
Eugene Gershnik [Mon, 6 May 2024 16:29:39 +0000 (09:29 -0700)]
libuuid: fix uuid_time on macOS without attribute((alias))
Weak aliases are not supported by clang on Darwin.
Instead this fix uses inline asm to make `_uuid_time` an alias to
`___uuid_time`
It appears that on macOS the time API is purely 32 or 64 bit depending
on the build type. There is no ABI issue on that platform and `uuid_time`
can be unconditionally aliased to `_uuid_time`. This is all conjectural,
however, since I have no ability to make 32-bit builds for macOS - the
Apple toolchain doesn't support this since 2019.
Karel Zak [Mon, 7 Apr 2025 11:49:43 +0000 (13:49 +0200)]
treewide: fix optional arguments usage
In some parts of the code, the optional argument handling is missing
for cases where the argument starts with '='. This is particularly
important for short options with optional arguments, as suggested by
our man pages. The libc getopt_long() handles this for long options,
but for short options, it's our responsibility.
Note that some argument parsing functions (mostly colormode_or_err())
already implement this, as they are usually used with optional
arguments.
Thomas Devoogdt [Mon, 7 Apr 2025 12:20:12 +0000 (14:20 +0200)]
namespace.h: fix compilation on Linux < 4.10
sys-utils/lsns.c: In function ‘add_namespace_from_sock’:
sys-utils/lsns.c:580:19: error: ‘SIOCGSKNS’ undeclared (first use in this function)
nsfd = ioctl(sk, SIOCGSKNS);
^~~~~~~~~