Chris Webb [Sun, 23 Apr 2023 16:05:07 +0000 (17:05 +0100)]
libmount: check for errors from prep-options hooks
fix_optstr() in context_mount.c calls the MNT_STAGE_PREP_OPTIONS hooks
but discards returned errors. This suppresses error messages and can
make invalid option strings 'fail open' in surprising ways. Handle error
returns from these hooks correctly.
No other callers of mnt_context_call_hooks() discard the return value,
so other hooks aren't affected.
Karel Zak [Thu, 20 Apr 2023 10:10:17 +0000 (12:10 +0200)]
Merge branch 'lsfd--ping-test-description' of https://github.com/masatake/util-linux
* 'lsfd--ping-test-description' of https://github.com/masatake/util-linux:
tests: (lsfd) add losetup as a required cmd
tests: (lsfd) make the message for skipping the case more descriptive
tests: (mkfds) delete nls markers _("...") from the helper command
The option-inet test case has not run because it was incorrectly kept
as non-executable.
Mark the test case as "skip" in qmeu-user before making the test case
executable because we already know the case fails on qmeu-user. A fix
on qmeu-user may come later.
Karel Zak [Tue, 18 Apr 2023 13:54:25 +0000 (15:54 +0200)]
libmount: cleanup all stat() use
* don't use STATX_MODE as we need only file type
* use fstatat() or stat() as fallback on EOPNOTSUPP
* use st_rdev from statx() too
* rename to mnt_stat_mountpoint() to more generic mnt_safe_stat()
* use mnt_is_path() on more places
* cleanup mnt_context_*_excode() to not use stat()
* use on others places mnt_safe_stat()
Note that on some places stat() remaining, but it's not related to the
mountpoints, it's about /run/mount/utab permissions, file locking and
/dev/* permissions for non-root mounts.
Karel Zak [Mon, 17 Apr 2023 12:23:18 +0000 (14:23 +0200)]
libmount: use AT_STATX_DONT_SYNC when touch mountpoints
* prefer statx() with AT_STATX_DONT_SYNC if available
* keep fstatat() and stat() as fallback
* add test to mnt_stat_mountpoint()
The goal is to minimize situations when we need classic stat() because
it triggers automount, and stat() syscall may hang on unreachable
network filesystems. The automount issue was resolved years ago by
AT_NO_AUTOMOUNT; now we can use statx() to fix also hangs on NFS.
Addresses: https://github.com/util-linux/util-linux/issues/2049 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 17 Apr 2023 11:06:01 +0000 (13:06 +0200)]
Merge branch 'libblkid/crc32c-exclude' of https://github.com/t-8ch/util-linux
* 'libblkid/crc32c-exclude' of https://github.com/t-8ch/util-linux:
libblkid: xfs: clean up call to ul_crc32_exclude_offset
libblkid: erofs: calculate checksum with offset
Karel Zak [Mon, 17 Apr 2023 10:29:40 +0000 (12:29 +0200)]
hwclock: use kernel struct rtc_time for RTC ioctls
Based on patch from Matt Nourse.
Addresses: https://github.com/util-linux/util-linux/pull/2123 Reported-by: Matthew Nourse <matthew@nplus1.com.au> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 17 Apr 2023 09:41:02 +0000 (11:41 +0200)]
Merge branch 'lsfd--raspberrypi-32bit' of https://github.com/masatake/util-linux
* 'lsfd--raspberrypi-32bit' of https://github.com/masatake/util-linux:
tests: (lsfd) don't hardcode the inode number of netns in the expected output
tests: (lsfd) adjust the output for unix datagram sockets already connected
tests: (lsfd) adjust the output for unix datagram sockets created by socketpair
tests: (lsfd) check the exit status of the first command in the pipeline
tests: (lsfd) adjust the output for unix stream sockets
Karel Zak [Mon, 17 Apr 2023 09:25:09 +0000 (11:25 +0200)]
Merge branch 'fadvise/fixes' of https://github.com/t-8ch/util-linux
* 'fadvise/fixes' of https://github.com/t-8ch/util-linux:
fadvise: always exit with EXIT_FAILURE on error
fadvise: (man) document help and version arguments
fadvise: correctly report error from posix_fadvise
fadvise: implement --advice argument
Karel Zak [Mon, 17 Apr 2023 08:57:45 +0000 (10:57 +0200)]
Merge branch 'correct_blkid_xfs_output' of https://github.com/jlinton/util-linux
* 'correct_blkid_xfs_output' of https://github.com/jlinton/util-linux:
libblkid: Compute CRC with sb_crc zeroed
lib: Add crc32c function that can deal with holes
tests: (lsfd) adjust the output for unix datagram sockets already connected
Though older kernels report such sockets as "unconnected" via /proc/net/unix,
the newer kernels report them as "connected". The change is introduced in
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=83301b5367a98c17ec0d76c7bc0ccdc3c7e7ad6d
This caused a failure in a test case. To avoid the failure,
this change rewrites "unconnected" in the lsfd's output to "connected".
tests: (lsfd) adjust the output for unix datagram sockets created by socketpair
Though older kernels report such sockets as "unconnected" via /proc/net/unix,
the newer kernels report them as "connected". The change is introduced in
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=83301b5367a98c17ec0d76c7bc0ccdc3c7e7ad6d
This caused a failure in a test case. To avoid the failure,
this change rewrites "state=unconnected" in the lsfd's output
to "state=connected".
tests: (lsfd) adjust the output for unix stream sockets
lsfd changes the output of NAME column for a unix stream socket
whether the kernel reports it is a "UNIX-STREAM" socket or a "UNIX"
socket. Rather older version of kernels report the socket "UNIX"
For "UNIX", lsfd appends "type=stream" to the NAME column.
This caused a failure in test cases. To avoid the failure,
this change strips "type=stream" from the output before
comparing the output strings and expected strings.
Jeremy Linton [Fri, 14 Apr 2023 21:25:28 +0000 (16:25 -0500)]
libblkid: Compute CRC with sb_crc zeroed
The Linux kernel computes the sb_crc by crcing the
superblock with the CRC field set to 0. The code is
trying to avoid doing this in three separate CRC calls
like the kernel performs by simply zeroing the field
and making a single call.
Except that the passed copy "ondisk" isn't the same
as the returned copy "csummed" so the zeroing goes into
the wrong buffer. Meaning that the CRC is computed
incorrectly. This results in blkid returning:
Which can result in lots of failures including boot
failures if XFS modules aren't placed into the initrd,
or scripts/etc cannot determine the fs UUID.
Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
Jeremy Linton [Fri, 14 Apr 2023 23:07:29 +0000 (18:07 -0500)]
lib: Add crc32c function that can deal with holes
XFS, and possibly other filesystems expect that the CRC field
is excluded (or rather RAZ) during the CRC operation. Lets
create a generic helper that is similar to the CRC32 version
ul_crc32_exclude_offset() which computes the CRC while replacing
exclude_len bytes of exclude_off with zeros.
Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
Karel Zak [Tue, 11 Apr 2023 10:04:30 +0000 (12:04 +0200)]
Merge branch 'hwclock/cleanup' of https://github.com/t-8ch/util-linux
* 'hwclock/cleanup' of https://github.com/t-8ch/util-linux:
hwclock: use linux/rtc.h
hwclock: drop ancient sparc special cases
hwclock: constify struct clock_opts
hwclock: (tests) add simple test to show rtc time
Karel Zak [Wed, 5 Apr 2023 19:44:55 +0000 (21:44 +0200)]
libmount: fix superblock rw/ro reconfiguration
The classic mount(2) defaults to 'rw', but the new API does not reset
superblock to 'rw' if the flag is not explicitly used for
FSCONFIG_CMD_RECONFIGURE.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2180593 Signed-off-by: Karel Zak <kzak@redhat.com>
For a long time, since commit 607ca46e97a1 ("UAPI: (Scripted) Disintegrate include/linux")
the kernel provided a dedicate uapi include for RTC definitions.
This makes the comment linux/mc146818rtc.h obsolete.