Karel Zak [Mon, 25 Sep 2023 10:22:54 +0000 (12:22 +0200)]
Merge branch 'lsfd--resolve-mqueue-nodev' of https://github.com/masatake/util-linux
* 'lsfd--resolve-mqueue-nodev' of https://github.com/masatake/util-linux:
lsfd: collect the device number for mqueue fs in the initialization stage
tests: (lsfd) show the entry for mqueue in /proc/self/mountinfo
Karel Zak [Mon, 18 Sep 2023 10:10:01 +0000 (12:10 +0200)]
Merge branch 'lsfd--monitor-flag-for-poll-syscall' of https://github.com/masatake/util-linux
* 'lsfd--monitor-flag-for-poll-syscall' of https://github.com/masatake/util-linux:
tests: (test_mkfds::mkfds-multiplexing) make the output of ts_skip_subtest visible
tests: (test_mkfds::mkfds-multiplexing) dump /proc/$pid/syscall for debugging
lsfd: (man) write about XMODE.m and classical system calls for multiplexing
tests: (lsfd) add a case testing XMODE.m for classical syscalls for multiplexing
tests: (test_mkfds) add ppoll multiplexer
tests: (test_mkfds) add poll multiplexer
tests: (test_mkfds) add pselect6 and select multiplexers
tests: (test_mkfds) add a new factory "multiplexing"
tests: (test_mkfds) allow to add factory-made fds to the multiplexer as event source
tests: (test_mkfds, refactor) make the function for waiting events plugable
tests: (test_mkfds) include locale headers first to define _GNU_SOURCE
tests: (test_mkfds) use err() when a system call fails
lsfd: (comment) fix a typo
lsfd: mark XMODE.m on fds monitored by select(2) and pselect6(2)
lsfd: mark XMODE.m on fds monitored by poll(2) and ppoll(2)
lsfd: cache the result of checking whether "XMODE" column is enabled or not
procfs: add a helper function to access /proc/$pid/syscall
lsfd: (refactor) make the code for traversing threads reusable
lsfd: collect the device number for mqueue fs in the initialization stage
Though lsfd reads device minor numbers for file-systems having "nodev"
from /proc/$pid/mountinfo, we observed lsfd failed to resolve the
values of SOURCE column for mqueue files on s390 CI/CD env. It seems
that /proc/$pid/mountinfo doesn't provide enough information.
This change makes lsfd open a mqueue file in lsfd's initialization
stage as a new data source for resolving; lsfd can collect an
actually-used minor number from the file descriptor with fstat(2).
Karel Zak [Mon, 18 Sep 2023 09:14:38 +0000 (11:14 +0200)]
Merge branch 'vla-alloca' of https://github.com/t-8ch/util-linux
* 'vla-alloca' of https://github.com/t-8ch/util-linux:
buildsys: warn on usage of alloca()
more: remove usage of alloca()
buildsys: warn on usage of VLAs
lib/mbsedit: remove usage of VLA
lscpu: remove usage of VLA
fdisk: remove usage of VLA
libfdisk: (dos) remove usage of VLA
libblkid: (stratis) remove usage of VLA
lib/path: remove usage of VLA
Some lines in /proc/cpuinfo can be large e.g. flags and can then
truncate them in displaying them
BUFSIZ can vary quite a bit e.g. glibc/linux systems its 8192
but on musl/linux and OSX its 1024, on mingW it is 256, some tests e.g.
x86_64-64cpu-linux6.2.tar.gz has added really long line for cpu flags
line which is greater than 1024 characters and hence this test fails
on musl because lscpu -s reports truncated string
Thomas Weißschuh [Sun, 10 Sep 2023 20:46:00 +0000 (22:46 +0200)]
libblkid: prune unneeded buffers
When a new buffer is cached that is a superset of another existing
buffer the old buffer can be removed as future requests can be satisfied
by the new one.
As probe functions can have local references to buffered data, delay the
cleanup until the probefunc is finished to avoid accessing freed data.
For the bcachefs.img testfile this reduces the final (maximal) cache
from 34338 bytes in 54 buffers
to 24760 bytes in 40 buffers.
Karel Zak [Mon, 11 Sep 2023 13:17:01 +0000 (15:17 +0200)]
scriptreplay: support ctrl+s and ctrl+g
The old scriptreplay supported XON/XOFF flow control. The new
implementation uses cfmakeraw() and it disables it by default. Let's
enable it by IXON iflag.
Fixes: https://github.com/util-linux/util-linux/issues/2480
References: https://github.com/util-linux/util-linux/pull/1101 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 11 Sep 2023 09:07:54 +0000 (11:07 +0200)]
Merge branch 'lsfd--fix-the-way-to-stop-mkfds-1' of https://github.com/masatake/util-linux
* 'lsfd--fix-the-way-to-stop-mkfds-1' of https://github.com/masatake/util-linux:
tests: (lsfd::filter-floating-point-nums) use --raw output to make the case more robust
tests: (lsfd::column-xmode) do rm -f the file for testing before making it
tests: make ts_skip_capability accepts the output of older version of getpcaps
tests: (lsfd::mkfds-unix-dgram) don't depend on the number of whitespaces in the output
tests: (lsfd) avoid race conditions (part 1)
tests: (test_mkfds) monitor stdin by default
tests: make ts_skip_capability accepts the output of older version of getpcaps
In https://git.kernel.org/pub/scm/libs/libcap/libcap.git/commit/?id=8a2ac848a2065641e20a8b50384b68e8781cc6fc,
the default output format of getpcaps command was changed.
ts_skip_capability() assumes only the newer format, a format
introduced in the commit.
Masatake YAMATO [Thu, 31 Aug 2023 18:20:20 +0000 (03:20 +0900)]
tests: (lsfd) avoid race conditions (part 1)
For terminating test_mkfds process, the test cases
used SIGCONT. test_mkfds used pselect for waiting for the signal.
After receiving the signal test_mkfds exited.
There is a race condition in this logic. If a test case sends SIGCONT
to test_mkfds process before the process calls pselect, the signal
may be lost. As the result, test_mkfds keeps waiting forever in pselect.
This change replaces the code sending SIGCONT with writing to the pipe
connecting to the stdin of test_mkfds. test_mkfds also monitors
its stdin in the pselect call. Unlike the signal, the written bytes to
the pipe are queued.
This change doesn't touch tests/ts/lsfd/option-inet and option-summary
test cases. They don't use coproc. So fixing the race condition in the test
cases can be much complicated. I will make a dedicated pull request (part 2)
for them.
Masatake YAMATO [Thu, 31 Aug 2023 15:56:06 +0000 (00:56 +0900)]
tests: (test_mkfds) monitor stdin by default
After making file descriptors as specified in arguments, test_mkfds
waits for an event with pselect. When test_mkfds gets the event, it
exits.
The original code monitored stdin when the test_mkfds process ran in
the foreground. However, monitoring stdin is useful even when it runs
in the background. ts/lsfd/mkfds-* test cases run test_mkfds as a
co-process. So the test cases can terminate their test_mkfds
processes with echo command if the processes monitor stdin.
This change also adds -X/--dont-monitor-stdin option. As the name
shows, with the option, test_mkfds doesn't monitor stdin as before.
Some test cases run test_mkfds directly. In such a case,
tests/functions.sh may connect stdin of test_mkfds to
/dev/null. /dev/null is always ready to be read.
Karel Zak [Thu, 31 Aug 2023 08:41:32 +0000 (10:41 +0200)]
Merge branch 'PR/losetup-json' of github.com:karelzak/util-linux-work
* 'PR/losetup-json' of github.com:karelzak/util-linux-work:
losetup: make --output-all more usable
losetup: add MAJ a MIN for device and backing-file
losetup: fix JSON MAJ:MIN
Karel Zak [Wed, 23 Aug 2023 09:50:37 +0000 (11:50 +0200)]
libmount: fix statx() includes
Using sys/stat.h and linux/stat is too tricky.h together. It seems
better to rely on libc and use sys/stat.h only. Users affected
by old libc must update to use recent util-linux.
Fixes: https://github.com/util-linux/util-linux/issues/2448 Signed-off-by: Karel Zak <kzak@redhat.com>
Daan De Meyer [Sun, 20 Aug 2023 09:42:51 +0000 (11:42 +0200)]
Add new setpgid utility
This program allows running a command in a new process group and
optionally makes the new process group the foreground process group
of the ctty.
This is useful when running programs through wrappers programs (think
bubblewrap, ...) and wanting to make sure that SIGINT is only sent to
the innermost process. This is possible by putting the innermost process
in a new process group and making that process group the foreground process
group of the controlling terminal.
By adding a separate utility to util-linux, we can apply this to any
program even if the program itself doesn't implement this functionality.
Thomas Weißschuh [Tue, 29 Aug 2023 10:06:54 +0000 (12:06 +0200)]
libblkid: protect shared buffers against modifications
The cached buffers are shared between multiple probers.
To avoid (potentially security-sensitive) interdependencies between
probers make let the kernel enforce the write-protection.
Karel Zak [Wed, 23 Aug 2023 09:36:45 +0000 (11:36 +0200)]
uuidgen: mark some options mutually exclusive
* types cannot be mixed (--time, --random, --md5 and --sha1)
* --count makes sense only for --time and --random
* --name and --namespace makes sense only for --md5 and --sha1
Karel Zak [Wed, 23 Aug 2023 09:21:22 +0000 (11:21 +0200)]
uuidgen: add option --count
This is mostly for testing purpose or performance tuning. The new
option allows generate multiple UUIDs using the enhanced capability of
the libuuid to cache time-based UUIDs.