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>
* 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>
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>
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>
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.
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>
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.
* `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>
* rename MANPAGES_EXTRA= to ADOCFILES_COMMON=
* keep track about individual adoc files by dist_noinst_DATA=
This variable is not effected by automake conditions, so the files
are always distributed.
Signed-off-by: Karel Zak <kzak@redhat.com>
* 'master' of https://github.com/arbego/util-linux:
Fixed wrongful time_t=long assumptions in hwclock.c and timeutils.c
Changed int64_t casts to long long int casts
Fixed format strings and type casts in hwclock to work with 64-bit time_t on 32-bit linux
It's possible that lscpu does not print any caches if full caches size
is zero. In this case we do not need the header.
Addresses: https://github.com/karelzak/util-linux/issues/1207
Signed-off-by: Karel Zak <kzak@redhat.com>
* 'topic/po4a' of https://github.com/mariobl/util-linux:
mount.a.adoc: Fix markup
Asciidoc: Add missing macro definition in uclampset.1
Asciidoc: Fix markup in example man page
Asciidoc: Fix markup
Asciidoc: Remove artifact from merge conflict
Asciidoc: Convert man-common/README to Markdown
po-man: Fix the example man page
po-man: Fix typos in po-man/README.md
po-man: Update the example man page
po-man: Add po-man/README.md
po-man: Add (incomplete) de.po for testing purposes
po-man: Add (incomplete) de.po for testing purposes
po-man: Adjust paths in po4a.cfg and update .pot file
po-man: Move Po4a config file and translation template to po-man
Because the headings are aligned with tabs the fields must
always be a multiple of 8 characters. Moreover if the field
values are shorter than 8 characters, extra tabs must be
inserted before the succeding field to keep alignment.
swapon parses /proc/swaps, generated by the Linux kernel in
mm/swapfile.c. Its function swap_show() and its recent fix in
commit 6f7939405f61de7d0da7f6c90182e96c4f5ff6c1 were used as
inspiration for this commit.
Additionally inform the translators about the requirements of
formatting and relationship between the heading and entry strings.
The prlimit description are always defined as static strings, but it
seems better to make the code more readable and robust for static
analyzers and readers.
Fix also missing gettext() call for description help.
Fixes: https://github.com/karelzak/util-linux/issues/1277
Signed-off-by: Karel Zak <kzak@redhat.com>
* don't use dist_noinst_DATA= for generated man pages (use man_MANS=)
* make asciidoctor optional
* add --disable-asciidoc to explicitly disable man pages
Addresses: https://github.com/karelzak/util-linux/issues/1257
Signed-off-by: Karel Zak <kzak@redhat.com>
We need to evaluate "include::" directive relatively to project
top-level source directory rather than to the current document
location.
Signed-off-by: Karel Zak <kzak@redhat.com>
The symlinks are generated by asciidoctor and current dist_man_MANS
depends on order (nan page before man link). This solutions is useless
when execute "make -j". The real solution is to keep man pages in
separate variable and use only this variable evaluate what we need to
generate.
Signed-off-by: Karel Zak <kzak@redhat.com>
For example for hierarchy:
$ findmnt -oTARGET,ID,PARENT
TARGET ID PARENT
/mnt/A 802 62
└─/mnt/A/B 937 802
├─/mnt/A/B/C 964 937
│ └─/mnt/A/B/C 991 964
└─/mnt/A/B 1018 937
└─/mnt/A/B 1045 1018
we need umount in order (id): 1045, 1018, 991, 964, 937, 802. The current
code first tries 991 in 937 branch.
Reported-by: Lennart Poettering <lennart@poettering.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
Besides some formatting tweaks, I've changed »lsblk(1)« into »lsblk(8)«
in the SEE ALSO section of mount.8.adoc. At least Archlinux and Debian
ship lsblk as a system administration command.
To build: meson build && ninja -C build
To run tests: ninja -C build check
To install for packaging: DESTDIR=/var/tmp/inst ninja -C build install
To install for realz: sudo ninja -C build install
v2:
- Optional items are now based on the 'feature' feature in meson.
Built libraries which are disabled turn into disabler() objects
and also poison any executables which link to them.
What is there:
- building of the binaries and libs and the python module
- installation of binaries, libs, python module, localization files,
man pages, pkgconfig files
- running of tests
- most options to configure build equivalently to the
./configure settings
Partially implemented:
- disabling of stuff when things missing. In the C code, the defines
are all used, so that should be fine. In the build system, some
files should be skipped, but that is probably not always done properly.
Getting this right might require some testing of various build option
combinations to get the details right.
Not implemented:
- static builds of fdisk and other binaries
- things marked with XXX or FIXME
- ???
Differences:
- .la files are not created. They are useless and everybody hates them.
- Requires.private in pkgconfig files are not present in the
autogenerated .pc file. Not sure if they should be there or not. If
necessary, they can be added by hand.
- man pages and systemd units are installed by the install target. Not
sure why 'make install' doesn't do that.
- the split between / and /usr is probably wrong. But it's all pointless
anyway, so maybe we could simplify things but not implementing it at
all under meson?