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>
Karel Zak [Mon, 12 Jan 2026 12:21:32 +0000 (13:21 +0100)]
Merge branch 'lslocks--Q' of https://github.com/masatake/util-linux
* 'lslocks--Q' of https://github.com/masatake/util-linux:
tests: (lslocks) test -Q,--filter option
tests: (test_mkfds::nop) new factory just printing pid
lslocks: special-case PID for filtering (skip −1)
lslocks: make SIZE filterable by normalizing to bytes
lslocks: implement Q, --filter option
lslocks: factor out code getting and setting the data from add_scols_line
lslocks: (refactor) move proc_locks to struct lslocks
lslocks: (refactor) move pid_locks in main to struct lslocks
lslocks: (refactor) move "tab" file static variable to struct lslocks
lslocks: (refactor) add struct lslocks representing the global context
lslocks: (refactor) use global bytes in get_json_type_for_column()
lslocks: (refactor) add a helper function refining value returned from get_lock
lslocks: (refactor) don't use redundant callback functions
lslocks: (refactor) specify list_head as type instead of abusing void*
lslocks: (refactor) use separate function to initialize libscols_table
lslocks: (refactor) remove an unused local variable
lslocks: (refactor) use narrow variable scoping for loop counters
lslocks: (comment) fix grammar
Karel Zak [Mon, 12 Jan 2026 12:21:17 +0000 (13:21 +0100)]
Merge branch 'PR/fallocate-report-holes' of https://github.com/karelzak/util-linux-work
* 'PR/fallocate-report-holes' of https://github.com/karelzak/util-linux-work:
tests: convert fallocate to use subtests
fallocate: refactor --report-holes and --dig-holes output
fallocate: add --report-holes
The existing code tries to only print content of non-empty files, but
does not check the target of an encountered symbolic link, which could
be even something else, e.g. a fifo. Add the missing check to the
motddir_filter function.
Even though alarm(0) is called, another process could still send a
SIGALRM signal to the login process, which could trigger a use after
free for a tiny amount of time.
Not able to reproduce without adding a proper sleep.
The util-linux project preferred coding style is based on the kernel
coding-style (https://docs.kernel.org/process/coding-style.html),
which explains that opening braces should be on a line on their own
after the function signature. Therefore, let us adapt functions that
violate this convention.
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Karel Zak [Thu, 8 Jan 2026 12:35:43 +0000 (13:35 +0100)]
Merge branch 'feat/new_tool_getpidino' of https://github.com/cgoesche/util-linux-fork
* 'feat/new_tool_getpidino' of https://github.com/cgoesche/util-linux-fork:
lib: (pidfd-utils) minor correction in the ul_get_valid_pidfd_or_err() description
tests: add getino tests
bash-completion: add getino completions
getino: new tool to print the unique pidfd or namespace inode number