Karel Zak [Wed, 4 Feb 2026 09:48:48 +0000 (10:48 +0100)]
Merge branch 'dmesg_oob' of https://github.com/stoeckmann/util-linux
* 'dmesg_oob' of https://github.com/stoeckmann/util-linux:
dmesg: Check if file is too large
dmesg: Only check for newline if input exists
dmesg: Check input length before calling strtol
Karel Zak [Wed, 4 Feb 2026 08:53:51 +0000 (09:53 +0100)]
Merge branch 'check_test_coverage' of https://github.com/cgoesche/util-linux-fork
* 'check_test_coverage' of https://github.com/cgoesche/util-linux-fork:
tests: search for all executable scripts in test subdirs
build-sys: add a target for tools/testcoverage.sh
tools: (get-options.sh) refine regex for unsupported programs to avoid false positives
tools: expand relative paths provided by $top_srcdir for robustness
tools: helper script to generate a test coverage report
tools: (get-options.sh) ensure functionality for out-of-tree builds
tests: search for all executable scripts in test subdirs
Instead of looking for scripts that contain ts_init()
look for all executable scripts as some of them contain
helper functions with commands and long options.
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
tools: helper script to generate a test coverage report
This script uses a heuristic approach to determine an approx.
test coverage of all util-linux tools. It does this by simply
looking at all the test scripts for a given tool and compares
the long options seen in them with all available ones for the
concerned tool. It also reports if a tool is either missing a
test subdirectory in tests/ts or doesn't have any test script
at all.
This script is not necessarily intended to be ran for build
tests but rather for code quality checks and to help util-linux
developers to get a better overview of their testing infrastructure
and plan accordingly for improvements.
It will potentially also help in keeping the tools stable and
detect regressions more efficiently.
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
WanBingjiang [Tue, 3 Feb 2026 01:49:47 +0000 (09:49 +0800)]
hexdump: add fetch_more_extents to retrieve all file extents
Add fetch_more_extents() so FIEMAP can fetch extents in batches beyond
the initial fixed batch, instead of being limited to FIEMAP_EXTENTS_BATCH
extents only.
lib/pager: Call _exit in signal handler, not raise
The signals are registered without SA_RESETHAND, which means that the
same signal handler is called over and over again.
This just works because eventually, the waitpid call will fail, leading
to a suppressed error message (because stderr is already closed) and
then an _exit(EXIT_FAILURE) call.
Just call _exit(EXIT_FAILURE) directly to avoid unneeded and failing
system calls.
If PAGER contains any slash in program part, avoid resolving it with
PATH environment variable. Even if it is found there (in a
subdirectory), sh -c won't execute it.
Ameer Hamza [Mon, 2 Feb 2026 16:16:50 +0000 (21:16 +0500)]
libblkid: zfs: fix unaligned memory access on SPARC
SPARC requires aligned memory access for uint32_t values. The ZFS code
was directly dereferencing uint32_t pointers that could be unaligned due
to XDR encoding, causing SIGBUS crashes. Introduce copy_be32_to_cpu()
helper using memcpy to safely read from potentially unaligned memory.
Karel Zak [Mon, 2 Feb 2026 12:46:44 +0000 (13:46 +0100)]
Merge branch 'tests_convert_to_long_opts' of https://github.com/cgoesche/util-linux-fork
* 'tests_convert_to_long_opts' of https://github.com/cgoesche/util-linux-fork: (26 commits)
tests: (waitpid) use long options to improve test coverage report
tests: use long options globally in test scripts
tests: (setarch) use long options to improve test coverage report
tests: (script) use long options to improve test coverage report
tests: (rev) use long options to improve test coverage report
tests: (rename) use long options to improve test coverage report
tests: (mount) use long options to improve test coverage report
tests: (more) use long options to improve test coverage report
tests: (lsns) use long options to improve test coverage report
tests: (lsmem) use long options to improve test coverage report
tests: (lscpu) use long options to improve test coverage report
tests: (lsclocks) use long options to improve test coverage report
tests: (losetup) use long options to improve test coverage report
tests: (logger) use long options to improve test coverage report
tests: (ipcs) use long options to improve test coverage report
tests: (ionice) use long options to improve test coverage report
tests: (hexdump) use long options to improve test coverage report
tests: (getopt) use long options to improve test coverage report
tests: (findmnt) use long options to improve test coverage report
tests: (fdisk) use long options to improve test coverage report
...
lib: (strutils.c) fix unchecked lookahead in ul_parse_size()
If the numeric value provided to ul_parse_size() via @str
is a decimal with fractions only containing zeros, the logic
fails to identify the end of the string and goes to the label
'check_suffix' and will do an unchecked lookahead (*p + 1)
that will result in an out-of-bounds read.
This is because the logic only checks for null-termination
when a fraction has been parsed, i.e. a fraction not only
containing zeros.
To fix the issue, we implicitly check for null-termination
when we have finished parsing the fraction.
Reported-by: Yashashree Gund <yash_gund@live.com> Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
tests: (waitpid) move waitpid tests to a dedicated subdir
Moving tests for waitpid(1) in tests/ts/misc to its own
subdirectory, namely tests/ts/waitpid, makes it possible
to add more extensive tests without cluttering tests/ts/misc
and makes the directory structure more coherent.
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
waitpid: support 'PID:inode' process addressing format
Adding support for the 'PID:inode' format to address a
process ensures that waitpid(1) safely polls the status
of the expected process in a race-free manner. Worthy of
note is that with the addition of the getino(1) command
the aforementioned task becomes trivially simple.
Example:
waitpid $(getino -p 123456)
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
This refactor introduces 'struct waitpid_control' which is
used to control the program state, e.g. option flags, to
create context for internal routines that can adapt their
execution flow accordingly. It has as goal to make the code
easier to understand and reduces the scope of variables.
It also adds 'struct process_info' which stores information
on a process, specified by the PID passed on the command line,
such as the PID, process file descriptor and pidfd inode number.
An array of process_info is used to store information on all
specified PIDs on the command line and is used to create the
event poll list that is integral to the waitpid(1) logic.
This refactor lays the ground work to introduce support for
the 'PID:inode' process addressing format.
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Use Linux FIEMAP ioctl to detect sparse file holes and skip reading
them. This significantly improves performance when dumping large
sparse files by avoiding unnecessary disk I/O for hole regions.
Key changes:
- Add fiemap, in_sparse_hole, and region_end fields to struct hexdump
- Use check_hole() with cached region boundaries to minimize syscalls
- Only skip holes when vflag==DUP to preserve correct "*" output
- Distinguish real sparse holes from duplicate data in regular files
tests: move test scripts from tests/ts/misc to dedicated subdir
This patch moves the test scripts in tests/ts/misc to subdirs
in tests/ts for each util-linux tool. It keeps the directory
structure consistent and allows to extend testing for each tool
individually. It also lays the groundwork for the test coverage
report helper script tools/testcoverage.sh.
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Karel Zak [Thu, 29 Jan 2026 11:50:16 +0000 (12:50 +0100)]
chfn: allow --help and --version without login.defs restrictions
Parse command line arguments twice: first pass handles --help and
--version before restrictions are applied, second pass enforces
login.defs CHFN_RESTRICT settings for field options.
Karel Zak [Thu, 29 Jan 2026 09:33:09 +0000 (10:33 +0100)]
Merge branch 'lsfd--dont-reuse-stat-buffer' of https://github.com/masatake/util-linux
* 'lsfd--dont-reuse-stat-buffer' of https://github.com/masatake/util-linux:
lsfd: (bugfix) do not reuse stat(2) buffer for files with identical names
tests: add a helper command, test_open_twice
Masatake YAMATO [Thu, 22 Jan 2026 16:19:09 +0000 (01:19 +0900)]
lsfd: (bugfix) do not reuse stat(2) buffer for files with identical names
To reduce the number of stat(2) calls, lsfd reused the buffer returned
from stat(2) when file descriptors opened files with the same name.
If file descriptors open different files that happen to have the same
name, lsfd may report incorrect results. In such cases, the stat(2)
buffer must not be reused.
The program a.out is run with a file name "D/a". It opens the file
twice during its execution with an interval. Between the two open()
calls, a different filesystem is mounted on "D".
Dick Marinus [Tue, 2 Dec 2025 19:51:35 +0000 (20:51 +0100)]
copyfilerange: new command to call copy-file-range
This command allows you to call the copy-file range system call which
performs an in-kernel copy between two files without the additional cost
of transferring data from the kernel to user space and then back into
the kernel.
It gives filesystems an opportunity to implement "copy acceleration"
techniques, such as the use of reflinks (i.e., two or more inodes that
share pointers to the same copy-on-write disk blocks) or
server-side-copy (in the case of NFS).
A purpose of this command is to in-place deduplicate equal file blocks
in two different files.
When calling this command the source and destination file are required
and ranges must be supplied using command line arguments or from a
ranges file.
A file range contains the offset in the source and destination file and
the length of the range in bytes. The offsets can be omitted so that the
current file pointer is used. When the size is omitted or set to zero
the remainder of the file is copied.
If the file range is too long to fit in SIZE_MAX subsequential calls to
copy_file_range will be performed to copy the whole range.
The following command will copy/reflink a file:
$ copyfilerange file1 file2 0::
The following command will copy the second block from file1 into file2: