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
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>
fincore: do not fall back to mincore if cachestat fails with EPERM
cachestat() and mincore() both require that the tested file is
(potentially) writable by the current user. If this permission check
fails, cachestat() will return EPERM while mincore() will simply mark
all pages as resident in core, as a proper EPERM would violate its API
contract. But when cachestat() fails with EPERM we know that mincore()
will not return real data, so instead show an error message.
Reported-by: Christian Hesse <mail@eworm.de> Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
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>
Bastian Krause [Fri, 24 Oct 2025 15:32:20 +0000 (17:32 +0200)]
hwclock: skip RTC_PARAM_SET for --param-set with unchanged value
Parameters set with `hwclock --param-set` tend to be persisted in the
RTC's EEPROM. Writing the same value over and over again can wear out
the EEPROM (e.g. on each boot).
So read the current value first. Only if the parameter is changed,
actually write the new value.
This allows for easier integrations, especially since there is no
machine-readable way of retrieving the current value via hwclock.
A lot of documentation on the Internet seems to assume "defaults" is the
/correct/ default value when no other options are intended.
Documentation/example.files/fstab does not have an entry for swap, but
it shows "defaults" for other file systems.
It seems prudent to align on a single variant, at least in the
documentation, even if both are accepted by swapon.
Signed-off-by: Chris Hofstaedtler <zeha@debian.org>
Karel Zak [Wed, 22 Oct 2025 08:42:36 +0000 (10:42 +0200)]
mount: add note about systemd and --all historical context
Add information that mount -a was originally designed for init scripts
but many modern systemd-based distributions use systemd units instead
for mounting filesystems on boot in a more sophisticated way.
Karel Zak [Wed, 22 Oct 2025 08:36:32 +0000 (10:36 +0200)]
mount: improve --all documentation regarding swap areas
The --all option description did not mention that swap entries in
fstab are silently ignored. Add a note clarifying this behavior and
pointing users to swapon --all for enabling swap devices and files.
Karel Zak [Tue, 21 Oct 2025 09:45:54 +0000 (11:45 +0200)]
losetup: improve command line option processing
The options --detach, --remove, and --set-capacity are mutually
exclusive. We can assume the device name follows the options, which is
better than assuming the device name is specified as an option's
argument. This also allows the use of the existing mutually-exclusive
check.
Karel Zak [Tue, 21 Oct 2025 08:58:36 +0000 (10:58 +0200)]
lostup: report EACCES on loop-control
Don't start scanning /dev/loop* after a failed access to
/dev/loop-control. It's a waste of time, and the user does not receive
a relevant error message.
Karel Zak [Thu, 16 Oct 2025 10:16:27 +0000 (12:16 +0200)]
losetup: improve --remove documentation
Rewrite the --remove option description to clearly explain the
difference between --detach and --remove. Add a new LOOP DEVICE
LIFECYCLE section that describes the three stages: creation,
detachment, and removal, with corresponding ioctl names.
Karel Zak [Thu, 16 Oct 2025 09:56:08 +0000 (11:56 +0200)]
losetup: make --remove a long-only option with mutual exclusivity
Change --remove from '-R, --remove' to a long-only option '--remove'.
This makes it consistent with other administrative options and adds
mutual exclusivity with other major actions like -d, -D, -a, -c, -f,
-j, -l, and -O.
Add a new static helper function loopcxt_get_device_nr() to extract
the loop device number from the device path. This eliminates code
duplication in loopcxt_remove_device() and loopcxt_add_device().
The helper function supports both /dev/loop<N> and /dev/loop/<N>
formats and provides consistent error handling with debug logging.
Karel Zak [Thu, 16 Oct 2025 09:22:47 +0000 (11:22 +0200)]
losetup: add error feedback for --remove command
The remove_loop() function was silently failing without providing
any feedback to the user. This also fixes incorrect indentation
(spaces instead of tabs).
Signed-off-by: Karel Zak <kzak@redhat.com> Reported-by: Benno Schulenberg <bensberg@telfort.nl>
Karel Zak [Wed, 15 Oct 2025 13:46:06 +0000 (15:46 +0200)]
treewide: use is_dotdir_dirent() helper
This simplifies the code by using the is_dotdir_dirent() helper
function instead of manual strcmp() checks for "." and ".." directory
entries across multiple utilities.