kill.1.adoc: clarify syntax of -SIG argument in synopsis
kill.1.adoc has this synopsis line
*kill* [-signal|*-s* _signal_]
For "-signal", the leading "-" should be typed literally, and the
"signal" suffix should be replaced by a signal name/number.
This means that according to GNU man(1), the "-" should render in
bold font whereas the "signal" placeholder should use italic (which
terminals often render with underscores).
Make it so. Use two askerisks because one is not enough for sub-word
markup [*].
mount.8.adoc: use bold font for literal text in synopsis
In a synopsis, *bold* text means "type exactly as shown" (see man(1)).
mount.8.adoc has *--make*-[*shared*|...] which is weird because
the middle dash is not in bold even though it's meant to be typed
literally. Make it bold like the surrounding text.
Signed-off-by: Johannes Altmanninger <aclopte@gmail.com>
Karel Zak [Mon, 7 Feb 2022 09:48:24 +0000 (10:48 +0100)]
Merge branch 'lsfd-refine-test-cases-0' of https://github.com/masatake/util-linux
* 'lsfd-refine-test-cases-0' of https://github.com/masatake/util-linux:
tests: (lsfd) delete "largefile" flag in the output before the comparison
tests: (lsfd) add a missing word to the test output
tests: (lsfd) refine the pattern for comparing the output of the commands
tests: (lsfd) print more information for debugging
Karel Zak [Mon, 7 Feb 2022 09:46:39 +0000 (10:46 +0100)]
Merge branch 'helpversion' of https://github.com/mariobl/util-linux
* 'helpversion' of https://github.com/mariobl/util-linux:
ldattach.8.adoc: Add missing standard options
man pages: unify output of --help and --version
Masatake YAMATO [Fri, 4 Feb 2022 17:40:10 +0000 (02:40 +0900)]
tests: (lsfd) delete "largefile" flag in the output before the comparison
The original code didn't considered that syscalls opening a directory
on mips64 GNU/Linux took O_LARGEFILE flag. This misconsideration made
the mkfds-directory test FAILED as reported in
https://github.com/util-linux/util-linux/issues/1511#issuecomment-1029968595.
Karel Zak [Mon, 31 Jan 2022 09:05:29 +0000 (10:05 +0100)]
hwclock: get/set param cleanup
* move all code to hwclock-rtc.c
* use ul_strtou64() to simplify code
* use base=0 for ul_strtou64() to handle 10 and 16 base
* allocate for strtok() (we keep command line options read-only)
Bastian Krause [Fri, 21 Jan 2022 15:09:43 +0000 (16:09 +0100)]
hwclock: add --param-set option
Implement the RTC_PARAM_SET 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-set hwclock function accepts aliases for parameters
currently existent (Kernel v5.16). They can be extended later on. As
fallback and for values, hexadecimal (if prefixed with 0x) and decimal
values, as defined in [2], are accepted.
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)
```