Thomas Weißschuh [Wed, 26 Jul 2023 14:32:59 +0000 (16:32 +0200)]
chrt: (tests) increase deadline test parameters
Since kernel commit b4098bfc5efb ("sched/deadline: Impose global limits on sched_attr::sched_period")
the value for dl_period has a lower bound of 100us.
Adjust the test parameters so the test can work on newer kernels.
Karel Zak [Thu, 16 Mar 2023 12:41:36 +0000 (13:41 +0100)]
losetup: add --loop-ref and REF column
The lo_file_name is nowhere used (kernel uses backing file descriptor,
no path) and it was used to store limited info about the backing file path
(64 bytes only!). For backward compatibility, we still fill lo_file_name
with the path, but it's nowhere in the userspace used as the complete
backing file path in sysfs.
This commit introduces a new option to overwrite the default path in
lo_file_name. The idea is to use the reference string by udevd in
/dev/loop/by-ref to address loop devices independently on paths.
Addresses: https://github.com/util-linux/util-linux/issues/2106 Suggested-by: Lennart Poettering <lennart@poettering.net> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Thu, 20 Jul 2023 10:34:14 +0000 (12:34 +0200)]
libmount: use some MS_* flags as superblock flags
The old mount(2) API usually utilizes MS_* flags to set up the VFS
node. However, there are some exceptions like "sync" (MS_SYNCHRONOUS),
where the flag is used (by kernel) for the superblock instead. The new
API addresses this issue, ensuring that these options are used for
fsconfig().
This commit introduces MNT_SUPERBLOCK to identify these options in the
libmount options Linux map, and it enforces the new mount code to
utilize these options for fsconfig(FSCONFIG_SET_FLAG).
Reported-by: Abbink Esger <esger.abbink.ext@siemens.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 18 Jul 2023 08:05:03 +0000 (10:05 +0200)]
Merge branch 'wip/rishi/libmount-handle-failure-to-apply-flags-as-part-of-mount' of https://github.com/debarshiray/util-linux
* 'wip/rishi/libmount-handle-failure-to-apply-flags-as-part-of-mount' of https://github.com/debarshiray/util-linux:
libmount: handle failure to apply flags as part of a mount operation
Karel Zak [Tue, 18 Jul 2023 08:03:35 +0000 (10:03 +0200)]
Merge branch 'lsfd--revise-help-message' of https://github.com/masatake/util-linux
* 'lsfd--revise-help-message' of https://github.com/masatake/util-linux:
lsfd: show default columns in the help message
lsfd: update the help message for XMODE column
lsfd: introduce -H, --list-columns option for making help messages short
lsfd: (man) fix the form for the optional argument of --inet option
lsfd: rearrange the aligment of the help messages
lsfd: use the specified output stream for printing help messages
Karel Zak [Tue, 18 Jul 2023 08:01:02 +0000 (10:01 +0200)]
Merge branch 'lsclocks/dynamic-clock' of https://github.com/t-8ch/util-linux
* 'lsclocks/dynamic-clock' of https://github.com/t-8ch/util-linux:
lsclocks: automatically discover dynamic clocks
lsclocks: add support for dynamic clocks
lsclocks: split out data function
lsclocks: add COL_TYPE
Karel Zak [Mon, 17 Jul 2023 12:15:33 +0000 (14:15 +0200)]
swapon: (man) fix --priority description
It's not true anymore that Linux uses -1 as the default. I could be
also another negative number (default is -2 for the first swap since
kernel commit a2468cc9bfdff6139f59ca896671e5819ff5f94a).
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2188894 Signed-off-by: Karel Zak <kzak@redhat.com>
Debarshi Ray [Thu, 13 Jul 2023 09:07:27 +0000 (11:07 +0200)]
libmount: handle failure to apply flags as part of a mount operation
If a mount operation with extra flags runs into an EPERM when applying
the flags, then mnt_context_get_mount_excode() returns 'Unknown error
5005' and MNT_EX_FAIL. Here's an example:
Create a mount point on the host with 'nodev,nosuid,noexec':
$ dd if=/dev/zero of=/var/tmp/loopfile bs=40960 count=1024
$ sudo losetup --find /var/tmp/loopfile
$ sudo mkfs.ext4 /dev/loop0
$ sudo mkdir /mnt/a
$ sudo mount -o nosuid,nodev,noexec /dev/loop0 /mnt/a
Check the mount options to be sure:
$ findmnt --output OPTIONS,PROPAGATION /mnt/a
OPTIONS PROPAGATION
rw,nosuid,nodev,noexec,relatime,seclabel shared
Enter a mount and user namespace:
$ podman run \
--interactive \
--privileged \
--rm \
--tty \
--volume /:/run/host:rslave \
registry.fedoraproject.org/fedora:38 \
/bin/bash
Try to bind mount the mount point from the host inside the namespace
with some extra flags:
# mkdir ~/b
# mount --bind -o ro /run/host/mnt/a ~/b
mount: /root/b: filesystem was mounted, but any subsequent operation
failed: Unknown error 5005.
# echo $?
32
It will be better to show something more human-readable than 'Unknown
error 5005'.
Secondly, an exit code of 32 means 'mount failure', which isn't quite
correct here. The mount operation is split into two mount(2) calls,
where the first one uses MS_BIND to create the bind mount, and the
second uses MS_REMOUNT | MS_BIND | MS_RDONLY to apply the 'ro' flag.
Here, the first mount(2) does succeed:
# findmnt --output OPTIONS,PROPAGATION ~/b
OPTIONS PROPAGATION
rw,nosuid,nodev,noexec,relatime,seclabel private,slave
It's only the application of the 'ro' flag with the second mount(2) that
fails with an EPERM. Hence, an exit code of 1 that means 'incorrect
invocation or permissions' seems more appropriate.
Signed-off-by: Debarshi Ray <rishi@fedoraproject.org>
mdadm superblocks before 1.1 are placed at the end of the device, which
means that the data contained inside the array starts at offset 0. For
LUKS inside MD, blkid falsely detects this as plain LUKS instead of a
linux_raid_member. This causes e.g. dracut to not assemble the array
during boot and system startup fails.
Karel Zak [Tue, 11 Jul 2023 10:01:00 +0000 (12:01 +0200)]
Merge branch 'lsfd--multiplexed-flag-of-XMODE-column' of https://github.com/masatake/util-linux
* 'lsfd--multiplexed-flag-of-XMODE-column' of https://github.com/masatake/util-linux:
tests: (lsfd) add a case testing 'm' flag in XMODE column
lsfd: add 'm' flag representing "multiplexed by epoll_wait(2)" to XMODE column
lsfd: (man) fix the broken page output for the description of NAME column
lib/pager: Apply pager-specific fixes only when needed
Currently defined output filter quirk fixes and environment variable
tweaks apply to less(1) only, so let's don't apply them when the pager
is actually configured to something else.
While there, rename the less(1)-specific callback function to make
clear what it applies to, and to make adding any posible additional
pager-specific callback functions a bit easier.
It's quite common to have options in the commands specified in the
PAGER environment variable, to customize the behavior of the configured
output filter. For example, someone might want to include the "-X"
option when less(1) is configured as the output filter, or might want
to specifically not include it, depending on the personal preferences.
For example, man(1), git(1) and bat(1) already allow and properly handle
the presence of any options in the configured output filter commands,
which assures that it's fine to do the same in util-linux.
Here's also a quotation from the description of the man(1) utility that
describes the PAGER environment variable, as found in The Single UNIX
Specification, version 4:
PAGER
Determine an output filtering command for writing the output
to a terminal. Any string acceptable as a command_string operand
to the sh -c command shall be valid. When standard output is
a terminal device, the reference page output shall be piped
through the command. If the PAGER variable is null or not set,
the command shall be either more or another paginator utility
documented in the system documentation.
This quotation just confirms, rather formally, that allowing options
in the output filter commands is a perfectly valid thing to do.
While there, perform a couple of minor cleanups as well, to make the
formatting of the code a tiny bit more consistent, and to slightly
improve one of the logged debug messages.
Karel Zak [Mon, 10 Jul 2023 10:33:21 +0000 (12:33 +0200)]
Merge branch 'lsfd--lock-flags-in-XMODE-column' of https://github.com/masatake/util-linux
* 'lsfd--lock-flags-in-XMODE-column' of https://github.com/masatake/util-linux:
test: (lsfd): add a case for l and L flags in XMODE column
test: (mkfds::ro-regular-file) add a parameter for a read lease
test: (mkfds::make-regular-file) add a parameter for file locking
lsfd: add flags, [-lL], representing file lock/lease states to XMODE column
test: (mkfds::make-regular-file) add a parameter for making the new file readable
test: (mkfds::make-regular-file) add a parameter for writing some bytes
test: (mkfds::make-regular-file) make 'fd' local variable reusable
test: (mkfds::make-regular-file) delete the created file when an error occurs
test: (lsfd::column-xmode): add mising "wait" invocation
lsfd: add flags, [-lL], representing file lock/lease states to XMODE column
The flags hide the details of locking: methods for locking (including
lease), mandatory or advisory, and ranges. The flags can be used only
for distinguishing three states: not locked, read (or shared) locked,
or write (or exclusive) locked.
Karel Zak [Mon, 3 Jul 2023 10:47:08 +0000 (12:47 +0200)]
Merge branch 'clock' of https://github.com/t-8ch/util-linux
* 'clock' of https://github.com/t-8ch/util-linux:
lsclocks: new util to interact with system clocks
lib/timeutils: implement timespec formatting
lib/timeutils: implement nanosecond formatting
lib/timeutils: constify some arguments
utmpdump: validate subsecond granularity
Karel Zak [Mon, 3 Jul 2023 10:41:04 +0000 (12:41 +0200)]
Merge branch 'lsfd--xmode' of https://github.com/masatake/util-linux
* 'lsfd--xmode' of https://github.com/masatake/util-linux:
lsfd: add 'D' flag for representing deleted files to XMODE column
lsfd: introduce XMODE column, extensible variant of MODE
test: (lsfd) add a subcase for testing NAME column for a deleted file
test: (lsfd) add a case for testing DELETED column
test: (mkfds) add "make-regular-file" factory
Karel Zak [Mon, 3 Jul 2023 10:38:48 +0000 (12:38 +0200)]
Merge branch 'lsfd--misc-tun' of https://github.com/masatake/util-linux
* 'lsfd--misc-tun' of https://github.com/masatake/util-linux:
tests: (lsfd) add a case testing TUN.IFACE column
tests: (mkfds) add a factor for opening tun device
lsfd: add TUN.IFFACE, a column for interfaces behind tun devices
lsfd: (refactor) move miscdev specific code to cdev_misc_ops
lsfd: (refactor) make the way to handle character devices extensible
lsfd: (refactor) introduce a content data type for char devices
Karel Zak [Mon, 3 Jul 2023 10:30:43 +0000 (12:30 +0200)]
Merge branch 'wip/rishi/libmount-src-libmount.h-MNT_ERR_APPLYFLAGS-docs' of https://github.com/debarshiray/util-linux
* 'wip/rishi/libmount-src-libmount.h-MNT_ERR_APPLYFLAGS-docs' of https://github.com/debarshiray/util-linux:
libmount: update documentation for MNT_ERR_APPLYFLAGS
Debarshi Ray [Thu, 29 Jun 2023 11:04:41 +0000 (13:04 +0200)]
libmount: update documentation for MNT_ERR_APPLYFLAGS
The implementation using the new FD based mount kernel API (ie.,
fsconfig/fsopen) uses MNT_ERR_APPLYFLAGS for failed mount_setattr(2)
calls, which involves more mount attributes (eg., MOUNT_ATTR_RDONLY,
MOUNT_ATTR_NOSUID, etc.) in addition to the MS_PROPAGATION flags (eg.,
MS_SHARED, MS_UNBINDABLE, etc.).
Note that mount_setattr(2) is part of the new FD based mount kernel API,
and is not used by the classic mount(2) based version.
Enter the cgroup namespace of target process without option -c:
$ sudo ./nsenter -C -U -t 216054 sh -c "cat /proc/self/cgroup"
0::/../../../../session-899.scope
Enter the cgroup namespace of target process with option -c:
$ sudo ./nsenter -c -C -U -t 216054 sh -c "cat /proc/self/cgroup"
0::/
Reviewed-by: Karel Zak <kzak@redhat.com> Reviewed-by: Thomas Weißschuh <thomas@t-8ch.de> Signed-off-by: u2386 <hugo.cavan2386@gmail.com>