Karel Zak [Mon, 17 Mar 2025 13:35:10 +0000 (14:35 +0100)]
include: use public domain for colors.{c,h} and xalloc.h
The LGPL makes it difficult to use the code in the old BSD tools we
have in util-linux. After obtaining agreement from the major
contributors to the files, we are changing it to "Public Domain".
Karel Zak [Mon, 17 Mar 2025 11:11:08 +0000 (12:11 +0100)]
Merge branch 'PR/lscpu-risc' of https://github.com/karelzak/util-linux-work
* 'PR/lscpu-risc' of https://github.com/karelzak/util-linux-work:
tests: (lscpu) update RISC-V tests to add ISA line
lscpu: RISC-V: Print ISA information in summary
Karel Zak [Mon, 17 Mar 2025 11:10:26 +0000 (12:10 +0100)]
Merge branch 'lsfd--revise-unix-endpoints' of https://github.com/masatake/util-linux
* 'lsfd--revise-unix-endpoints' of https://github.com/masatake/util-linux:
lsfd: (man) fix a typo
lsfd: add UNIX.IPEER column
lsfd: fill ENDPOINTS column for UNIX one-way sockets
include/list: add a macro for initializing list_head a declarative way
lsfd: (refactor) add a helper function building ENDPOINTS strings for UNIX socket
lsfd: add a dummy entry for UNIX socket having no peer to the IPC table
tests: (lsfd::mkfds-unix-dgram, refactor) split the test into subtests
tests: add ts_is_in_docker as a helper function
lsfd: (man) fix a typo
Karel Zak [Mon, 17 Mar 2025 10:49:57 +0000 (11:49 +0100)]
more: fix repeat command
The function more_key_command() may modify the current command setting.
We need to remember the original unmodified version, as specified by
the user, as the previous command; otherwise, the output will be affected
by unexpected cmd.number settings.
Simple reproducer:
$ more -c /etc/passwd
- Press <enter> to jump to the next line.
- Press '.' to repeat the last command.
Old version:
- It clears the screen and prints only one line (like the "1 <enter>" command).
Fixed version:
- It jumps to the next line (like the "<enter>" command).
Reported-by: Benno Schulenberg <bensberg@telfort.nl> Signed-off-by: Karel Zak <kzak@redhat.com>
Sunil V L [Tue, 11 Mar 2025 16:06:46 +0000 (21:36 +0530)]
lscpu: RISC-V: Print ISA information in summary
The ISA information for RISC-V is important for understanding the
different extensions supported by the CPU. Print the ISA information in
the summary, with the Base ISA and single-letter extensions at the
beginning, followed by multi-letter extensions sorted in alphabetical
order. The information is the same as the cpuinfo information, except
that underscores are replaced by spaces and multi-letter extensions are
simply sorted instead of following any ISA string ordering rule.
The sample output below shows the difference between cpuinfo and lscpu.
cpuinfo output:
isa : rv64imafdch_zicbom_zicboz_zicntr_zicsr_zifencei_zihintntl_zihintpause_zihpm_zawrs_zfa_zba_zbb_zbc_zbs_smaia_ssaia_sstc
swapon: make options --help and --version override --summary
When -h or --help is among the given options, most utilities
print a help text, ignoring all other options and arguments.
Make `swapon --summary --help` conform to this general pattern.
Masatake YAMATO [Sun, 9 Mar 2025 21:54:04 +0000 (06:54 +0900)]
lsfd: fill ENDPOINTS column for UNIX one-way sockets
With recvfrom(2) and sendto(2), we can use a UNIX datagram socket at
server side without assigning a peer address with connect(2). Here, I
call such sockets one-way sockets.
Masatake YAMATO [Sun, 9 Mar 2025 03:48:34 +0000 (12:48 +0900)]
lsfd: add a dummy entry for UNIX socket having no peer to the IPC table
With recvfrom(2) and sendto(2), we can use a UNIX datagram socket at
server side without assigning a peer address with connect(2). Here, I
call such sockets one-way sockets.
The socket, opened with systemd as fd 227, is an example of one-way
socket (13465). It has 0 as "Peer Address:Port". From the side of
systemd process, there is no communication peers. However, the
sockets (35438 and 74792) opened with systemd-journal and bluetoothd
have the one-way socket (13465) as their communication peers.
We expect lsfd prints these connections if user specifies
-o+ENDPOINTS. This change and subsequent changes remove limitations in
this area.
In the early stage of lsfd process, lsfd collects information about
UNIX sockets on the system via unix-diag netlink. lsfd stores the
information to the IPC table. lsfd looks up the IPC table when
printing ENDPOINTS column.
With the original code, lsfd could not fill the ENDPOINTS columns
for sockets connecting to an one-way socket because lsfd did not
store one-way sockets to the IPC table.
With this change, lsfd can fill the ENDPOINTS columns for sockets
connecting to an one-way socket. The new code puts dummy entries for
the one-way sockets to the IPC table. The dummy entries help lsfd to
find the connections.
Karel Zak [Mon, 10 Mar 2025 14:19:52 +0000 (15:19 +0100)]
Merge branch 'github-issue-3442' of https://github.com/masatake/util-linux
* 'github-issue-3442' of https://github.com/masatake/util-linux:
tests: (lsns) verify NETNSID column for namespaces with no process running
lsns: make "-Q NETNSID ..." work even if NETNSID column is not enabled
lsns: show NETNSID for namespaces with no process running
lsns: (refactor) generalize the code for collecting netnsid information
Masatake YAMATO [Fri, 7 Mar 2025 21:42:18 +0000 (06:42 +0900)]
lsns: make "-Q NETNSID ..." work even if NETNSID column is not enabled
With the original code, lsns didn't collect values for NETNSID
unless NETNSID column was enabled. As a result, a filter expression
referencing NETNSID value didn't work expectedly.
# ip netns add X
# ip netns set X 99999
# lsns-original -Q 'NETNSID == "99999"
(PRINT NOTHING)
# lsns-original -Q 'NETNSID == "99999" -o NETNSID
NETNSID
99999
With this change, lsns collects values for NETNSID if the
filter expression given to -Q option refers to NETNSID.
# lsns-new -Q 'NETNSID == "99999"
NS TYPE NPROCS PID USER COMMAND 4026535564 net 0 root
Masatake YAMATO [Thu, 6 Mar 2025 23:44:30 +0000 (08:44 +0900)]
lsns: show NETNSID for namespaces with no process running
Fixes #3445
The original code doesn't collect NETNSID for netns namespaces with no
process running.
A way to reproduce this issue:
# ip netns delete X
# ip netns add X
# ip netns set X 117
# ip netns show
X (id: 117)
netns-813c699f-4651-e5e9-6af4-cca568bf2c3a (id: 0)
# stat /var/run/netns/X
File: /var/run/netns/X
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 0,4 Inode: 4026533679 Links: 1
Access: (0444/-r--r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: system_u:object_r:nsfs_t:s0
Access: 2025-03-06 00:29:58.598605182 +0900
Modify: 2025-03-06 00:29:58.598605182 +0900
Change: 2025-03-06 00:29:58.598605182 +0900
Birth: -
# ./lsns -P -o+NETNSID
NS TYPE NPROCS PID USER COMMAND NETNSID 4026533679 net 0 root 4026534230 user 0 yamato
NS 4026533679 should have "117" as the value of NETNSID.
Though the original code defined netnsid member in struct
lsns_namespace, the member wasn't used at all. struct lsns_process had
a member having the same name. The original code used only the one in
struct lsns_process.
This change utilizes the netnsid member in struct lsns_namespace.
I found another bug, so I will provide a test case for this fix in a
subsequent commit.
Thomas Devoogdt [Thu, 6 Mar 2025 13:18:48 +0000 (14:18 +0100)]
exch: fix compile error if renameat2 is not present
https://www.man7.org/linux/man-pages/man2/rename.2.html
Available since Linux 3.15 or glibc 2.28,
add a fallback for older systems.
My initial implementation did the exchange using a swap
file if both HAVE_RENAMEAT2 and SYS_renameat2 were absent.
But that is not really what is desired since exch is supposed
to be atomic. So simply return -1 renameat2 is available.
Signed-off-by: Thomas Devoogdt <thomas.devoogdt@barco.com>
Karel Zak [Wed, 5 Mar 2025 08:53:34 +0000 (09:53 +0100)]
tests: improve test_sysinfo to check for NS_GET_NSTYPE usability
Now the test checks if the kernel supports the NS_GET_NSTYPE ioctl,
but it seems that on some platforms it's implemented but does not work
as expected and returns ENOTTY.
Karel Zak [Tue, 4 Mar 2025 18:25:34 +0000 (19:25 +0100)]
Merge branch 'ci-fix-alt-arch-segfaults' of https://github.com/mrc0mmand/util-linux
* 'ci-fix-alt-arch-segfaults' of https://github.com/mrc0mmand/util-linux:
ci: bump uraimo/run-on-arch-action to v3
Revert "ci: temporarily switch the alt-arch job worker to Ubuntu 22.04"
Masatake YAMATO [Tue, 4 Mar 2025 11:05:29 +0000 (20:05 +0900)]
test_mkfds: disable ppoll multiplexer if sigset_t is not defined
Fixes #3432
The ppoll multiplexer requires RAW sigset_t type generally defined in
asm/linux.h. However, the parisc arch of the kernel older than 487fa28fa8b60417642ac58e8beda6e2509d18f9 didn't export the type to
the user space.
Karel Zak [Tue, 4 Mar 2025 10:53:07 +0000 (11:53 +0100)]
Merge branch 'PR/irq-misc' of https://github.com/karelzak/util-linux-work
* 'PR/irq-misc' of https://github.com/karelzak/util-linux-work:
lsirq: add support for reading data from given file
irqtop: support json output format
irqtop: add max iteration support
irqtop: add batch mode support
Karel Zak [Mon, 3 Mar 2025 08:23:24 +0000 (09:23 +0100)]
Merge branch 'libblkid/ddf' of https://github.com/t-8ch/util-linux
* 'libblkid/ddf' of https://github.com/t-8ch/util-linux:
libblkid: ddf_read: validate header checksum
libc/crc32: make fill value of excluded area configurable
libblkid: ddf_raid: drop little-endian handling
libblkid: ddf_raid: respect constness of buffer
Thomas Weißschuh [Thu, 27 Feb 2025 17:15:56 +0000 (18:15 +0100)]
libblkid: ddf_raid: drop little-endian handling
The DDF specification, both 1.2 and 2.0 require big-endian.
This is also what mdadm expects.
5.2 Byte Ordering
Each section of the DDF MUST be stored in big-endian format
(i.e., the more significant bytes of the section are stored in
lower addresses in relation to bytes of lesser significance).
Thomas Weißschuh [Thu, 27 Feb 2025 17:15:38 +0000 (18:15 +0100)]
libblkid: ddf_raid: respect constness of buffer
The buffers returned by blkid_probe_get_buffer() are not allowed to be
modified. Respect this restriction when casting the buffer to other
pointer types.
scriptlive: reduce two usage synopses to one simple one
No synopsis can show all possible permutattions of arguments and
options, so do not even try and just give the most basic form,
without unneeded -t, -I, or -B.
Also, use angle brackets to show that <timingfile> and <typescript>
are placeholders.
scriptreplay: mark literal values in the man page in bold, not italic
Also, mention which keys can be used to speed up, slow down, and pause
the replay. Shorten the description of '-s' as it is deprecated. And
improve the description of '-t': it does not override the _timingfile_
positional argument, but takes the place of it, makes it unneeded.
scriptreplay: make Up/Down keys use a percentage instead of fixed amount
Using a fixed 0.1 amount made each subsequent Down-arrow key slow things
down _more_, and each subsequent Up-arrow key speed things up _less_.
It's nicer when each subsequent keystroke has the same relative effect.