Commit Graph

15419 Commits

Author SHA1 Message Date
Masatake YAMATO e749d51a9c lsns: make namespace having no process printable
This is a preparation change for planed "tree interpolation" patch.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2021-05-24 13:39:53 +02:00
Naohiro Aota db22115875 libblkid: support zone reset for wipefs
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().

Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
2021-05-24 13:39:53 +02:00
Naohiro Aota 6be38dccae libblkid: add magic and probing for zoned btrfs
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.

Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
2021-05-24 13:39:53 +02:00
Naohiro Aota b250fbbf56 libblkid: implement zone-aware probing
This patch makes libblkid zone-aware. It can probe the magic located at
some offset from the beginning of some specific zone of a device.

This patch introduces some new fields to struct blkid_idmag. They indicate
the magic location is placed related to a zone and the offset in the zone.

Also, this commit introduces `zone_size` to struct blkid_struct_probe. It
stores the size of zones of a device.

Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
2021-05-24 13:39:53 +02:00
Karel Zak 3387ad72a6 lsns: make --tree default, update man-page
* make --tree=process default for 'lsns' and 'lsns <ns>'
* remove 'list' from struct lsns
* update man page

Addresses: https://github.com/karelzak/util-linux/pull/1281
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-24 13:39:53 +02:00
Masatake YAMATO 179dd17a6a lsns: fix passing wrong process lists when showing ownerns and parentns
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2021-05-24 13:39:53 +02:00
Masatake YAMATO 8d27b60530 lsns: unify the code and option for printing process based tree and namespace based trees
Suggested by Karel Zak.

`--tree` option is introduced as replacement for `--nstree`.
In addition to `parent` and `owner`, `--tree` take `process` as the
option argument.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2021-05-24 13:39:53 +02:00
Masatake YAMATO e8c56ae2d7 lsns: print namespace tree based on the relationship (parent/child or owner/owned)
Introduce new option -T[parent|owner]|--nstree[=parent|=owner].

With this change, lsns prints parent/child relationship tree if
"-T parent" is given and owner/owned relationship tree if "-T owner is given.

Passing only "-T" is same as passing "-Towner."

Example sessions:

    # ./lsns -Tparent -ons,type,pns| head -20
    NS             TYPE          PNS
    4026531837     user            0
    ├─4026532508   user   4026531837
    ├─4026532609   user   4026531837
    ├─4026532610   user   4026531837
    ├─4026532629   user   4026531837
    ├─4026532705   user   4026531837
    ├─4026532901   user   4026531837
    ├─4026533090   user   4026531837
    ├─4026533185   user   4026531837
    ├─4026533280   user   4026531837
    └─4026533468   user   4026531837
    4026531835     cgroup          0
    4026531836     pid             0
    └─4026533038   pid    4026531836
      ├─4026532934 pid    4026533038
      ├─4026533715 pid    4026533038
      ├─4026533716 pid    4026533038
      ...

    # ./lsns -Towner -ons,type,ons| head -20
    NS             TYPE          ONS
    4026531837     user            0
    ├─4026531835   cgroup 4026531837
    ├─4026531836   pid    4026531837
    ├─4026531838   uts    4026531837
    ├─4026531839   ipc    4026531837
    ├─4026531840   mnt    4026531837
    ├─4026531861   mnt    4026531837
    ├─4026532001   net    4026531837
    ├─4026532219   mnt    4026531837
    ├─4026532357   mnt    4026531837
    ├─4026532383   net    4026531837
    ├─4026532475   mnt    4026531837
    ├─4026532476   mnt    4026531837
    ├─4026532504   mnt    4026531837
    ├─4026532508   user   4026531837
    │ ├─4026532509 ipc    4026532508
    │ └─4026532511 net    4026532508
    ├─4026532573   mnt    4026531837
    ├─4026532574   mnt    4026531837

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2021-05-24 13:39:52 +02:00
Karel Zak aa049eabb3 lscpu: add MHZ to the -e output
Addresses: https://github.com/karelzak/util-linux/issues/1314
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-23 23:52:00 +02:00
Zbigniew Jędrzejewski-Szmek cacd3e7685 fstrim: do not start the timer in initrd
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.
2021-05-21 10:45:35 +02:00
Karel Zak 6dfa12395e Merge branch 'more-floating-point' of https://github.com/kerolasa/util-linux
* 'more-floating-point' of https://github.com/kerolasa/util-linux:
  more: fix floating point exception core dump
2021-05-20 09:32:53 +02:00
Karel Zak 3e8403522c fstrim: fix paths comparison
Fix: https://github.com/karelzak/util-linux/issues/1312
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-20 09:29:34 +02:00
Sami Kerola ec4153cc28
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)

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2021-05-19 20:23:48 +01:00
Karel Zak 842ec4ce6b build-sys: fix po-man/ make check
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-13 12:21:56 +02:00
Karel Zak e304441936 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>
2021-05-13 10:34:14 +02:00
Karel Zak cef52b197a Merge branch 'whitespace' of https://github.com/eworm-de/util-linux 2021-05-13 10:24:25 +02:00
Karel Zak 65abace259 build-sys: update util-linux-man.pot on 'make dist'
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-13 10:23:34 +02:00
Christian Hesse e08e3d587c fix whitespace issue in ducumentation
This removes trailing whitespaces and fixes minor issues.
2021-05-10 15:53:50 +02:00
Karel Zak d637ca3e17 build-sys: release++ (v2.37-rc2)
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-10 13:12:02 +02:00
Karel Zak a6b49e89ed docs: update v2.37-ReleaseNotes
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-10 13:10:37 +02:00
Karel Zak 524897ed63 docs: update AUTHORS file
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-10 13:09:13 +02:00
Karel Zak 2994605fba po: merge changes
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-10 12:21:25 +02:00
Sebastian Rasmussen b93b8f42df po: update sv.po (from translationproject.org) 2021-05-10 12:15:03 +02:00
Karel Zak c916e84380 tests: update build tests
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-10 12:13:09 +02:00
Karel Zak 58739eb0a7 build-sys: fix libblkid dependence
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-10 11:24:24 +02:00
Karel Zak 21b16433a1 column: add placeholder '0' to specify all columns
Fixes: https://github.com/karelzak/util-linux/issues/1306
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-10 10:46:51 +02:00
Karel Zak b6464f8dc5 blkdiscard: fix compilation without libblkid
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-07 20:38:26 +02:00
Karel Zak 3773bb151a mkswap: remove unused variable when compile without libblkid
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-07 20:37:51 +02:00
Karel Zak 0ee5fcd2e8 docs: add #1266 to TODO file
References: https://github.com/karelzak/util-linux/issues/1266
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-07 11:26:33 +02:00
Johan Herland 9b657529cc
unshare: Fix error message when setting proc mount propagation
The mount() command associated with this error message is not about
unmounting the proc fs, but rather about changing the propagation
of mount events for the proc fs. Rewrite the error message to
reflect this.
2021-05-07 00:53:29 +02:00
Karel Zak 185bc3a832 rfkill: make RFKILL_EVENT_SIZE_V1 use more portable
The old linux/rfkill.h uses "int", new versions use sizeof() for the
macro ...

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-06 17:10:46 +02:00
Karel Zak fe58418e9d tests: update libfdisk JSON outputs
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-06 17:02:40 +02:00
Karel Zak 940f9def45 libfdisk: (script) print bootable flag only when set
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-06 17:01:48 +02:00
Karel Zak 787af7ce7c rfkill: fix compiler warning [-Wsign-compare]
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-06 16:44:20 +02:00
Karel Zak 64a89adaa1 lib/jsonwrt: don't use ctype.h for ASCII chars
tolower() does not work "as expected" for tr_TR.UTF-8 (Turkish).
Fortunately, we need to convert only objects and variables names in
JSON output, and this is always old good ASCII.

Anyway, for more details:

	$ cat a.c
	#include <ctype.h>
	#include <stdio.h>
	#include <locale.h>

	int main(void)
	{
		int in, out;

		setlocale(LC_ALL, "");

		in ='I';
		out = tolower(in);

		printf("%1$c [%1$d] --> %2$c [%2$d]\n", in, out);
		return 0;
	}

	$ make a
	cc     a.c   -o a

	$ LANG=en_US.utf8 ./a
	I [73] --> i [105]

	$ LANG=tr_TR.UTF-8 ./a
	I [73] --> I [73]

Fixes: https://github.com/karelzak/util-linux/issues/1302
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-06 16:35:50 +02:00
Karel Zak 3a07505a39 lib/jsonwrt: remove fputs_quoted_json_* functions from include/carefulputc.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-06 16:05:56 +02:00
Karel Zak d124a78034 lib/jsonwrt: remove 'islast' from API
The code should be able to keep track about previous content and print
JSON objects separator automatically.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-06 15:58:02 +02:00
Karel Zak 4b9abd11eb libfdisk: use lib/jsonwrt.s for JSON formatting
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-06 15:02:14 +02:00
Karel Zak f798aed128 rfkill: fix compiler warning [-Wformat=]
* `RFKILL_EVENT_SIZE_V1` is defined as sizeof(struct rfkill_event), so let's use %zu

* cast `len` to size_t to make it usable with %zu

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-06 12:25:10 +02:00
Masatake YAMATO c8d931ebe2 lib/fileutils: close fd if fdopen is failed
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2021-05-06 12:20:14 +02:00
Karel Zak f6c1168925 hwclock: follow timespec and use long int for nsec
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-06 11:56:14 +02:00
Karel Zak 9406284a92 script: fix time_t=long assumptions
References: ce3355cc54
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-06 11:37:10 +02:00
Karel Zak 01b37affc1 rtcwake: fix time_t=long assumptions
References: ce3355cc54
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-06 11:07:22 +02:00
Karel Zak 35c84bf76a lib/strutils: assume 64-bit time_t
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-06 11:06:45 +02:00
Karel Zak 634636301e hardlink: fix time_t=long assumptions
References: ce3355cc54
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-06 10:45:16 +02:00
Karel Zak 7e349033e0 test_uuid_parser: fix time_t=long assumptions
References: ce3355cc54
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-06 10:43:13 +02:00
Karel Zak c13ce8f4d6 fsck: fix time_t=long assumptions
References: ce3355cc54
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-06 10:40:32 +02:00
Karel Zak 7b20bb1acc scriptplay: fix time_t=long assumptions
Fixes: https://github.com/karelzak/util-linux/issues/1069
References: ce3355cc54
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-06 10:34:15 +02:00
Karel Zak f02286fd89 lib/pty-session: fix time_t=long assumptions
Fixes: https://github.com/karelzak/util-linux/issues/1069
References: ce3355cc54
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-06 10:22:07 +02:00
Karel Zak 4fb27d5c62 flock: fix time_t=long assumptions
This also fixes flock for archs (e.g. sparc64) where suseconds_t is not long.

Fixes: https://github.com/karelzak/util-linux/issues/1069
References: ce3355cc54
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-06 10:13:27 +02:00