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).
Signed-off-by: Karel Zak <kzak@redhat.com>
This is more portable and provides more stable results than
/proc/cpuinfo.
Fixes: https://github.com/karelzak/util-linux/pull/1317
Co-Author: Thomas Weißschuh
Signed-off-by: Karel Zak <kzak@redhat.com>
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.
The original output for -Towner:
# ./lsns -Towner
NS TYPE NPROCS PID USER COMMAND
4026531837 user 405 1 root /usr/lib/systemd/s
├─4026531835 cgroup 431 1 root /usr/lib/systemd/s
...
4026532638 pid 1 30839 yamato /opt/google/chrome
4026532640 pid 2 30837 yamato /opt/google/chrome
...
pid namespaces 4026532638 and 4026532640 are orphans.
lsns could not find their owners.
With this change:
# ./lsns-with-changes -Towner
NS TYPE NPROCS PID USER COMMAND
4026531837 user 403 1 root /usr/lib/systemd
├─4026531835 cgroup 429 1 root /usr/lib/systemd
...
├─4026532639 user 0
...
│ ├─4026532637 user 0
│ │ ├─4026532638 pid 1 30839 yamato /opt/google/chro
│ │ ├─4026533638 net 1 30839 yamato /opt/google/chro
│ │ └─4026533733 user 1 30839 yamato /opt/google/chro
│ ├─4026532640 pid 2 30837 yamato /opt/google/chro
Now pid namespaces 4026532638 and 4026532640 are integrated to the
tree. lsns interpolates the missing namespace 4026532639 and
4026532637 for the integration.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
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]
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
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>