Karel Zak [Mon, 13 Dec 2021 12:22:56 +0000 (13:22 +0100)]
mount: add hint about systemctl daemon-reload
This commit implements an extra hint for systemd based distros to
inform users that units currently used by systemd are older than
fstab. This situation is usually unwanted, and 'systemctl
daemon-reload' is recommended.
The message is printed only on terminal to avoid extra messages in
logs, etc.
Addresses: https://github.com/systemd/systemd/pull/20476 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Fri, 10 Dec 2021 14:20:28 +0000 (15:20 +0100)]
Merge branch 'lsfd-blkdev' of https://github.com/masatake/util-linux
* 'lsfd-blkdev' of https://github.com/masatake/util-linux:
tests: (lsfd) call ts_skip_nonroot earlier
lsfd: fix a typo in comment
lsfd: declare local variables at the beginning of block
tests: (lsfd) add a case for listing a fd opening a block device
tests: (lsfd) add a factory for opening a block device to the helper command
lsfd: use the list of block devices in /proc/devices for decoding SOURCE column
lsfd: add a helper function for reading bdevs in /prode/devices
lsfd: move the code for reading /proc/devices to lsfd.c
libblkid/src/probe: check for ENOMEDIUM from ioctl(CDROM_LAST_WRITTEN)
The CD device on Azure VMs returns CDS_DISC_OK from CDROM_DRIVE_STATUS even
when no disc is present. In that case an ENOMEDIUM from CDROM_LAST_WRITTEN
follows. Catch that and return error to prevent probing which results in
hundreds of "unaligned transfer" warnings in the kernel logbuffer.
Karel Zak [Thu, 9 Dec 2021 12:20:50 +0000 (13:20 +0100)]
findmnt: add SOURCES column to print all devices with the same tag
It's the same like TARGETS for lsblk (the same device is possible to
mount on more mountpoints). Here in findmnt we support by a new column
SOURCES scenario when more devices (filesystems) use the same tag
(LABEL, UUID, e.g.).
Karel Zak [Thu, 9 Dec 2021 09:56:07 +0000 (10:56 +0100)]
isfdisk: improve --backup documentation
* add reference to backup section
* add note that backup is done always after startup
* remove TODO item about --backup, it seems that back after open is
only way how we can make it with current libfdisk, because
fdisk_locate_disklabel() returns current in-memory rather than on-disk
situation.
Addresses: https://github.com/util-linux/util-linux/issues/850 Signed-off-by: Karel Zak <kzak@redhat.com>
Masatake YAMATO [Wed, 8 Dec 2021 14:41:52 +0000 (23:41 +0900)]
lsfd: use the list of block devices in /proc/devices for decoding SOURCE column
For decoding the SOURCE column of a fd opening a block devices, the
origina code uses /proc/partitions only. However, this is not enough
for decoding /dev/nullb0. Though is is a block device node, the block
device behind the node is not listed in /proc/partitions.
This change uses the information min /proc/devices as the fallback of
/proc/partitions.
Masatake YAMATO [Wed, 8 Dec 2021 14:02:45 +0000 (23:02 +0900)]
lsfd: move the code for reading /proc/devices to lsfd.c
The original code is only for reading the names of character device
drivers. For making the code reusable in reading that of block device
drivers, rearrange the code an move it to the common area, lsfd.c.
Karel Zak [Wed, 8 Dec 2021 13:13:36 +0000 (14:13 +0100)]
Merge branch 'patch-2' of https://github.com/mariobl/util-linux
* 'patch-2' of https://github.com/mariobl/util-linux:
lsfd.1.adoc: Improve punctuation and add translator comments
lsfd.1.adoc: Fix yet another entry in the filter examples list
lsfd.1.adoc: Fix wording and markup
Karel Zak [Thu, 2 Dec 2021 13:15:49 +0000 (14:15 +0100)]
hardlink: add reflinks support (add --reflinks and --skip-reflinks)
Let's make XFS and BTRFS users more happy. The option --skip-reflinks
forces hardlink to detect files with shared extends and --reflinks
forces hardlink to create clones (FICLONE ioctl) rather than
hardlinks.
Addresses: https://github.com/util-linux/util-linux/issues/1447 Signed-off-by: Karel Zak <kzak@redhat.com>
Sean Anderson [Wed, 24 Nov 2021 18:26:18 +0000 (13:26 -0500)]
unshare: Document --map-{groups,users,auto}
This documents the new options added in the previous few commits.
I have added another example to better demonstrate the these
options. The actual use is fairly straightforward, but the descriptions
are on the pithier side.
Sean Anderson [Wed, 24 Nov 2021 18:26:17 +0000 (13:26 -0500)]
unshare: Add option to automatically create user and group maps
This option is designed to handle the "garden path" user/group ID
mapping:
- The user has one big map in /etc/sub[u,g]id
- The user wants to map as many user and group IDs as they can,
especially the first 1000 users and groups.
The "auto" map is designed to handle this. We find the first map
matching the current user, and then map the whole thing to the ID range
starting at ID 0.
Sean Anderson [Wed, 24 Nov 2021 18:26:16 +0000 (13:26 -0500)]
unshare: Add options to map blocks of user/group IDs
This adds the ability to map multiple user/group IDs when creating a new
user namespace. Regular processes cannot map any user other than the
effective user, so we need to use the setuid helpers newuidmap and
newgidmap, provided by shadow. Typically, users will be assigned blocks
of user/group IDs in /etc/sub{u,g}id, although it is also possible to
use NSS. There is a second advantage in using these helpers: because we
never write to /proc/self/gid_map, we don't have to disable setgroups.
Because the process of mapping IDs is almost identical, whether we are
mapping user IDs or group IDs, we put both in a common "map_range"
structure. These are read in by (ab)using string_to_idarray. In addition
to any map created with --map-users, we still need to handle a map of
size one created with --map-user. This makes constructing the helpers'
command line the trickiest part of the whole process. newuidmap/
newgidmap check to see if any ranges overlap before creating a mapping.
To avoid failing, we carve out a hole in the mapping for the singular
map. In the worst case, we may have three separate maps.
where the parent has to do some tasks (unshare(), fork() again, etc)
before the child can do its work. At the moment this is implemented
explicitly with a pipe().
Add some helper functions to abstract this process away. In addition,
switch to eventfd() instead of pipe(). As the man page for eventfd(2)
notes,
> Applications can use an eventfd file descriptor instead of a pipe (see
> pipe(2)) in all cases where a pipe is used simply to signal events. The
> kernel overhead of an eventfd file descriptor is much lower than that of
> a pipe, and only one file descriptor is required (versus the two required
> for a pipe).
> In the commit, the protoname of (AF_UNIX, SOCK_DGRAM) sockets was also
> changed to "UNIX-DGRAM". However, it was renamed back to "UNIX" in
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0edf0824e0dc359ed76bf96af986e6570ca2c0b9
To make this test case more portable, this change makes the test case
accept "UINX-DGRAM" in addition to "UINX", too.
ThomasKaiser [Sun, 28 Nov 2021 15:39:47 +0000 (16:39 +0100)]
Add Apple cores, fix Phytium core names
See https://www.spinics.net/lists/arm-kernel/msg879381.html and https://en.wikipedia.org/wiki/FeiTeng_(processor)#Future_processors (S2500 and D2000 are SoCs and contain 4 or 8 FTC663 cores).
The child that is about to exec*() the user shell is supposed to pam_end()
with PAM_DATA_SILENT. This gives the modules a last chance to do a minor
cleanup of the module state before the user's shell is launched.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
Masatake YAMATO [Sat, 27 Nov 2021 00:39:42 +0000 (09:39 +0900)]
tests: (lsfd) make DGRAM socketpair to mitigate the change of protoname
The protoname for a socket can be get from its xattr slot of
/proc/$PID/fd/$FD.
The protoname for (AF_UNIX, SOCK_STREAM) sockets was changed
from "UNIX" to "UNIX-STREAM" in
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=94531cfcbe79c3598acf96806627b2137ca32eb9
As the result, the test case, mkfds-socketpair doesn't work well on a
newer kernel.
To mitigate the impact of the change in the kernel, use (AF_UNIX, SOCK_DGRAM)
for making a socket pair.
In the commit, the protoname of (AF_UNIX, SOCK_DGRAM) sockets was also
changed to "UNIX-DGRAM". However, it was renamed back to "UNIX" in
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0edf0824e0dc359ed76bf96af986e6570ca2c0b9
Paul Sarena [Fri, 26 Nov 2021 23:34:02 +0000 (15:34 -0800)]
Escape ((…)) in AsciiDoc to fix broken example
In AsciiDoc, double parentheses are used to mark flow index terms, but in this document, their use is intended to be interpreted by the shell's arithmetic expansion. By escaping them with a backslash in the AsciiDoc, they pass through as-is to the manpage and other targets.
So, instead of a rendered result of `dd if=~/wipefs-sdb-0x00000438.bak of=/dev/sdb seek=$0x00000438 bs=1 conv=notrunc`, we get `dd if=~/wipefs-sdb-0x00000438.bak of=/dev/sdb seek=$((0x00000438)) bs=1 conv=notrunc`.
Seperately, when interpreted by a shell's arithmetic expansion, the 0x00000438 hex is converted to decimal 1080 `dd if=~/wipefs-sdb-0x00000438.bak of=/dev/sdb seek=1080 bs=1 conv=notrunc`
Alex Xu [Wed, 24 Nov 2021 20:34:10 +0000 (20:34 +0000)]
loopdev: accept ENOSYS for LOOP_CONFIGURE
qemu returns this if it doesn't understand the ioctl. according to ioctl(2) it should actually return EINVAL, but considering that it's been doing this for at least 20 years already, I doubt there's much appetite for change, considering that it has a slightly better error message if propagated back to the user and changing it to EINVAL may break other programs.
Karel Zak [Mon, 22 Nov 2021 12:18:54 +0000 (13:18 +0100)]
nsenter: add --wdns to change working directory
The current --wd=<dir> changes CWD to the path which is opened
*before* nsenter calls setns(). It may be useful if you want to use in
namespace something from your current namespace. In this case, the
option --wd works like a "tunnel" between namespaces.
For some other use-cases, this is useless and you want to be sure that
CWD always points to the target namespace. For this purpose this patch
implements --wdns <dir>.
Karel Zak [Fri, 19 Nov 2021 13:19:03 +0000 (14:19 +0100)]
libblkid: don't mark cache as "probed" if /sys not available
For "mount --all" we need to read the cache more than once in a short
time. The library checks the delay between probes, and if the delay is
too short, it does not read devices. This is a problem on boot when there
are no /sys, and the cache is empty. In this case, we need to check
for /sys until it's available constantly.
https://github.com/util-linux/util-linux/issues/1492 Signed-off-by: Karel Zak <kzak@redhat.com>
Masatake YAMATO [Thu, 18 Nov 2021 15:14:50 +0000 (00:14 +0900)]
lsfd: add --dump-counters option
User may wonder how the built-in counters are defined.
Describing their definitions in lsfd(1) is one of choice.
However, the definitions may drastically change in the future
development.
--dump-counters option is for making lsfd self descriptive.
Users who understand the filter expressions can understand
directly the meaning of the counters.