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:32:15 +0000 (10:32 +0100)]
Merge branch 'lsfd--tun-netns' of https://github.com/masatake/util-linux
* 'lsfd--tun-netns' of https://github.com/masatake/util-linux:
lsfd: add TUN.DEVNETNS column
tests: (lsfd::mkfds-cdev-tun,refactor) make the case extensible
lsfd: (doc) fix English in SOCK.NETNS description
lsfd: (cleanup) add missing "break" in a case statement
lsfd: (cleanup) return 0 instead of false
lsfd: (refactor) introduce tundata struct
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]
This feature helps users inspect target processes, containers, and/or
VMs with tools such as tcpdump, wireshark, or ip-link.
However, I found a case where the device name was not sufficient.
pasta (https://passt.top/) provides networking for rootless
containers. It creates a tap device whose name matches the name of a
network device on the host:
$ ip link show ens8191
5: ens8191: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 ...
$ ethtool -i ens8191 | head -1
driver: atlantic
$ podman exec 9fbbed215871 ip link show ens8191
2: ens8191: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 65520 ...
$ podman exec 9fbbed215871 ethtool -i ens8191 | head -1
driver: tun
A name alone is not enough to identify a network device on the system.
With this change, lsfd reports the network namespace to which the
tun/tap device belongs:
Karel Zak [Thu, 20 Nov 2025 12:34:23 +0000 (13:34 +0100)]
Merge branch 'PR/mountpoint-statmount' of https://github.com/karelzak/util-linux-work
* 'PR/mountpoint-statmount' of https://github.com/karelzak/util-linux-work:
mountpoint: use single libmount cache for all path resolutions
mountpoint: add --show option to print mountpoint path
mountpoint: use statmount() syscall on modern kernels
Karel Zak [Wed, 19 Nov 2025 12:46:40 +0000 (13:46 +0100)]
mountpoint: use single libmount cache for all path resolutions
Move libmount cache initialization to main() and pass it through
the control structure. This allows the cache to be reused across
all mnt_resolve_path() calls, reducing allocations.
Also add cleanup section in main() with goto labels for proper
resource deallocation in a single location.
Karel Zak [Wed, 19 Nov 2025 12:32:25 +0000 (13:32 +0100)]
mountpoint: add --show option to print mountpoint path
Add a new --show option that prints the actual mountpoint path for
a given directory or file. This is useful for:
- Resolving any path to its containing mountpoint
- Finding the canonical mountpoint path when symlinks are involved
- Determining the mountpoint from paths within filesystems
The option requires kernel support for statmount(2) (Linux 6.8+).
On older kernels without statmount support, the option fails with
an error message, as the /proc/self/mountinfo fallback cannot
resolve arbitrary paths to their containing mountpoint.
The --show option always returns EXIT_SUCCESS (0) when it successfully
finds the mountpoint, regardless of whether the given path itself is
a mountpoint or not.
Addresses: https://github.com/util-linux/util-linux/issues/3806 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Wed, 19 Nov 2025 12:01:02 +0000 (13:01 +0100)]
mountpoint: use statmount() syscall on modern kernels
Improve mountpoint(1) to use the modern statmount() system call
(available since Linux 6.8) instead of parsing /proc/self/mountinfo.
- Works without /proc mounted on modern kernels
- More efficient than parsing /proc/self/mountinfo
- Better detection of bind mounts via statmount()
- Graceful fallback maintains compatibility
Addresses: https://github.com/util-linux/util-linux/issues/3806 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Wed, 12 Nov 2025 11:08:39 +0000 (12:08 +0100)]
Merge branch 'PR/chmem-dynamic-configuration' of https://github.com/karelzak/util-linux-work
* 'PR/chmem-dynamic-configuration' of https://github.com/karelzak/util-linux-work:
tests: update lsmem outputs
lsmem: use xstrncpy()
lsmem,chmem: add configure/deconfigure bash completion options
lsmem: add doc for dynamic (de)configuration and memmap-on-memory support
chmem: add chmem documentation for dynamic (de)configuration of memory
chmem: add support for dynamic (de)configuration of hotplug memory
lsmem: add support to display dynamic (de)configuration of memory
lsmem: display global memmap on memory parameter
Karel Zak [Mon, 10 Nov 2025 11:43:57 +0000 (12:43 +0100)]
Merge branch 'fallocate' of https://github.com/t-8ch/util-linux
* 'fallocate' of https://github.com/t-8ch/util-linux:
tests: (swaplabel) don't create test image with truncate(1)
fallocate: require posix_fallocate() from libc
fallocate: drop syscall() fallback for fallocate()
build: simplify checks for fallocate() and posix_fallocate()
tests: (swaplabel) don't create test image with truncate(1)
truncate(1) can create holes in the file. These will trigger a warning
in mkswap(1), failing the testsuite. Given that fallocate(1) now alway
supports posix_fallocate() which works on all filesystems, truncate(1)
is unnecessary anyways.
Reported-by: Christian Hesse <mail@eworm.de> Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
Recent libcs implement posix_fallocate() properly. The fallback logic
should never be used. Furthermore unconditional support for
posix_fallocate() will enable some further cleanup and fixes.
Karel Zak [Fri, 7 Nov 2025 11:19:16 +0000 (12:19 +0100)]
Merge branch 'PR/benno-losetup' of https://github.com/karelzak/util-linux-work
* 'PR/benno-losetup' of https://github.com/karelzak/util-linux-work:
losetup: (man) put the synopses in a better order, the name-giver first
losetup: remove the --verbose flag, as it doesn't actually do anything
losetup: sort 'O' correctly for the mutual-exclusive check to work
Sumanth Korikkar [Thu, 16 Oct 2025 15:38:04 +0000 (17:38 +0200)]
chmem: add chmem documentation for dynamic (de)configuration of memory
Describe chmem configure, deconfigure and memmap-on-memory options:
ff18dcb19aab ("s390/sclp: Add support for dynamic (de)configuration of
memory") s390 kernel no longer pre-adds all standby memory at boot.
Instead, users must explicitly configure a block before it can be used
for online/offline actions. At configuration time, users can dynamically
decide whether to use optional memmap-on-memory for each memory block,
where value of 1 allocates metadata (such as struct pages array) from
the hotplug memory itself, enabling hot-add operations even under memory
pressure. A value of 0 stores metadata in regular system memory, which
may require additional free memory, but enables continuous physical
memory across memory blocks.
Add documentation to reflect the following options:
* chmem --configure 128M --memmap-on-memory 1
* chmem --deconfigure 128M
* chmem --enable 128M # implicitly configure memory if supported by
architecture and online it
* chmem --disable 128M # offline memory and implicitly deconfigure if
supported by the architecture.
Just like online and offline actions, memory configuration and
deconfiguration can be controlled through similar options. Also,
memmap-on-memory setting can be changed, only when the memory block is
in deconfigured state. This means, it is usable only via --configure
option.
Reviewed-by: Maria Eisenhaendler <maria1@de.ibm.com> Signed-off-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
Sumanth Korikkar [Thu, 16 Oct 2025 15:38:03 +0000 (17:38 +0200)]
chmem: add support for dynamic (de)configuration of hotplug memory
Extend chmem to use the new s390 kernel interface for configuring and
deconfiguring hotpluggable memory blocks, with memmap-on-memory support.
Background:
On s390, memmap-on-memory was introduced to ensure that the struct page
array (metadata) for hotpluggable standby memory is allocated from the
memory block itself. This allowed hot-add operations even under memory
pressure, particularly in cases with a strong imbalance between
boot-time online memory and standby memory.
The original design, however, had few limitations:
* All hotpluggable standby memory was added at boot.
* The use of memmap-on-memory was global and static, decided at boot
time. Either all standby blocks used it, or none of them did.
* memmap-on-memory choice could not be changed at runtime, limiting
flexibility. For example, when continuous physical memory was required
later across memory blocks.
The s390 kernel ff18dcb19aab ("s390/sclp: Add support for dynamic
(de)configuration of memory") no longer pre-adds all standby memory at
boot. Instead, users must explicitly configure a block before it can be
used for online/offline actions. At configuration time, users can
dynamically decide whether to use optional memmap-on-memory for each
memory block, where value of 1 allocates metadata (such as struct pages
array) from the hotplug memory itself, enabling hot-add operations even
under memory pressure. A value of 0 stores metadata in regular system
memory and enables continuous physical memory across memory blocks.
s390 kernel sysfs interface to configure/deconfigure memory with
memmap-on-memory support looks as shown below:
lsmem -o RANGE,SIZE,STATE,BLOCK,CONFIGURED,MEMMAP-ON-MEMORY
RANGE SIZE STATE BLOCK CONFIGURED MEMMAP-ON-MEMORY
0x00000000-0x7fffffff 2G online 0-15 yes no
0x80000000-0xffffffff 2G offline 16-31 no yes
Memory block size: 128M
Total online memory: 2G
Total offline memory: 2G
Memmap on memory parameter: yes
Just like online and offline actions, memory configuration and
deconfiguration can be controlled through similar options. Also,
memmap-on-memory setting can be changed, only when the memory block is
in deconfigured state. This means, it is usable only via --configure
option.
Sumanth Korikkar [Thu, 16 Oct 2025 15:38:02 +0000 (17:38 +0200)]
lsmem: add support to display dynamic (de)configuration of memory
Extend lsmem to display (de)configured blocks and memmap_on_memory
state. With the new s390 kernel interface (linux-next) ff18dcb19aab
("s390/sclp: Add support for dynamic (de)configuration of memory"),
standby memory blocks are no longer pre-added at boot, but must be
explicitly configured before being eligible for online/offline
operations. At configuration time, users can also decide whether to use
memmap-on-memory per block.
Add CONFIGURED column : indicate if a memory block has been explicitly
configured.
Add MEMMAP-ON-MEMORY column : indicate if a memory block uses
memmap-on-memory.
Sumanth Korikkar [Thu, 16 Oct 2025 15:38:01 +0000 (17:38 +0200)]
lsmem: display global memmap on memory parameter
Display the output of global memmap-on-memory parameter for memory
hotplug. Retrieve the details via
/sys/module/memory_hotplug/parameters/memmap_on_memory.
lsmem
RANGE SIZE STATE REMOVABLE BLOCK
0x0000000000000000-0x00000001ffffffff 8G online yes 0-63
Memory block size: 128M
Total online memory: 8G
Total offline memory: 0B
Memmap on memory parameter: yes
cgoesche [Sun, 2 Nov 2025 16:55:09 +0000 (11:55 -0500)]
su: pass arguments after <user> to shell
The su(1) manpage describes how the arguments after <user>
are passed to the invoked shell. However this is empirically
wrong, as option flags after <user> are interpreted by su(1)
and will eventually never be passed or yield an error that
terminates the program due to an unrecognized option flag.
To fix this we can change getopt(3)'s scanning mode with a '+'
prefixed to 'optstring', this will make it so that getopt(3)
stops processing argv elements on the first occurrence of a
non-option argument, e.g. '-' or '<user>'.
Additionally, if the argument that directly follows '-' is an
option flag, su(1) will assume that this argument and the ones
that follow, are to be passed to a shell invoked by the root user.
losetup: remove the --verbose flag, as it doesn't actually do anything
Fourteen years ago, commit c7e0925def rewrote the `losetup` tool,
removing all references to the 'verbose' variable. Three years
later, commit 60cb2c3720 removed the line 'verbose = 1' because
the compiler complained that the variable was set but never used.
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>