Karel Zak [Mon, 31 Oct 2022 12:54:45 +0000 (13:54 +0100)]
Merge branch 'lsfd-s390-proc-net-L3' of https://github.com/masatake/util-linux
* 'lsfd-s390-proc-net-L3' of https://github.com/masatake/util-linux:
lsfd: unify the code for reading /proc/net/tcp and udp
lsfd: make the logic for verifying the initial line of /proc/net/{tcp,udp} more flexible
Inside a container, the file /proc/self/mountinfo may contain many lines
with /dev/root. It is also quite likely that /dev/root is not visible
inside the container. This may cause mnt_guess_system_root() to try to use
libblkid before giving up, through mnt_resolve_spec() and
mnt_resolve_tag(), which calls blkid_evaluate_tag(). The call to
blkid_evaluate_tag() may trigger a scan of all block devices, which is
expensive.
For this reason, it doesn't make any sense for kernel_fs_postparse()
to call mnt_guess_system_root() more than once for every call to
mnt_table_parse_stream. Instead, save the result from the first call and
reuse it for all subsequent calls to kernel_fs_postparse(), so that there
is at most one call to mnt_guess_system_root() for every call
to mnt_table_parse_stream().
[kzak@redhat.com: - use sysroot_ prefix for the cached variables
- simplify code logic in kernel_fs_postparse()
- add free() to parser_cleanup()]
Signed-off-by: Viktor Rosendahl (BMW) <viktor.rosendahl@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Wed, 26 Oct 2022 07:41:29 +0000 (09:41 +0200)]
Merge branch 'cramfs/endianess-mismatch' of https://github.com/t-8ch/util-linux
* 'cramfs/endianess-mismatch' of https://github.com/t-8ch/util-linux:
libblkid: cramfs: report version
libblkid: cramfs: report filesystem size
libblkid: test big endian cramfs image
libblkid: cramfs: handle cross-endianess for checksums
Masatake YAMATO [Wed, 26 Oct 2022 02:56:00 +0000 (11:56 +0900)]
lsfd: make the logic for verifying the initial line of /proc/net/{tcp,udp} more flexible
The format of /proc/net/udp was changed in 6c25449e1a32 ("net: udp: fix alignment problem in udp4_seq_show()").
This kind of change can be applied to /proc/net/tcp, too.
Co-Authored-by: Thomas Weißschuh <thomas@t-8ch.de> Co-Authored-by: Masatake YAMATO <yamato@redhat.com>
Karel Zak [Wed, 12 Oct 2022 07:46:56 +0000 (09:46 +0200)]
libsmartcols: use standard deviation to optimize columns width
The standard deviation together with mean (average) of the data width
can be used to detect "problematic" columns and to calculate optimal
width.
The idea is to sort column by avg+deviation and start columns width
reduction from the column with the most wide and variable width. The
width reduction is also optimized by 68–95–99 rule (aka empirical
rule, avg+n*deviation; where n={1,2,3}) to cover 95% or 68% data in
the column.
The disadvantage is we need to link libsmartcols with -lm (math) due
to sqrt() function.
Karel Zak [Mon, 24 Oct 2022 09:04:40 +0000 (11:04 +0200)]
Merge branch 'tests' of https://github.com/t-8ch/util-linux
* 'tests' of https://github.com/t-8ch/util-linux:
ci: install dependencies from setup-ubuntu.sh
ci: s390x: install more test dependencies
lsfd: skip test mkfds-udp on s390x
Karel Zak [Fri, 21 Oct 2022 16:11:59 +0000 (18:11 +0200)]
libblkid: fix jmicron checksum and LE to CPU
- don't cast packed struct to uint16_t pointer, use temporary value
- calculate real count for the loop
- convert all to LE for checksum calculation (jm_to_cpu() ignores fillers)
Karel Zak [Fri, 21 Oct 2022 12:23:50 +0000 (14:23 +0200)]
lsfd: fix compiler warning [-Werror,-Wextra-semi]
isc-utils/lsfd-sock-xinfo.c:588:34: error: extra ';' outside of a function [-Werror,-Wextra-semi]
define_fill_column_func(tcp, TCP);
^
misc-utils/lsfd-sock-xinfo.c:703:34: error: extra ';' outside of a function [-Werror,-Wextra-semi]
define_fill_column_func(udp, UDP);
^
Addresses: 92a0dbce7c779923bd2a6fd7c53470ff6982ea50 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Fri, 21 Oct 2022 11:02:56 +0000 (13:02 +0200)]
Merge branch 'lsfd-udp' of https://github.com/masatake/util-linux
* 'lsfd-udp' of https://github.com/masatake/util-linux:
tests: (lsfd) add a case testing UDP sockets
lsfd: use extra information loaded from /proc/net/udp
lsfd: (man) write more about TCP scokets
Karel Zak [Fri, 21 Oct 2022 10:39:11 +0000 (12:39 +0200)]
Merge branch 'ci/big-endian' of https://github.com/t-8ch/util-linux
* 'ci/big-endian' of https://github.com/t-8ch/util-linux:
Run Ci on big-endian s390x
tests: disable nonfunctional tests under qemu user emulation
ci: don't run make with infinite parallel jobs
zhanchengbin [Mon, 10 Oct 2022 09:23:24 +0000 (17:23 +0800)]
fsck: Processes may kill other processes.
A error in disk-utils/fsck.c, if run the fsck -N command, processes
don't execute, just show what would be done. However, the pid whose
value is -1 is added to the instance_list list in the execute
function,if the kill_all function is called later, kill(-1, signum)
is executed, Signals are sent to all processes except the number one
process and itself. Other processes will be killed if they use the
default signal processing function.
Thomas Weißschuh [Mon, 10 Oct 2022 21:07:25 +0000 (23:07 +0200)]
libblkid: apfs: add test
Fixes #1807
Information known to macOS:
```
$ hdiutil attach apfs.img
/dev/disk1
/dev/disk2 EF57347C-0000-11AA-AA11-0030654
/dev/disk2s1 41504653-0000-11AA-AA11-0030654 /Volumes/testapfs
$ diskutil info disk2
Device Identifier: disk2
Device Node: /dev/disk2
Whole: Yes
Part of Whole: disk2
Device / Media Name: Disk Image
Volume Name: Not applicable (no file system)
Mounted: Not applicable (no file system)
File System: None
Content (IOContent): EF57347C-0000-11AA-AA11-00306543ECAC
OS Can Be Installed: No
Media Type: Generic
Protocol: Disk Image
SMART Status: Not Supported
Disk / Partition UUID: 25E5F1D3-11C0-4D36-98A5-3F66953519B9
Read-Only Media: No
Read-Only Volume: Not applicable (no file system)
Device Location: External
Removable Media: Removable
Media Removal: Software-Activated
Virtual: Yes
$ diskutil info disk2s1
Device Identifier: disk2s1
Device Node: /dev/disk2s1
Whole: No
Part of Whole: disk2
Volume Name: testapfs
Mounted: Yes
Mount Point: /Volumes/testapfs
Partition Type: 41504653-0000-11AA-AA11-00306543ECAC
File System Personality: APFS
Type (Bundle): apfs
Name (User Visible): APFS
Owners: Disabled
OS Can Be Installed: Yes
Media Type: Generic
Protocol: Disk Image
SMART Status: Not Supported
Volume UUID: 3EA5C1EF-64CB-447C-AE37-8046CDC35010
Disk / Partition UUID: 3EA5C1EF-64CB-447C-AE37-8046CDC35010
Milan Broz [Sun, 9 Oct 2022 18:20:45 +0000 (20:20 +0200)]
libblkid: avoid buffer overflow in ocfs superblock parsing
Label and mount values are checked only according to on-disk
values and not checked against the real structure size.
This can lead to reading of memory outside of superblock
struct and subsequent crash.
Reproducer found with OSS-Fuzz (issue 52270) running over
cryptsetup project (blkid is used in header init).
Masatake YAMATO [Sat, 1 Oct 2022 21:00:50 +0000 (06:00 +0900)]
lsfd: introduce SOCK. column namespace
lsfd has many columns already. We will add more in the future.
e.g. --help output is too long.
Groping columns is one of the ways to improve the usability of lsfd.
As the first step, this change introduces the "SOCK." column namespace.
Conceptually SOCKNETNS, SOCKSTATE, and SOCKTYPE migrate to the
namespace. At the implementation level, they are renamed to
SOCK.NETNS, SOCK.STATE, and SOCK.TYPE.
Karel Zak [Mon, 3 Oct 2022 07:49:07 +0000 (09:49 +0200)]
Merge branch 'lsfd-inet-xinfo' of https://github.com/masatake/util-linux
* 'lsfd-inet-xinfo' of https://github.com/masatake/util-linux:
lsfd: (man) write about TCP scokets
tests: (lsfd) add a case testing TCP sockets
lsfd: use extra information loaded from /proc/net/tcp
lsfd: cosmetic change, delete whitespaces
lsfd: add SOCKLISTENING column
For measuring and monitoring the performance aspect of a command,
people may want to drop the page caches related to specified files.
In some cases, writing 1 to /proc/sys/vm/drop_caches is overkill. The
fadvise command can be used for dropping page caches related to
specified files; the impact on a system is much smaller than
/proc/sys/vm/drop_caches.