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>
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:
Karel Zak [Tue, 27 Jan 2026 10:37:28 +0000 (11:37 +0100)]
Merge branch 'pidutils_improve' of https://github.com/cgoesche/util-linux-fork
* 'pidutils_improve' of https://github.com/cgoesche/util-linux-fork:
lib: (pidutils) improve the return protocol
lib: (pidutils) add a routine to parse pids and err() on failure
lib: (pidutils) improve 'PID:inode' parsing logic
Using _namespace ID_ in the synopsis as argument definition
is more coherent as it lets a user easily infer that a
numeric value is required to identify a namespace.
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Instead of using generic return codes, lets
be more precise and return negative errno
numbers and set errno accordingly, so that
higher level callers can report errors more
accurately.
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
The parsing logic in ul_parse_pid_str() failed to
identify invalid input when *pidstr starts with a
colon ':' followed by a number (inode), and also
in cases where the input does not consist of any
digits. And lastly if the PID or inode is 0.
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Karel Zak [Thu, 22 Jan 2026 16:29:51 +0000 (17:29 +0100)]
Merge branch 'master' of https://github.com/martinjungblut/util-linux into PR/libfdisk-EBR-gap
* 'master' of https://github.com/martinjungblut/util-linux:
tests: fdisk: add regression test for missing EBR gap between logical partitions
libfdisk: (dos) fix logical partition start
Karel Zak [Wed, 21 Jan 2026 10:56:54 +0000 (11:56 +0100)]
lsfd: make sure errors array is not empty [-Werror=type-limits]
lsfd-cmd/error.c: In function ‘get_errno_name’:
lsfd-cmd/error.c:49:30: error: comparison of unsigned expression in ‘< 0’ is always false [-Werror=type-limits]
49 | for (size_t i = 0; i < ARRAY_SIZE(errnos); i ++) {
| ^