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 ++) {
| ^
The struct field `no_stdin` is always false, since it's never
initialized and only eventually reset to false when the whole
`pager_process` is reset to 0 with a `memset` call.
Since pager is supposed to read from stdin, this feature is not needed.
Karel Zak [Tue, 20 Jan 2026 14:35:37 +0000 (15:35 +0100)]
Merge branch 'PR/unshare-signals-forwarding' of https://github.com/karelzak/util-linux-work
* 'PR/unshare-signals-forwarding' of https://github.com/karelzak/util-linux-work:
tests: add tests for unshare --forward-signals
unshare: document --forward-signals in man page
unshare: implement signal forwarding when --forward-signals is used
unshare: add --forward-signals option to argument parser
Karel Zak [Tue, 20 Jan 2026 14:32:21 +0000 (15:32 +0100)]
Merge branch 'lsfd--add-error-c' of https://github.com/masatake/util-linux
* 'lsfd--add-error-c' of https://github.com/masatake/util-linux:
lsfd: (refactor) move the error object related code to a new file
lsfd: (refactor) remove redundant is_error member from struct file
lsfd: (refactor) add a helper function making error file objects
lsfd: remove __unused__ attr from parameters used actually
lsfd: (cosmetic) adjust white spaces in column definitions
Kiran Rangoon [Fri, 16 Jan 2026 17:06:48 +0000 (12:06 -0500)]
tests: add tests for unshare --forward-signals
Add two test cases for the new --forward-signals option:
- forward-signals: verifies SIGTERM is forwarded to child
- forward-signals-kill-child: verifies compatibility with --kill-child
Both tests use test_sigreceive which exits with the signal number
received, confirming proper signal forwarding.
Kiran Rangoon [Fri, 16 Jan 2026 17:06:47 +0000 (12:06 -0500)]
unshare: document --forward-signals in man page
Add documentation for the new --forward-signals option, explaining
its use case (graceful shutdown during reboot/system management)
and interaction with the --fork option.
Kiran Rangoon [Fri, 16 Jan 2026 17:06:46 +0000 (12:06 -0500)]
unshare: implement signal forwarding when --forward-signals is used
When --forward-signals is specified, install signal handlers for
SIGTERM and SIGINT that forward these signals to the child process.
This allows child processes with cleanup handlers to execute gracefully during shutdown scenarios like
system reboot.
Also fix waitpid() to handle EINTR properly when signals are being
forwarded, ensuring the parent waits for the child to complete
signal handling before exiting.
Kiran Rangoon [Fri, 16 Jan 2026 17:06:45 +0000 (12:06 -0500)]
unshare: add --forward-signals option to argument parser
Add a new --forward-signals command-line option that will allow
unshare to forward SIGTERM and SIGINT signals from the parent
process to the forked child process.
This commit adds the option parsing infrastructure but does not
implement the signal forwarding logic yet. The flag defaults to 0
(disabled) to maintain backward compatibility.
Karel Zak [Wed, 14 Jan 2026 11:12:35 +0000 (12:12 +0100)]
lib/path: add NULL checks for path in statx and access
Coverity warns that *at() libc functions (faccessat, statx) have pathname
marked as nonnull. Add explicit runtime NULL checks returning -EINVAL
instead of using __attribute__((nonnull)) into include/path.h to maintain
runtime safety for suid code.
Karel Zak [Mon, 12 Jan 2026 15:27:23 +0000 (16:27 +0100)]
blkpr: Call gettext() for descriptions, clean up
* Use N_() and _() macros to translate description texts.
* Avoid repeating command/flag/type names in description texts.
* Remove trailing line breaks; it's the caller's task to format
before/after the descriptions.
* Improve coding style by starting strings at the beginning of the
line, enhancing maintainability (80 characters limit).
* Keep "}, {" on separate lines as per our usual coding practice.
Stefan Hajnoczi [Wed, 17 Dec 2025 18:26:07 +0000 (13:26 -0500)]
blkpr: add read-reservation command
The new IOC_PR_READ_RESERVATION ioctl reports the current reservation on
a device. Add a command so that users can inspect the current
reservation. This is useful both for troubleshooting and for recovery
scenarios.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Stefan Hajnoczi [Wed, 17 Dec 2025 18:26:06 +0000 (13:26 -0500)]
blkpr: add read-keys command
The new IOC_PR_READ_KEYS ioctl lists registered keys on a device. Add a
command so that users can inspect keys. This is useful both for
troubleshooting and for recovery scenarios.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Stefan Hajnoczi [Wed, 17 Dec 2025 18:26:05 +0000 (13:26 -0500)]
blkpr: prepare for _IOR() ioctls
parse_pr_command() returns the ioctl command constant for a given
command or -1 when the command is unknown. Up until now all ioctl
command constants were positive, so the following check worked:
if (command < 0)
err(EXIT_FAILURE, _("unknown command"));
The top two bits of ioctl command constants encode the direction (_IO,
_IOR, _IOW, _IOWR). ioctl commands defined with _IOR have negative ioctl
command constants.
Explicitly check for -1 to differentiate "unknown command" from valid
ioctls commands. Later commits will add ioctl commands that use _IOR.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>