Karel Zak [Wed, 9 Jun 2021 14:12:13 +0000 (16:12 +0200)]
libblkid: check for ioctl macro rather than for header file
libblkid/src/probe.c:1012:22: error: ‘BLKGETZONESZ’ undeclared (first use in this function)
1012 | if (!ioctl(pr->fd, BLKGETZONESZ, &zone_size_sector))
| ^~~~~~~~~~~~
Qais Yousef [Mon, 7 Jun 2021 16:11:11 +0000 (17:11 +0100)]
uclampset: Fix left over optind++
The code was changed to use ':' in getopt_long() but these were left
over by mistake causing weird random errors when using these options
depending on the order they were fed.
Karel Zak [Mon, 7 Jun 2021 08:32:20 +0000 (10:32 +0200)]
libsmartcols: fix bare array on JSON output
The bare array ({[...]}) for top level list of entries is invalid. It
seems better to print empty string than nothing. This is workaround
for broken utils, better is to define a table name.
Addresses: https://github.com/karelzak/util-linux/issues/1339 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Wed, 2 Jun 2021 11:06:10 +0000 (13:06 +0200)]
Merge branch 'lscpu-json-types' of https://github.com/t-8ch/util-linux
* 'lscpu-json-types' of https://github.com/t-8ch/util-linux:
lscpu: use optional json values
libsmartcols: add support for optional boolean values
lscpu: use json types
Karel Zak [Wed, 2 Jun 2021 10:33:07 +0000 (12:33 +0200)]
Merge branch 'next'
* next: (26 commits)
build-sys: add script to compare config.h from meson and autotools
meson: add missing header files check
docs: update TODO
tests: update lscpu outputs
lscpu: read MHZ from /sys/.../cpufreq/scaling_cur_freq
lscpu: use locale-independent strtod() when read from kernel
lib/c_strtod; add locale independent strtod()
tests: update lscpu output
lscpu: use MHZ as number to be locale sensitive
lscpu: add SCALMHZ% and "CPU scaling MHz:"
sulogin: fix whitespace error
sulogin: ignore none-existing console devices
lsns: fix old error message
lsns: fix copy & past in man page
lsns: fill UID and USER columns for interpolated namespaces
fixup! lsns: interpolate missing namespaces for converting forests to a tree
lsns: interpolate missing namespaces for converting forests to a tree
lsns: reorganize members specifying other namespaces in lsns_namespace
lsns: make namespace having no process printable
libblkid: support zone reset for wipefs
...
Karel Zak [Wed, 2 Jun 2021 09:55:44 +0000 (11:55 +0200)]
build-sys: fix {release-version} man pages
* define {release-version} as $VERSION
* do not use {docdir} in adoc; it's built-in ascidoctor variable
https://docs.asciidoctor.org/asciidoc/latest/attributes/document-attributes-reference/#intrinsic-attributes
Addresses: https://github.com/karelzak/util-linux/issues/1327 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 31 May 2021 15:44:10 +0000 (17:44 +0200)]
build-sys: remove with-cryptsetup from tools/config-gen.d/all.conf
Unfortunately libtools is not smart enough to link libblkid
dynamically if we link in-tree static libmount.a for libmount tests.
In this case libtools always uses also libblkid.a, but it's problem
for libcryptsetup which requires versioned symbols from libblkid.so
This is no problem for normal binaries, but for libmount tests only
(where we need static library to by-pass public library API).
Karel Zak [Mon, 24 May 2021 10:24:33 +0000 (12:24 +0200)]
lscpu: add SCALMHZ% and "CPU scaling MHz:"
$ lscpu
...
Model name: Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz
CPU family: 6
Model: 60
Thread(s) per core: 2
Core(s) per socket: 4
Socket(s): 1
Stepping: 3
CPU(s) scaling MHz: 61%
CPU max MHz: 4400.0000
CPU min MHz: 800.0000
...
lsns: interpolate missing namespaces for converting forests to a tree
The tree of *parent* and *owner* could be forests because *lsns*
cannot track a namespace having no process.
This change tries interpolating the missing namespaces by calling
ioctl(NS_GET_PARENT) and ioctl(NS_GET_USERNS) recursively.
The original output for -Tparent:
# ./lsns -Tparent
NS TYPE NPROCS PID USER COMMAND 4026531837 user 404 1 root /usr/lib/systemd/sy
├─4026532508 user 1 29376 yamato /usr/lib64/firefox/
...
└─4026533513 user 1 24245 yamato /usr/lib64/firefox/
... 4026533733 user 1 30839 yamato /opt/google/chrome- 4026533734 user 15 10076 yamato /opt/google/chrome-
user namespaces 4026533733 and 4026533734 are orphans.
lsns could not find their parents.
With this change:
# ./lsns-with-changes -Tparent
NS TYPE NPROCS PID USER COMMAND 4026531837 user 404 1 root /usr/lib/systemd/
├─4026532508 user 1 29376 yamato /usr/lib64/firefo
...
├─4026532639 user 0
│ ├─4026532637 user 0
│ │ └─4026533733 user 1 30839 yamato /opt/google/chrom
│ └─4026533734 user 14 10076 yamato /opt/google/chrom
Now user namespaces 4026533733 and 4026533734 are integrated to the
tree. lsns interpolates the missing namespace 4026532639 and 4026532637 for the integration.
lsns: reorganize members specifying other namespaces in lsns_namespace
This is a preparation change for planed "tree interpolation" patch.
parentid, ownerid, parentns, and ownerns were members of
lsns_namespace struct. When interpolating missing namespaces
for building a unified name space tree, duplicated functions
are needed; one is for parentid and parentns members, and
another is for ownerid and ownerns members. To avoid the
duplication, this change unifies the members as following:
parentid and ownerid => related_id [2]
parentns and ownerns => related_ns [2]
We cannot overwrite superblock magic in a sequential required zone. So,
wipefs cannot work as it is. Instead, this commit implements the wiping by
zone resetting.
Zone resetting must be done only for a sequential write zone. This is
checked by is_conventional().
This commit adds zone-aware magics and probing functions for zoned btrfs.
The superblock (and its copies) are the only data structure in btrfs with a
fixed location on a device. Since we cannot do overwrites in a sequential
write required zone, we cannot place the superblock in the zone.
Thus, zoned btrfs uses superblock log writing to update superblocks on
sequential write required zones. It uses two zones as a circular buffer to
write updated superblocks. Once the first zone is filled up, start writing
into the second buffer. When both zones are filled up, and before starting
to write to the first zone again, it reset the first zone.
We can determine the position of the latest superblock by reading the write
pointer information from a device. One corner case is when both zones are
full. For this situation, we read out the last superblock of each zone and
compare them to determine which zone is older.
The magics can detect a superblock magic ("_BHRfs_M") at the beginning of
zone #0 or zone #1 to see if it is zoned btrfs. When both zones are filled
up, zoned btrfs resets the first zone to write a new superblock. If btrfs
crashes at the moment, we do not see a superblock at zone #0. Thus, we need
to check not only zone #0 but also zone #1.
It also supports the temporary magic ("!BHRfS_M") in zone #0. Mkfs.btrfs
first writes the temporary superblock to the zone during the mkfs process.
It will survive there until the zones are filled up and reset. So, we also
need to detect this temporary magic.
Finally, this commit extends probe_btrfs() to load the latest superblock
determined by the write pointers.
I'm working on building initramfs images directly from normal
packages, which means that the pristine system rpms should behave
correctly as much as possible also in the initrd. There usually isn't
enough time for the timer to actually fire, but starting it gives a
line on the console and generally looks confusing and sloppy. So let's
skip the timer if it ever ends up being enabled in the initrd.
Checking for /etc/initrd-release is the standard condition that
systemd's initrd units use.
Sami Kerola [Wed, 19 May 2021 19:23:48 +0000 (20:23 +0100)]
more: fix floating point exception core dump
Make the code avoid divided by zero. This can happen when file has content
but is zero in size. Such files can be found from procfs, possibly some
other pseudo-filesystems. To reproduce the issue run the following.
$ more /proc/crypto
...
Floating point exception (core dumped)
Karel Zak [Thu, 13 May 2021 08:34:14 +0000 (10:34 +0200)]
blkdiscard: do not probe for signatures on --force
The command-line option --force is defined as "disable all checks",
but the current code does not follow this idea. We need a way how to
disable read from the device (for example for dm-integrity devices).
Fixes: https://github.com/karelzak/util-linux/issues/1308 Signed-off-by: Karel Zak <kzak@redhat.com>