Karel Zak [Wed, 2 Apr 2025 09:00:47 +0000 (11:00 +0200)]
include/cctype: fix string comparison
Reimplement c_strcasecmp() and c_strncasecmp() to be libc compatible
and fix c_strncasecmp() to avoid \0 misinterpretation. The original
implementation was pretty stupid (sorry).
Karel Zak [Tue, 1 Apr 2025 13:54:07 +0000 (15:54 +0200)]
mkfs.bfs: fix memory leaks and weak code
- use size_t to store strlen() result
- init superblock with the default volume and fsname
- don't use strdup(), it's unnecessary as getopt_long() does not
modify arguments
- don't use memcpy() as we need to check string sizes
- restrict verbose output 6 bytes
Addresses: https://github.com/util-linux/util-linux/pull/3488 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 1 Apr 2025 13:06:54 +0000 (15:06 +0200)]
Merge branch 'setarch--show-pid' of https://github.com/masatake/util-linux
* 'setarch--show-pid' of https://github.com/masatake/util-linux:
setarch: add -p/--pid option showing the personality of specified process
procfs: add a helper function to access /proc/$pid/personality
bash-completion: (setarch) show some options as the 1st arg
Karel Zak [Tue, 1 Apr 2025 12:59:24 +0000 (14:59 +0200)]
Merge branch 'lsfd--bugfix-af-packet' of https://github.com/masatake/util-linux
* 'lsfd--bugfix-af-packet' of https://github.com/masatake/util-linux:
lsfd: (bug fix) scan the protocol field of /proc/net/packet as a hex number
tests: (test_mkfds::mapped-packet-socket) add a new parameter, protocol
lsfd: fix the description for PACKET.PROTOCOL column
Karel Zak [Thu, 27 Mar 2025 09:58:24 +0000 (10:58 +0100)]
more: improve help readability
The internal help can be printed within the current content. In this
case, it's hard to see where the help starts. Add a separator to make
it easier to read.
mkfs.cramfs: reduce the synopsis to the standard, succinct form
The old synopsis was 1) incomplete (mentioning -h and -v, but not
-V and -E and -z, for example), and 2) overlong, being wider than
80 columns. So, change the synposis to what most other utilities
nowadays use: "<name> [options] <arguments>..." -- this makes it
much clearer what the two required arguments are.
Also, reshuffle the descriptions of the two arguments, to not hide
them among the options.
And remove the description of option -s, as listing an option that
does nothing is not helpful.
swapon: improve a translator hint, and remove a pointless one
The reference to "each entry below" made no sense, as that second
translator hint is not before a gettextized message and therefore
did not make it into the POT file. Gettextizing that message is
not useful as 1) there is nothing to translate, and 2) allowing
the translators to fiddle with the tabs is too complicated, and
3) the --summary output is deprecated anyway.
Thomas Devoogdt [Tue, 25 Mar 2025 10:58:18 +0000 (11:58 +0100)]
lsns: fix undefined reference to add_namespace_for_nsfd #3483
Fixes:
sys-utils/lsns-lsns.o: In function `read_process':
lsns.c:(.text+0x9e8): undefined reference to `add_namespace_for_nsfd'
collect2: error: ld returned 1 exit status
Signed-off-by: Thomas Devoogdt <thomas.devoogdt@barco.com>
Karel Zak [Mon, 24 Mar 2025 13:44:46 +0000 (14:44 +0100)]
Merge branch 'PR/fix-non-widechar' of https://github.com/karelzak/util-linux-work
* 'PR/fix-non-widechar' of https://github.com/karelzak/util-linux-work:
misc: never include wchar.h
autotools: don't use wide-character ncurses if --disable-widechar
column: fix compiler warning for non-widechar compilation
Karel Zak [Thu, 20 Mar 2025 10:53:59 +0000 (11:53 +0100)]
column: fix compiler warning for non-widechar compilation
text-utils/column.c: In function ‘ansi_esc_width’:
text-utils/column.c:212:17: warning: case label value exceeds maximum value for type [-Wswitch-outside-range]
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 12:38:20 +0000 (13:38 +0100)]
terminal-colors.d: support NO_COLOR
We already provide the ability to easily disable output colorization,
but there is also the https://no-color.org initiative based on the
NO_COLOR environment variable. Let's support this method to disable
colors. Let's be friendly :-)
Addresses: https://github.com/util-linux/util-linux/issues/3463 Signed-off-by: Karel Zak <kzak@redhat.com>
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.