Bastian Krause [Fri, 21 Jan 2022 15:09:35 +0000 (16:09 +0100)]
hwclock: add --param-get option
Implement the RTC_PARAM_GET RTC ioctl in hwclock. The ioctl interface was
introduced with [1], which went mainline in Kernel v5.16. The parameters
are independent of hardware/driver. This means we can read and set
parameters in a generic way.
The new --param-get hwclock function accepts aliases for parameters
currently existent (Kernel v5.16). They can be extended later on. As
fallback, hexadecimal (if prefixed with 0x) and decimal values, as
defined in [2], are accepted.
Thomas Weißschuh [Thu, 27 Jan 2022 17:00:12 +0000 (18:00 +0100)]
findmnt: properly exclude poll columns from --output-all
Previously columns excluded from --output-all where in fact stored as
column index 0. This however is COL_ACTION which is a polled column
leading to the following error:
findmnt --output-all
findmnt: ACTION column is requested, but --poll is not enabled
Karel Zak [Thu, 27 Jan 2022 09:50:45 +0000 (10:50 +0100)]
libfdisk: (gpt) align size of partition by default
LastUsableLBA (field in GPT header) is calculated to use all free
space on the device. The problem is that size of this area is
unaligned to optimal I/O (or physical sector size) on devices where
the logical sector is 512 bytes, but the physical sector size is 4K.
(Note that after LastUsableLBA is backup GPT header and size of this
backup is calculated by logical sectors.)
The problem is visible for the last partition on the device because
this partition ends on LastUsableLBA.
The ideal solution would be align directly LastUsableLBA number in the
GPT header. Unfortunately, this solution is useless for libfdisk,
because we have to be backwardly compatible with sfdisk scripts
generated by old versions where is explicitly specified partition
size.
It seems usable compromise is to align only last partition if the size
of the partition is unspecified or specified by relative number
(+100M) -- in this case we already align partition, so there is no
change in fdisk semantic (well, last partition will be smaller than in
previous libfdisk versions).
The unaligned partition size is a problem for dm-crypt where device
size is used dynamically, and when unaligned, DM uses 512-bytes with a
negative impact on performance.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2044108
Addresses: https://marc.info/?l=dm-crypt&m=164306225923513&w=2 Signed-off-by: Karel Zak <kzak@redhat.com>
Jan Kara [Thu, 20 Jan 2022 12:16:39 +0000 (13:16 +0100)]
loopdev: Do not treat errors when detecting overlap as fatal
When looking for overlapping loop device we can fail getting some loop
device properties when we race with device autoclear. Just squelsh these
errors and try next loop device.
Jan Kara [Thu, 20 Jan 2022 11:47:05 +0000 (12:47 +0100)]
mount: Fix race in loop device reuse code
Small timing changes in the kernel loop device handling broke the
following loop:
while :; do mount -o loop,ro isofs.iso isofs/; umount isofs/; done
which quickly reports:
mount: /mnt: can't read superblock on /dev/loop0.
umount: /mnt: not mounted.
And this loop is broken because of a subtle interaction with
systemd-udevd that also opens the loop device. The race seems to be in
mount(8) handling itself and the altered kernel timing makes it happen.
It look like:
bash systemd-udevd
mount -o loop,ro isofs.iso isofs/
/dev/loop0 is created and bound to isofs.iso, autoclear is set for
loop0
opens /dev/loop0
umount isofs/
loop0 still lives because systemd-udev still has device open
mount -o loop,ro isofs.iso isofs/
gets to mnt_context_setup_loopdev()
loopcxt_find_overlap()
sees loop0 is still valid and with proper parameters
reuse = true;
close /dev/loop0
last fd closed => loop0 is
cleaned up
loopcxt_get_fd()
opens loop0 but it is no longer the device we wanted!
calls mount(2) which fails because we cannot read from the loop device
Fix the problem by rechecking that loop device is still attached after
opening the device. This makes sure the kernel will not autoclear the
device anymore.
Karel Zak [Tue, 25 Jan 2022 10:04:13 +0000 (11:04 +0100)]
build-sys: generate all man pages for distribution tarball
Now "make dist" and "make distcheck" follows autoconf. It means that
disabled tools or tools that cannot compile are ignored, and man-pages
for these tools are not generated. This is a problem for people
without asciidoctor (adoc -> man generator).
Fixes: https://github.com/util-linux/util-linux/issues/1577 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Fri, 21 Jan 2022 11:10:44 +0000 (12:10 +0100)]
findmnt: (verify) ignore passno for btrfs
"Traditional filesystems need to run their respective fsck utility in case
the filesystem was not unmounted cleanly and the log needs to be replayed
before mount. This is not needed for btrfs. You should set fs_passno to 0."
Karel Zak [Mon, 17 Jan 2022 11:37:13 +0000 (12:37 +0100)]
libblkid: reopen floppy without O_NONBLOCK
Vladimir Sementsov-Ogievskiy wrote:
> The commit "floppy: reintroduce O_NDELAY fix" was removed from kernel,
> so we faced the bug described and discussed here:
> https://bugzilla.suse.com/show_bug.cgi?id=3D1181018
>
> Discussion in kernel list on reverting the commit:
> https://www.spinics.net/lists/stable/msg493061.html
>
> In short, I can quote Jiri Kosina's comment:
>
> opening floppy device node with O_NONBLOCK is asking for all kinds
> of trouble
>
> So opening floppy with O_NONBLOCK in blkid leads to failure of blkid,
> probable failure of mount and unpleasant error messages in dmesg (see
> also patch 02 for details).
Based on patch from Vladimir.
CC: Jiri Kosina <jkosina@suse.cz> Reported-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Tested-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Sean Anderson [Sat, 15 Jan 2022 16:29:26 +0000 (11:29 -0500)]
unshare: Fix doc comments
Several doc comments use the wrong terminology, or have mismatches
descriptions. Fix them.
Fixes: ff5dc96eb ("unshare: Add options to map blocks of user/group IDs") Signed-off-by: Sean Anderson <seanga2@gmail.com> Reported-by: Daniel Gerber <dg@atufi.org>
This commit fixes a regression and wrong file size handling:
checkf ends execution prematurely if st.st_size is 0. The idea was to
skip the check_magic call which would otherwise claim that a text file
would not be one, e.g. /proc/self/wchan would fail otherwise. This has
two consequences:
1. The last check in checkf is never true, because if st_size is 0 we
already left the function (file_size and st_size are both off_t).
Proof of Concept (use a window with less lines than /proc/cpuinfo):
$ echo "hello world" > /tmp/more-poc
$ more /tmp/more-poc /proc/cpuinfo
- Press space to switch to next file
- You see >100% in status line
2. Leaving early does not set the close on exit flag for empty files.
3. Since the last line is never reached, ~(off_t)0 is never set, which
implies that the check in display_file is never true.
The st.st_size = 0 case is supposed to be special. Simplify this
regression fix by considering ctl->file_size = 0 to be special. This
eleminates the ~(off_t)0 magic, which would be -1.
Thomas Weißschuh [Sat, 15 Jan 2022 08:54:08 +0000 (09:54 +0100)]
lspcu: Print dummy modelname if none present
The logic in print_summary_cputype() starts a new hierarchy level under
the CPUs "Model name" entry. If the model is unknown the hierarchy level
will be skipped. This is visually confusing in the human-readable
version and changes the schema of the JSON tree.
Earl Chew [Sun, 9 Jan 2022 22:01:21 +0000 (14:01 -0800)]
unshare: Propagate inherited signal handling to forked child
In #1086, signal(3) is used along with SIG_IGN,
and SIG_DFL, to prevent premature termination of
the parent. The present approach causes the
forked child to have different inherited
signal handling behaviour than original
behaviour inherited by the parent.
Sam James [Fri, 7 Jan 2022 01:54:41 +0000 (01:54 +0000)]
su: use LOG_PID for syslog
Enable PID in syslog lines for `su`.
In Gentoo Linux, we recently switched `su` providers from
shadow to util-linux.
It was notiiced that syslog output differs slightly
with util-linux (no PID):
```
Jan 7 20:00:50 localhost su: (to root) root on pts/5
Jan 7 20:00:50 localhost su: pam_unix(su:session): session opened for user root(uid=0) by sam(uid=0)
```
... whereas shadow's `su` gave (with PID):
```
Jan 7 20:52:50 localhost su[22245]: Successful su for root by root
Jan 7 20:52:50 localhost su[22245]: + /dev/pts/5 root:root
```
This change enables PID logging to give shadow-like syslog
output for `su`:
```
Jan 7 20:54:32 localhost su[10827]: (to root) root on pts/6
Jan 7 20:54:32 localhost su[10827]: pam_unix(su:session): session opened for user root(uid=0) by sam(uid=0)
```
Karel Zak [Tue, 4 Jan 2022 09:37:55 +0000 (10:37 +0100)]
libmount: remove support for deleted mount table entries
The "(deleted)" suffix has been originally used by kernel for deleted
mountpoints. Since kernel commit 9d4d65748a5ca26ea8650e50ba521295549bf4e3
(Dec 2014) kernel does not use this suffix for mount stuff in /proc at
all. Let's remove this support from libmount too.
Karel Zak [Mon, 3 Jan 2022 12:06:47 +0000 (13:06 +0100)]
Merge branch 'meson' of https://github.com/t-8ch/util-linux
* 'meson' of https://github.com/t-8ch/util-linux:
meson: only install pkgconfig if library is built
meson: install manpages and bash completions
meson: install examples to correct directory
meson: headers: Install headers
meson: headers: use util-linux version of version defines
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