Compare commits

..

No commits in common. 'c10-beta' and 'c9' have entirely different histories.
c10-beta ... c9

2
.gitignore vendored

@ -1 +1 @@
SOURCES/util-linux-2.40.2.tar.xz SOURCES/util-linux-2.37.4.tar.xz

@ -1 +1 @@
59d363aa55d8b74abd7663545c29b353524294af SOURCES/util-linux-2.40.2.tar.xz 6e6c49c1dbb288b90b933e4328bde4786172f021 SOURCES/util-linux-2.37.4.tar.xz

@ -1,20 +1,18 @@
From a9d027ee07f56b67054ec8ef02481a1e60429f6d Mon Sep 17 00:00:00 2001 From ef8c8e117234f135a22ba7180114f0153b2444d8 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com> From: Karel Zak <kzak@redhat.com>
Date: Wed, 10 Jul 2024 10:29:20 +0200 Date: Mon, 20 Jun 2016 11:09:02 +0200
Subject: login: lastlog create Subject: login: create /var/log/lastlog
This is port of the old RHEL patch to RHEL-10. Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=151635
Signed-off-by: Karel Zak <kzak@redhat.com>
--- ---
login-utils/login.c | 2 +- login-utils/login.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-) 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/login-utils/login.c b/login-utils/login.c diff --git a/login-utils/login.c b/login-utils/login.c
index c8544f6a1..3de0398e9 100644 index c6cd340b6..3657f04cd 100644
--- a/login-utils/login.c --- a/login-utils/login.c
+++ b/login-utils/login.c +++ b/login-utils/login.c
@@ -681,7 +681,7 @@ static void log_lastlog(struct login_context *cxt) @@ -662,7 +662,7 @@ static void log_lastlog(struct login_context *cxt)
sa.sa_handler = SIG_IGN; sa.sa_handler = SIG_IGN;
sigaction(SIGXFSZ, &sa, &oldsa_xfsz); sigaction(SIGXFSZ, &sa, &oldsa_xfsz);
@ -24,5 +22,5 @@ index c8544f6a1..3de0398e9 100644
goto done; goto done;
offset = cxt->pwd->pw_uid * sizeof(ll); offset = cxt->pwd->pw_uid * sizeof(ll);
-- --
2.45.2 2.34.1

@ -1,17 +1,17 @@
From c4354ccde565c742a75816ef46c2f7265415f1f7 Mon Sep 17 00:00:00 2001 From c8574869e60a0351551cb281872e08b4d8fc68d8 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com> From: Karel Zak <kzak@redhat.com>
Date: Wed, 10 Jul 2024 10:30:42 +0200 Date: Tue, 24 Aug 2021 13:50:57 +0200
Subject: login: default motd file Subject: login: default motd file
This is port of the old RHEL patch to RHEL-10. Add `/run/motd.d` to the hardcoded MOTD_FILE
Signed-off-by: Karel Zak <kzak@redhat.com> Addresses: https://github.com/coreos/console-login-helper-messages/issues/60
--- ---
include/pathnames.h | 2 +- include/pathnames.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-) 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/pathnames.h b/include/pathnames.h diff --git a/include/pathnames.h b/include/pathnames.h
index de456c53e..ac28a9a50 100644 index 9be2baa83..7e7d9053f 100644
--- a/include/pathnames.h --- a/include/pathnames.h
+++ b/include/pathnames.h +++ b/include/pathnames.h
@@ -41,7 +41,7 @@ @@ -41,7 +41,7 @@
@ -24,5 +24,5 @@ index de456c53e..ac28a9a50 100644
# define _PATH_NOLOGIN "/etc/nologin" # define _PATH_NOLOGIN "/etc/nologin"
#endif #endif
-- --
2.45.2 2.34.1

@ -0,0 +1,30 @@
From 38b2b2e49e72638639c997e532a846ee935ce148 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 23 Aug 2021 15:15:38 +0200
Subject: tests: make ./run.sh more robust
Let's make upstream tests more stable to be usable in RHEL
environment where we do not use ASAN and meson.
Upstream: http://github.com/karelzak/util-linux/commit/331c5e0c54d9cb6f67dc3e825eec2d78c67d8ce6
Signed-off-by: Karel Zak <kzak@redhat.com>
---
tests/run.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/run.sh b/tests/run.sh
index 9d26406c4..d020bfe88 100755
--- a/tests/run.sh
+++ b/tests/run.sh
@@ -165,7 +165,7 @@ OPTS="$OPTS --srcdir=$top_srcdir --builddir=$top_builddir"
if [ -z "$has_asan_opt" ]; then
if [ -e "$top_builddir/Makefile" ]; then
asan=$(awk '/^ASAN_LDFLAGS/ { print $3 }' $top_builddir/Makefile)
- else
+ elif [ -f "$top_builddir/meson.conf" ]; then
. "$top_builddir/meson.conf"
fi
if [ -n "$asan" ]; then
--
2.34.1

@ -1,34 +0,0 @@
From 151dbf45503032839c02d07d8a5c89e2d064cb34 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 9 Jul 2024 17:04:09 +0200
Subject: uuidd: fix /var/lib/libuuid mode uuidd-tmpfiles.conf
The directory can be directly used by libuuid, for example, by running
"uuidgen --time" as root, even if the uuidd daemon is not installed.
In this case, we must create a clock.txt file with the uuidd group to
prevent any potential ownership mismatch if the uuidd daemon is
installed later. The 2xxx mode (setgid) forces open(O_CREAT) in
libuuid to create the file with the uuidd group.
Please note that mode 2755 is the standard used for years in RHEL.
Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit e0c41735aa13a7a62e42c0428823537d3edc02a8)
(cherry picked from commit 555152c36b1026ea97eb06a9a57fac154fa36ed0)
---
misc-utils/uuidd-tmpfiles.conf.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/misc-utils/uuidd-tmpfiles.conf.in b/misc-utils/uuidd-tmpfiles.conf.in
index b362930d8..90b8a8537 100644
--- a/misc-utils/uuidd-tmpfiles.conf.in
+++ b/misc-utils/uuidd-tmpfiles.conf.in
@@ -3,4 +3,4 @@
# See tmpfiles.d(5) for details
#
d @runstatedir@/uuidd 2775 uuidd uuidd -
-d @localstatedir@/lib/libuuid 0755 uuidd uuidd -
+d @localstatedir@/lib/libuuid 2755 uuidd uuidd -
--
2.45.2

@ -0,0 +1,66 @@
From a4d1feed2803a5c0596877b64487734bcdb781ef Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 23 Aug 2021 16:28:52 +0200
Subject: tests: make mount/fstab-all more robust
Upstream: http://github.com/karelzak/util-linux/commit/85ae61dd6d956e7c9fe2b22b8c46bb1d0bfd13da
Signed-off-by: Karel Zak <kzak@redhat.com>
---
tests/ts/mount/fstab-all | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tests/ts/mount/fstab-all b/tests/ts/mount/fstab-all
index acc64e462..6b7018823 100755
--- a/tests/ts/mount/fstab-all
+++ b/tests/ts/mount/fstab-all
@@ -79,6 +79,7 @@ echo "${TS_DEVICE}4 ${MOUNTPOINT}D ext4 rw,defaults 0 0" >> $MY_FSTAB
ts_init_subtest "basic"
$TS_CMD_MOUNT --all --fstab $MY_FSTAB >> $TS_OUTPUT 2>> $TS_ERRLOG
[ $? == 0 ] || ts_log "mount failed"
+udevadm settle
$TS_CMD_UMOUNT ${MOUNTPOINT}{A,B,C,D}
[ $? == 0 ] || ts_log "umount failed"
ts_finalize_subtest
@@ -87,6 +88,7 @@ ts_finalize_subtest
ts_init_subtest "filter-type"
$TS_CMD_MOUNT --all --fstab $MY_FSTAB -t ext4 >> $TS_OUTPUT 2>> $TS_ERRLOG
[ $? == 0 ] || ts_log "mount failed"
+udevadm settle
$TS_CMD_UMOUNT ${MOUNTPOINT}D
[ $? == 0 ] || ts_log "umount failed"
ts_finalize_subtest
@@ -95,6 +97,7 @@ ts_finalize_subtest
ts_init_subtest "filter-notype"
$TS_CMD_MOUNT --all --fstab $MY_FSTAB -t noext4 >> $TS_OUTPUT 2>> $TS_ERRLOG
[ $? == 0 ] || ts_log "mount failed"
+udevadm settle
$TS_CMD_UMOUNT ${MOUNTPOINT}{A,B,C}
[ $? == 0 ] || ts_log "umount failed"
ts_finalize_subtest
@@ -103,6 +106,7 @@ ts_finalize_subtest
ts_init_subtest "filter-option"
$TS_CMD_MOUNT --all --fstab $MY_FSTAB -O ro >> $TS_OUTPUT 2>> $TS_ERRLOG
[ $? == 0 ] || ts_log "mount failed"
+udevadm settle
$TS_CMD_UMOUNT ${MOUNTPOINT}C
[ $? == 0 ] || ts_log "umount failed"
ts_finalize_subtest
@@ -111,6 +115,7 @@ ts_finalize_subtest
ts_init_subtest "override-option"
$TS_CMD_MOUNT --all --fstab $MY_FSTAB -o ro >> $TS_OUTPUT 2>> $TS_ERRLOG
[ $? == 0 ] || ts_log "mount failed"
+udevadm settle
$TS_CMD_UMOUNT ${MOUNTPOINT}{A,B,C,D}
[ $? == 0 ] || ts_log "umount failed"
ts_finalize_subtest
@@ -132,6 +137,7 @@ $TS_CMD_MOUNT --all \
--target-prefix $MY_ROOT \
-o X-mount.mkdir >> $TS_OUTPUT 2>> $TS_ERRLOG
[ $? == 0 ] || ts_log "mount failed"
+udevadm settle
$TS_CMD_UMOUNT $MY_ROOT/foo/{A,B,C,D}
[ $? == 0 ] || ts_log "umount failed"
ts_finalize_subtest
--
2.34.1

@ -1,28 +0,0 @@
From 5a3ce382501f4b56dbf8a6989d56c7aac63c0314 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Wed, 10 Jul 2024 15:55:35 +0200
Subject: uuidd: fix typo in tmpfiles.conf
Let's change 2755 to 2775. The directory must be writable for the
'uuidd' group.
Addresses: http://github.com/util-linux/util-linux/commit/e0c41735aa13a7a62e42c0428823537d3edc02a8
Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit 7af2539f58b3bd3bb2f5e44138595be116c8d76c)
---
misc-utils/uuidd-tmpfiles.conf.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/misc-utils/uuidd-tmpfiles.conf.in b/misc-utils/uuidd-tmpfiles.conf.in
index 90b8a8537..2245b1b7e 100644
--- a/misc-utils/uuidd-tmpfiles.conf.in
+++ b/misc-utils/uuidd-tmpfiles.conf.in
@@ -3,4 +3,4 @@
# See tmpfiles.d(5) for details
#
d @runstatedir@/uuidd 2775 uuidd uuidd -
-d @localstatedir@/lib/libuuid 2755 uuidd uuidd -
+d @localstatedir@/lib/libuuid 2775 uuidd uuidd -
--
2.45.2

@ -0,0 +1,42 @@
From 54c1c6895ec53929d44153073a862521f6ed869d Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 24 Aug 2021 10:49:32 +0200
Subject: tests: make eject umount tests more robust
Upstream: http://github.com/karelzak/util-linux/commit/abe16d0d34413555fbd621f90a0b93c2105116a2
Signed-off-by: Karel Zak <kzak@redhat.com>
---
tests/ts/eject/umount | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tests/ts/eject/umount b/tests/ts/eject/umount
index 2be281ee3..04f53ed99 100755
--- a/tests/ts/eject/umount
+++ b/tests/ts/eject/umount
@@ -83,6 +83,7 @@ mkfs.ext2 -q -F $TS_DEVICE
udevadm settle
mkdir -p $TS_MOUNTPOINT
$TS_CMD_MOUNT $TS_DEVICE $TS_MOUNTPOINT
+udevadm settle
$TS_CMD_EJECT --force $TS_DEVICE && ts_log "Success"
deinit_device
ts_finalize_subtest
@@ -95,6 +96,7 @@ mkdir -p ${TS_MOUNTPOINT}1
mkdir -p ${TS_MOUNTPOINT}2
$TS_CMD_MOUNT ${TS_DEVICE}1 ${TS_MOUNTPOINT}1
$TS_CMD_MOUNT ${TS_DEVICE}2 ${TS_MOUNTPOINT}2
+udevadm settle
$TS_CMD_EJECT --force $TS_DEVICE && ts_log "Success"
deinit_device
ts_finalize_subtest
@@ -115,6 +117,7 @@ mkdir -p ${TS_MOUNTPOINT}1
mkdir -p ${TS_MOUNTPOINT}2
$TS_CMD_MOUNT ${TS_DEVICE}1 ${TS_MOUNTPOINT}1
$TS_CMD_MOUNT ${TS_DEVICE}2 ${TS_MOUNTPOINT}2
+udevadm settle
$TS_CMD_EJECT --force ${TS_DEVICE}1 && ts_log "Success"
deinit_device
ts_finalize_subtest
--
2.34.1

@ -0,0 +1,52 @@
From 41ae35c39241575c63db204c786cb1423c202815 Mon Sep 17 00:00:00 2001
From: "Andrew G. Morgan" <morgan@kernel.org>
Date: Sat, 27 Nov 2021 21:00:22 -0800
Subject: Complete Linux-PAM compliance for forked child in su and login.
As documented here:
http://www.linux-pam.org/Linux-PAM-html/adg-interface-by-app-expected.html#adg-pam_end
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.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2037212
Upstream: http://github.com/util-linux/util-linux/commit/4660286e9cdff6d95b49295674b96f83af10ea36
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
---
login-utils/login.c | 3 +++
login-utils/su-common.c | 3 +++
2 files changed, 6 insertions(+)
diff --git a/login-utils/login.c b/login-utils/login.c
index 3657f04cd..c62e91e94 100644
--- a/login-utils/login.c
+++ b/login-utils/login.c
@@ -1521,6 +1521,9 @@ int main(int argc, char **argv)
child_argv[child_argc++] = NULL;
+ /* http://www.linux-pam.org/Linux-PAM-html/adg-interface-by-app-expected.html#adg-pam_end */
+ (void) pam_end(cxt.pamh, PAM_SUCCESS|PAM_DATA_SILENT);
+
execvp(child_argv[0], child_argv + 1);
if (!strcmp(child_argv[0], "/bin/sh"))
diff --git a/login-utils/su-common.c b/login-utils/su-common.c
index afd0ea8ad..7d4826bbc 100644
--- a/login-utils/su-common.c
+++ b/login-utils/su-common.c
@@ -1231,6 +1231,9 @@ int su_main(int argc, char **argv, int mode)
if (su->simulate_login && chdir(su->pwd->pw_dir) != 0)
warn(_("warning: cannot change directory to %s"), su->pwd->pw_dir);
+ /* http://www.linux-pam.org/Linux-PAM-html/adg-interface-by-app-expected.html#adg-pam_end */
+ (void) pam_end(su->pamh, PAM_SUCCESS|PAM_DATA_SILENT);
+
if (shell)
run_shell(su, shell, command, argv + optind, max(0, argc - optind));
--
2.34.1

@ -0,0 +1,70 @@
From a80ba745cc54d5ba726e48065aebe6dac50dedd2 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 24 Jan 2022 14:08:08 +0100
Subject: uuidd: fix open/lock state issue
* warn on open/lock state issue
* enable access to /var/lib/libuuid/, because ProtectSystem=strict make it read-only
openat(AT_FDCWD, "/var/lib/libuuid/clock.txt",
O_RDWR|O_CREAT|O_CLOEXEC, 0660) = -1 EROFS (Read-only file system)
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2040366
Upstream: http://github.com/util-linux/util-linux/commit/f27876f9c1056bf41fd940d5c4990b4277e0024f
Upstream: http://github.com/util-linux/util-linux/commit/417982d0236a12756923d88e627f5e4facf8951c
Signed-off-by: Karel Zak <kzak@redhat.com>
---
misc-utils/uuidd.c | 9 ++++++---
misc-utils/uuidd.service.in | 1 +
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/misc-utils/uuidd.c b/misc-utils/uuidd.c
index fa8db173b..78a37d2e8 100644
--- a/misc-utils/uuidd.c
+++ b/misc-utils/uuidd.c
@@ -494,7 +494,8 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
break;
case UUIDD_OP_TIME_UUID:
num = 1;
- __uuid_generate_time(uu, &num);
+ if (__uuid_generate_time(uu, &num) < 0 && !uuidd_cxt->quiet)
+ warnx(_("failed to open/lock clock counter"));
if (uuidd_cxt->debug) {
uuid_unparse(uu, str);
fprintf(stderr, _("Generated time UUID: %s\n"), str);
@@ -504,7 +505,8 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
break;
case UUIDD_OP_RANDOM_UUID:
num = 1;
- __uuid_generate_random(uu, &num);
+ if (__uuid_generate_time(uu, &num) < 0 && !uuidd_cxt->quiet)
+ warnx(_("failed to open/lock clock counter"));
if (uuidd_cxt->debug) {
uuid_unparse(uu, str);
fprintf(stderr, _("Generated random UUID: %s\n"), str);
@@ -513,7 +515,8 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
reply_len = sizeof(uu);
break;
case UUIDD_OP_BULK_TIME_UUID:
- __uuid_generate_time(uu, &num);
+ if (__uuid_generate_time(uu, &num) < 0 && !uuidd_cxt->quiet)
+ warnx(_("failed to open/lock clock counter"));
if (uuidd_cxt->debug) {
uuid_unparse(uu, str);
fprintf(stderr, P_("Generated time UUID %s "
diff --git a/misc-utils/uuidd.service.in b/misc-utils/uuidd.service.in
index b4c9c4635..e64ca59b5 100644
--- a/misc-utils/uuidd.service.in
+++ b/misc-utils/uuidd.service.in
@@ -18,6 +18,7 @@ ProtectKernelModules=yes
ProtectControlGroups=yes
RestrictAddressFamilies=AF_UNIX
MemoryDenyWriteExecute=yes
+ReadWritePaths=/var/lib/libuuid/
SystemCallFilter=@default @file-system @basic-io @system-service @signal @io-event @network-io
[Install]
--
2.34.1

@ -0,0 +1,51 @@
From 9c45c4bf1a1a02ebaf9e24fd7d81d62c676eda7c Mon Sep 17 00:00:00 2001
From: Portisch <hugo.portisch@yahoo.de>
Date: Mon, 8 Nov 2021 12:31:39 +0100
Subject: sysfs: fallback for partitions not including parent name
Upstream: http://github.com/util-linux/util-linux/commit/9b59641bcec3df9c451eea4c7057751a153a3fcb
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2021462
Signed-off-by: Karel Zak <kzak@redhat.com>
---
lib/sysfs.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/lib/sysfs.c b/lib/sysfs.c
index bb7183319..191d870f6 100644
--- a/lib/sysfs.c
+++ b/lib/sysfs.c
@@ -210,9 +210,10 @@ int sysfs_blkdev_is_partition_dirent(DIR *dir, struct dirent *d, const char *par
d->d_type != DT_UNKNOWN)
return 0;
#endif
+ size_t len = 0;
+
if (parent_name) {
const char *p = parent_name;
- size_t len;
/* /dev/sda --> "sda" */
if (*parent_name == '/') {
@@ -223,14 +224,15 @@ int sysfs_blkdev_is_partition_dirent(DIR *dir, struct dirent *d, const char *par
}
len = strlen(p);
- if (strlen(d->d_name) <= len)
- return 0;
+ if ((strlen(d->d_name) <= len) || (strncmp(p, d->d_name, len) != 0))
+ len = 0;
+ }
+ if (len > 0) {
/* partitions subdir name is
* "<parent>[:digit:]" or "<parent>p[:digit:]"
*/
- return strncmp(p, d->d_name, len) == 0 &&
- ((*(d->d_name + len) == 'p' && isdigit(*(d->d_name + len + 1)))
+ return ((*(d->d_name + len) == 'p' && isdigit(*(d->d_name + len + 1)))
|| isdigit(*(d->d_name + len)));
}
--
2.34.1

@ -0,0 +1,61 @@
From 199c328686aac174b0535619e5cea8450016e827 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Thu, 21 Oct 2021 18:47:40 +0200
Subject: logger: fix --size use for stdin
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The stdin version counts log header into the message size, but
for example when it reads message from argv[] it counts only message
itself.
$ logger --stderr --size 3 "abcd"
<13>Oct 21 18:48:29 kzak: abc
$ echo "abcd" | logger --stderr --size 3
logger: cannot allocate 18446744073709551597 bytes: Cannot allocate memory
Upstream: http://github.com/util-linux/util-linux/commit/58e4ee082bca100034791a4a74481f263bb30a25
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2033622
Signed-off-by: Karel Zak <kzak@redhat.com>
---
misc-utils/logger.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/misc-utils/logger.c b/misc-utils/logger.c
index 5b122de79..43284caeb 100644
--- a/misc-utils/logger.c
+++ b/misc-utils/logger.c
@@ -976,8 +976,7 @@ static void logger_stdin(struct logger_ctl *ctl)
int has_header = 1;
int default_priority = ctl->pri;
int last_pri = default_priority;
- size_t max_usrmsg_size = ctl->max_message_size - strlen(ctl->hdr);
- char *const buf = xmalloc(max_usrmsg_size + 2 + 2);
+ char *buf = xmalloc(ctl->max_message_size + 2 + 2);
int pri;
int c;
size_t i;
@@ -1004,16 +1003,14 @@ static void logger_stdin(struct logger_ctl *ctl)
ctl->pri = default_priority;
if (ctl->pri != last_pri) {
- has_header = 0;
- max_usrmsg_size =
- ctl->max_message_size - strlen(ctl->hdr);
+ generate_syslog_header(ctl);
last_pri = ctl->pri;
}
if (c != EOF && c != '\n')
c = getchar();
}
- while (c != EOF && c != '\n' && i < max_usrmsg_size) {
+ while (c != EOF && c != '\n' && i < ctl->max_message_size) {
buf[i++] = c;
c = getchar();
}
--
2.34.1

@ -0,0 +1,54 @@
From 006aca565d4c8565baf05296b8e65ca4d5f203d3 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Fri, 30 Jul 2021 13:22:54 +0200
Subject: wdctl: Workaround reported boot-status bits not being present in
wd->ident.options
Some watchdog drivers are capable of reporting WDIOF_CARDRESET in their
bootstatus, but they do not advertise this in the options field
returned by the WDIOC_GETSUPPORT ioctl.
This causes wdctl to not print the CARDRESET flag on these devices,
even when the reset was caused by the watchdog and this is being
reported in the WDIOC_GETBOOTSTATUS return.
Add a workaround by or-ing any bits which are set in the status and
bstatus returns into wd->ident.options so that reported flags will
get printend independent of them being advertised as supported in
wd->ident.options.
This will make wdctl print a CARDRESET line when the system was
actually reset by the watchdog while omitting it when it was not
reset by the watchdog. At least on drivers which have the
CARDRESET is missing from info.options problem. On other drivers
the CARDRESET line will always be printend, but the actual reported
value will change.
Upstream: http://github.com/util-linux/util-linux/commit/b1b0259fe42aad1bf0997ce1c03a020ce59e38ab
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2057046
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
sys-utils/wdctl.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/sys-utils/wdctl.c b/sys-utils/wdctl.c
index 8de5d5a2d..6b9affa0a 100644
--- a/sys-utils/wdctl.c
+++ b/sys-utils/wdctl.c
@@ -419,6 +419,13 @@ static int read_watchdog_from_device(struct wd_device *wd)
ioctl(fd, WDIOC_GETSTATUS, &wd->status);
ioctl(fd, WDIOC_GETBOOTSTATUS, &wd->bstatus);
+ /*
+ * Sometimes supported options like WDIOF_CARDRESET are missing from
+ * ident.options, add anything set in status/bstatus to ident.options.
+ */
+ wd->ident.options |= wd->status;
+ wd->ident.options |= wd->bstatus;
+
if (ioctl(fd, WDIOC_GETTIMEOUT, &wd->timeout) >= 0)
wd->has_timeout = 1;
if (ioctl(fd, WDIOC_GETPRETIMEOUT, &wd->pretimeout) >= 0)
--
2.34.1

@ -0,0 +1,28 @@
From 097fc3427d3221d763f0b1c41923758af2f471a3 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Thu, 21 Jul 2022 10:57:36 +0200
Subject: lslogins: remove unexpected debug message
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2094216
Signed-off-by: Karel Zak <kzak@redhat.com>
---
login-utils/lslogins.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c
index 9431a50bb..c37df9096 100644
--- a/login-utils/lslogins.c
+++ b/login-utils/lslogins.c
@@ -562,9 +562,6 @@ static int get_sgroups(gid_t **list, size_t *len, struct passwd *pwd)
*list = xcalloc(1, ngroups * sizeof(gid_t));
-fprintf(stderr, "KZAK>>> alloc '%p' for %s\n", *list, pwd->pw_name);
-
-
/* now for the actual list of GIDs */
if (-1 == getgrouplist(pwd->pw_name, pwd->pw_gid, *list, &ngroups))
return -1;
--
2.36.1

@ -0,0 +1,92 @@
From 53339f53ab71c138578d4102a4e4011344d33b2d Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 7 Jun 2022 09:11:56 +0200
Subject: lslogins: improve prefixes interpretation
It seems that for example 'passwd --lock' uses two exclamation marks
in password field. It seems better to assume arbitrary number of '!'
and '*' prefixes.
The patch also makes description of the PWD-EMPTY output field more
explicit.
Upstream: http://github.com/util-linux/util-linux/commit/c51cba1e838ae7e36a843ec785543492bb8737cd
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2094216
Signed-off-by: Karel Zak <kzak@redhat.com>
---
login-utils/lslogins.c | 33 ++++++++++++++++++++++++++-------
1 file changed, 26 insertions(+), 7 deletions(-)
diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c
index c37df9096..1332a9925 100644
--- a/login-utils/lslogins.c
+++ b/login-utils/lslogins.c
@@ -225,7 +225,7 @@ static const struct lslogins_coldesc coldescs[] =
{
[COL_USER] = { "USER", N_("user name"), N_("Username"), 0.1, SCOLS_FL_NOEXTREMES },
[COL_UID] = { "UID", N_("user ID"), "UID", 1, SCOLS_FL_RIGHT},
- [COL_PWDEMPTY] = { "PWD-EMPTY", N_("password not required"), N_("Password not required"), 1, SCOLS_FL_RIGHT },
+ [COL_PWDEMPTY] = { "PWD-EMPTY", N_("password not defined"), N_("Password not required (empty)"), 1, SCOLS_FL_RIGHT },
[COL_PWDDENY] = { "PWD-DENY", N_("login by password disabled"), N_("Login by password disabled"), 1, SCOLS_FL_RIGHT },
[COL_PWDLOCK] = { "PWD-LOCK", N_("password defined, but locked"), N_("Password is locked"), 1, SCOLS_FL_RIGHT },
[COL_PWDMETHOD] = { "PWD-METHOD", N_("password encryption method"), N_("Password encryption method"), 0.1 },
@@ -817,23 +817,42 @@ static struct lslogins_user *get_user_info(struct lslogins_control *ctl, const c
break;
case COL_PWDEMPTY:
if (shadow) {
- if (!*shadow->sp_pwdp) /* '\0' */
+ const char *p = shadow->sp_pwdp;
+
+ while (p && (*p == '!' || *p == '*'))
+ p++;
+
+ if (!p || !*p)
user->pwd_empty = STATUS_TRUE;
} else
user->pwd_empty = STATUS_UNKNOWN;
break;
case COL_PWDDENY:
if (shadow) {
- if ((*shadow->sp_pwdp == '!' ||
- *shadow->sp_pwdp == '*') &&
- !valid_pwd(shadow->sp_pwdp + 1))
+ const char *p = shadow->sp_pwdp;
+
+ while (p && (*p == '!' || *p == '*'))
+ p++;
+
+ if (p && *p && p != shadow->sp_pwdp && !valid_pwd(p))
user->pwd_deny = STATUS_TRUE;
} else
user->pwd_deny = STATUS_UNKNOWN;
break;
case COL_PWDLOCK:
if (shadow) {
- if (*shadow->sp_pwdp == '!' && valid_pwd(shadow->sp_pwdp + 1))
+ const char *p = shadow->sp_pwdp;
+ int i = 0;
+
+ /* 'passwd --lock' uses two exclamation marks,
+ * shadow(5) describes the lock as "field which
+ * starts with an exclamation mark". Let's
+ * support more '!' ...
+ */
+ while (p && *p == '!')
+ p++, i++;
+
+ if (i != 0 && (!*p || valid_pwd(p)))
user->pwd_lock = STATUS_TRUE;
} else
user->pwd_lock = STATUS_UNKNOWN;
@@ -842,7 +861,7 @@ static struct lslogins_user *get_user_info(struct lslogins_control *ctl, const c
if (shadow) {
const char *p = shadow->sp_pwdp;
- if (*p == '!' || *p == '*')
+ while (p && (*p == '!' || *p == '*'))
p++;
user->pwd_method = get_pwd_method(p, NULL, NULL);
} else
--
2.36.1

@ -0,0 +1,38 @@
From c269e116ea4d9e96a5f5801aecf1f624199fa6ec Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 7 Jun 2022 09:46:54 +0200
Subject: lslogins: fix free(): invalid pointer
Upstream: http://github.com/util-linux/util-linux/commit/890d4d3f236e2d28db35ea9bc9dc3e5e35db975c
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2094216
Signed-off-by: Karel Zak <kzak@redhat.com>
---
login-utils/lslogins.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c
index 1332a9925..ff4386d1b 100644
--- a/login-utils/lslogins.c
+++ b/login-utils/lslogins.c
@@ -488,7 +488,7 @@ static int parse_utmpx(const char *path, size_t *nrecords, struct utmpx **record
/* optimize allocation according to file size, the realloc() below is
* just fallback only */
- if (stat(path, &st) == 0 && (size_t) st.st_size > sizeof(struct utmpx)) {
+ if (stat(path, &st) == 0 && (size_t) st.st_size >= sizeof(struct utmpx)) {
imax = st.st_size / sizeof(struct utmpx);
ary = xmalloc(imax * sizeof(struct utmpx));
}
@@ -1007,6 +1007,9 @@ static void free_ctl(struct lslogins_control *ctl)
{
size_t n = 0;
+ if (!ctl)
+ return;
+
free(ctl->wtmp);
free(ctl->btmp);
--
2.36.1

@ -0,0 +1,30 @@
From 1c4ee8348e220b633d676214fd585ee2b3945cf6 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 6 Jun 2022 16:14:14 +0200
Subject: login-utils/logindefs: fix compiler warning
[-Werror=format-truncation=]
Upstream: http://github.com/util-linux/util-linux/commit/977f98ee34ca002cb5301c2d3a5953c754f813ec
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2094216
Signed-off-by: Karel Zak <kzak@redhat.com>
---
login-utils/logindefs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/login-utils/logindefs.c b/login-utils/logindefs.c
index 97150dc28..95631223a 100644
--- a/login-utils/logindefs.c
+++ b/login-utils/logindefs.c
@@ -521,7 +521,8 @@ int get_hushlogin_status(struct passwd *pwd, int force_check)
if (strlen(pwd->pw_dir) + strlen(file) + 2 > sizeof(buf))
continue;
- sprintf(buf, "%s/%s", pwd->pw_dir, file);
+ if (snprintf(buf, sizeof(buf), "%s/%s", pwd->pw_dir, file) < 0)
+ continue;
if (force_check) {
uid_t ruid = getuid();
--
2.36.1

@ -0,0 +1,38 @@
From 3ceddbb1238e13a51efbe23119c885568e820e69 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Thu, 2 Jun 2022 16:55:49 +0200
Subject: uuidd: allow AF_INET in systemd service
libuuid uses
socket(AF_INET, SOCK_DGRAM, IPPROTO_IP)
to get MAC address for time based UUIDs, but there is
RestrictAddressFamilies=AF_UNIX
in uuidd service file ...
Fixes: https://github.com/util-linux/util-linux/issues/1704
Upstream: http://github.com/util-linux/util-linux/commit/304b4dc4936b115ca33af5325c3b04d0997c1353
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2092943
Signed-off-by: Karel Zak <kzak@redhat.com>
---
misc-utils/uuidd.service.in | 1 -
1 file changed, 1 deletion(-)
diff --git a/misc-utils/uuidd.service.in b/misc-utils/uuidd.service.in
index e64ca59b5..64580287f 100644
--- a/misc-utils/uuidd.service.in
+++ b/misc-utils/uuidd.service.in
@@ -16,7 +16,6 @@ PrivateUsers=yes
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectControlGroups=yes
-RestrictAddressFamilies=AF_UNIX
MemoryDenyWriteExecute=yes
ReadWritePaths=/var/lib/libuuid/
SystemCallFilter=@default @file-system @basic-io @system-service @signal @io-event @network-io
--
2.36.1

@ -0,0 +1,28 @@
From bf0cd2995c5e34338703105c62e49a785c6c9dcc Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Fri, 3 Jun 2022 09:07:09 +0200
Subject: uuidd: remove also PrivateNetwork=yes from systemd service
Fixes: https://github.com/util-linux/util-linux/issues/1704
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2092943
Upstream: http://github.com/util-linux/util-linux/commit/c9671a3cf7738bb81e1cbef2f56485a36c6e7623
Signed-off-by: Karel Zak <kzak@redhat.com>
---
misc-utils/uuidd.service.in | 1 -
1 file changed, 1 deletion(-)
diff --git a/misc-utils/uuidd.service.in b/misc-utils/uuidd.service.in
index 64580287f..4ad6d97c9 100644
--- a/misc-utils/uuidd.service.in
+++ b/misc-utils/uuidd.service.in
@@ -11,7 +11,6 @@ Group=uuidd
ProtectSystem=strict
ProtectHome=yes
PrivateDevices=yes
-PrivateNetwork=yes
PrivateUsers=yes
ProtectKernelTunables=yes
ProtectKernelModules=yes
--
2.36.1

@ -0,0 +1,31 @@
From 338d5f2876c54e5d811100ba816d3a6dec00ab11 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Fri, 29 Apr 2022 10:11:49 +0200
Subject: lsirq: improve --sort IRQ
IRQ column mixes numbers and text, it seems better to use strverscmp()
rather than classic strcmp().
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2078787
Upstream: http://github.com/util-linux/util-linux/commit/d382861c0815ff241fb2844a2a896f0fb1c7b73e
Signed-off-by: Karel Zak <kzak@redhat.com>
---
sys-utils/irq-common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sys-utils/irq-common.c b/sys-utils/irq-common.c
index 350675394..22080b96d 100644
--- a/sys-utils/irq-common.c
+++ b/sys-utils/irq-common.c
@@ -371,7 +371,7 @@ static inline int cmp_delta(const struct irq_info *a,
static inline int cmp_interrupts(const struct irq_info *a,
const struct irq_info *b)
{
- return (strcmp(a->irq, b->irq) > 0) ? 1 : 0;
+ return (strverscmp(a->irq, b->irq) > 0) ? 1 : 0;
}
static void sort_result(struct irq_output *out,
--
2.36.1

@ -0,0 +1,28 @@
From de0402358f6d363a57e6fef98c92a9eef5690cdd Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 6 Jun 2022 16:14:30 +0200
Subject: irqtop: fix compiler warning [-Werror=format-truncation=]
Upstream: http://github.com/util-linux/util-linux/commit/b7865ae165bb43b1626c6928250843cc2c96be57
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2078787
Signed-off-by: Karel Zak <kzak@redhat.com>
---
sys-utils/irq-common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sys-utils/irq-common.c b/sys-utils/irq-common.c
index 22080b96d..e39ef823c 100644
--- a/sys-utils/irq-common.c
+++ b/sys-utils/irq-common.c
@@ -426,7 +426,7 @@ struct libscols_table *get_scols_cpus_table(struct irq_output *out,
struct libscols_table *table;
struct libscols_column *cl;
struct libscols_line *ln;
- char colname[sizeof(stringify_value(LONG_MAX))];
+ char colname[sizeof("cpu") + sizeof(stringify_value(LONG_MAX))];
size_t i;
if (prev) {
--
2.36.1

@ -0,0 +1,34 @@
From f45fe0768ac09cb5e05b095afa47a0a71e931f84 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Wed, 20 Apr 2022 14:42:32 +0200
Subject: dmesg: fix --since and --until
Now --since and --until requires any time field in the output (e.g.
--ctime,-T), it means "dmesg --since '1 day ago'" doesn't work, but
"dmesg -T --since '1 day ago'" works as expected.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2076829
Upstream: http://github.com/util-linux/util-linux/commit/c9667633f1f6b7a84116f2af067d1d15c72e6382
Signed-off-by: Karel Zak <kzak@redhat.com>
---
sys-utils/dmesg.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c
index d301951bb..5c580107a 100644
--- a/sys-utils/dmesg.c
+++ b/sys-utils/dmesg.c
@@ -1539,7 +1539,9 @@ int main(int argc, char *argv[])
if ((is_timefmt(&ctl, RELTIME) ||
is_timefmt(&ctl, CTIME) ||
- is_timefmt(&ctl, ISO8601))) {
+ is_timefmt(&ctl, ISO8601)) ||
+ ctl.since ||
+ ctl.until) {
if (dmesg_get_boot_time(&ctl.boot_time) != 0)
ctl.time_fmt = DMESG_TIMEFTM_NONE;
else
--
2.36.1

@ -0,0 +1,62 @@
From f02e9004303df5ab3d9b868f6f60af44663cce69 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 19 Apr 2022 09:44:07 +0200
Subject: libblkid: check fsync() return code
Since 39f5af25982d8b0244000e92a9d0e0e6557d0e17 libblkid uses
O_NONBLOCK. Now it's more obvious that check fsync() (and close())
return value after write() is always a good idea ...
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2074486
Upstream: http://github.com/util-linux/util-linux/commit/133a0d70f637b4f4e4337811e452153b04f2bdcf
Signed-off-by: Karel Zak <kzak@redhat.com>
---
libblkid/src/probe.c | 5 ++++-
misc-utils/wipefs.c | 8 ++++++--
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/libblkid/src/probe.c b/libblkid/src/probe.c
index 5f01bc3b3..d317dc19a 100644
--- a/libblkid/src/probe.c
+++ b/libblkid/src/probe.c
@@ -1298,7 +1298,10 @@ int blkid_do_wipe(blkid_probe pr, int dryrun)
/* wipen on device */
if (write_all(fd, buf, len))
return -1;
- fsync(fd);
+
+ if (fsync(fd) != 0)
+ return -1;
+
pr->flags &= ~BLKID_FL_MODIF_BUFF; /* be paranoid */
return blkid_probe_step_back(pr);
diff --git a/misc-utils/wipefs.c b/misc-utils/wipefs.c
index 78dc63ee7..f08a9ba4f 100644
--- a/misc-utils/wipefs.c
+++ b/misc-utils/wipefs.c
@@ -615,7 +615,9 @@ static int do_wipe(struct wipe_control *ctl)
if (need_force)
warnx(_("Use the --force option to force erase."));
- fsync(blkid_probe_get_fd(pr));
+ if (fsync(blkid_probe_get_fd(pr)) != 0)
+ err(EXIT_FAILURE, _("%s: cannot flush modified buffers"),
+ ctl->devname);
#ifdef BLKRRPART
if (reread && (mode & O_EXCL)) {
@@ -635,7 +637,9 @@ static int do_wipe(struct wipe_control *ctl)
}
#endif
- close(blkid_probe_get_fd(pr));
+ if (close(blkid_probe_get_fd(pr)) != 0)
+ err(EXIT_FAILURE, _("%s: close device failed"), ctl->devname);
+
blkid_free_probe(pr);
free(backup);
return 0;
--
2.36.1

@ -0,0 +1,87 @@
From 863ecca27cfc937bc6fb2131e0d0e35947e38ce6 Mon Sep 17 00:00:00 2001
From: Andrey Albershteyn <aalbersh@redhat.com>
Date: Mon, 25 Apr 2022 17:08:37 +0200
Subject: libblkid: add interface for FSSIZE field
Add interface to let filesystem probe calculate and set FSSIZE.
Enable that field in the 'superblocks' sample.
Upstream: http://github.com/util-linux/util-linux/commit/ad08ae0aa
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2064810
Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
---
libblkid/samples/superblocks.c | 2 +-
libblkid/src/blkid.h.in | 1 +
libblkid/src/superblocks/superblocks.c | 11 +++++++++++
libblkid/src/superblocks/superblocks.h | 1 +
4 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/libblkid/samples/superblocks.c b/libblkid/samples/superblocks.c
index 7d9555771..38903ecee 100644
--- a/libblkid/samples/superblocks.c
+++ b/libblkid/samples/superblocks.c
@@ -44,7 +44,7 @@ int main(int argc, char *argv[])
BLKID_SUBLKS_UUID | BLKID_SUBLKS_UUIDRAW |
BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE |
BLKID_SUBLKS_USAGE | BLKID_SUBLKS_VERSION |
- BLKID_SUBLKS_MAGIC);
+ BLKID_SUBLKS_MAGIC | BLKID_SUBLKS_FSSIZE);
rc = blkid_do_safeprobe(pr);
if (rc == -1)
diff --git a/libblkid/src/blkid.h.in b/libblkid/src/blkid.h.in
index 3cd4116d9..ad4becf0a 100644
--- a/libblkid/src/blkid.h.in
+++ b/libblkid/src/blkid.h.in
@@ -281,6 +281,7 @@ extern int blkid_probe_enable_superblocks(blkid_probe pr, int enable)
#define BLKID_SUBLKS_VERSION (1 << 8) /* read FS type from superblock */
#define BLKID_SUBLKS_MAGIC (1 << 9) /* define SBMAGIC and SBMAGIC_OFFSET */
#define BLKID_SUBLKS_BADCSUM (1 << 10) /* allow a bad checksum */
+#define BLKID_SUBLKS_FSSIZE (1 << 11) /* read and define FSSIZE from superblock */
#define BLKID_SUBLKS_DEFAULT (BLKID_SUBLKS_LABEL | BLKID_SUBLKS_UUID | \
BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE)
diff --git a/libblkid/src/superblocks/superblocks.c b/libblkid/src/superblocks/superblocks.c
index f21365538..9adc2cfa3 100644
--- a/libblkid/src/superblocks/superblocks.c
+++ b/libblkid/src/superblocks/superblocks.c
@@ -7,6 +7,7 @@
* GNU Lesser General Public License.
*/
+#include <inttypes.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -584,6 +585,16 @@ static int blkid_probe_set_usage(blkid_probe pr, int usage)
return blkid_probe_set_value(pr, "USAGE", (unsigned char *) u, strlen(u) + 1);
}
+int blkid_probe_set_fssize(blkid_probe pr, uint64_t size)
+{
+ struct blkid_chain *chn = blkid_probe_get_chain(pr);
+
+ if (!(chn->flags & BLKID_SUBLKS_FSSIZE))
+ return 0;
+
+ return blkid_probe_sprintf_value(pr, "FSSIZE", "%" PRIu64, size);
+}
+
int blkid_probe_set_id_label(blkid_probe pr, const char *name,
const unsigned char *data, size_t len)
{
diff --git a/libblkid/src/superblocks/superblocks.h b/libblkid/src/superblocks/superblocks.h
index 9c489c438..67803679f 100644
--- a/libblkid/src/superblocks/superblocks.h
+++ b/libblkid/src/superblocks/superblocks.h
@@ -111,6 +111,7 @@ extern int blkid_probe_set_utf8_id_label(blkid_probe pr, const char *name,
const unsigned char *data, size_t len, int enc);
int blkid_probe_set_block_size(blkid_probe pr, unsigned block_size);
+int blkid_probe_set_fssize(blkid_probe pr, uint64_t size);
extern int blkid_probe_is_bitlocker(blkid_probe pr);
extern int blkid_probe_is_ntfs(blkid_probe pr);
--
2.36.1

@ -0,0 +1,45 @@
From e81cc68312e91ab7086188542f3377605bf144a8 Mon Sep 17 00:00:00 2001
From: Andrey Albershteyn <aalbersh@redhat.com>
Date: Mon, 25 Apr 2022 17:08:38 +0200
Subject: libblkid: implement FSSIZE calculation for XFS
The implementation is similar to one provided by statfs(2) + lsblk.
Upstream: http://github.com/util-linux/util-linux/commit/d7ec8fe8e
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2064810
Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
---
libblkid/src/superblocks/xfs.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/libblkid/src/superblocks/xfs.c b/libblkid/src/superblocks/xfs.c
index d8c6fb6d4..444050f55 100644
--- a/libblkid/src/superblocks/xfs.c
+++ b/libblkid/src/superblocks/xfs.c
@@ -158,6 +158,15 @@ static int xfs_verify_sb(struct xfs_super_block *ondisk)
return 1;
}
+static uint64_t xfs_fssize(struct xfs_super_block *xs)
+{
+ uint32_t lsize = xs->sb_logstart ? xs->sb_logblocks : 0;
+ uint64_t avail_blocks = be64_to_cpu(xs->sb_dblocks) - be32_to_cpu(lsize);
+ uint64_t fssize = avail_blocks*be32_to_cpu(xs->sb_blocksize);
+
+ return fssize;
+}
+
static int probe_xfs(blkid_probe pr, const struct blkid_idmag *mag)
{
struct xfs_super_block *xs;
@@ -173,6 +182,7 @@ static int probe_xfs(blkid_probe pr, const struct blkid_idmag *mag)
blkid_probe_set_label(pr, (unsigned char *) xs->sb_fname,
sizeof(xs->sb_fname));
blkid_probe_set_uuid(pr, xs->sb_uuid);
+ blkid_probe_set_fssize(pr, xfs_fssize(xs));
blkid_probe_set_block_size(pr, be16_to_cpu(xs->sb_sectsize));
return 0;
}
--
2.36.1

@ -0,0 +1,54 @@
From d3d0e6dc70889e5fe9d9dfeab67e9ba1f0491a28 Mon Sep 17 00:00:00 2001
From: Andrey Albershteyn <aalbersh@redhat.com>
Date: Mon, 25 Apr 2022 17:08:39 +0200
Subject: blkid: add FSSIZE tag with tests for XFS
The FSSIZE tag was added to the libblkid. Enable this tag in blkid
and update tests golden output for XFS test cases.
Upstream: http://github.com/util-linux/util-linux/commit/60cedc921
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2064810
Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
---
misc-utils/blkid.c | 3 ++-
tests/expected/blkid/low-probe-xfs | 1 +
tests/expected/blkid/low-probe-xfs-v5 | 1 +
3 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/misc-utils/blkid.c b/misc-utils/blkid.c
index cccd8af87..4f456be52 100644
--- a/misc-utils/blkid.c
+++ b/misc-utils/blkid.c
@@ -892,7 +892,8 @@ int main(int argc, char **argv)
blkid_probe_set_superblocks_flags(pr,
BLKID_SUBLKS_LABEL | BLKID_SUBLKS_UUID |
BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE |
- BLKID_SUBLKS_USAGE | BLKID_SUBLKS_VERSION);
+ BLKID_SUBLKS_USAGE | BLKID_SUBLKS_VERSION |
+ BLKID_SUBLKS_FSSIZE);
if (fltr_usage &&
diff --git a/tests/expected/blkid/low-probe-xfs b/tests/expected/blkid/low-probe-xfs
index 6eb1b4600..a91e92bcc 100644
--- a/tests/expected/blkid/low-probe-xfs
+++ b/tests/expected/blkid/low-probe-xfs
@@ -1,4 +1,5 @@
ID_FS_BLOCK_SIZE=512
+ID_FS_FSSIZE=11862016
ID_FS_LABEL=test-xfs
ID_FS_LABEL_ENC=test-xfs
ID_FS_TYPE=xfs
diff --git a/tests/expected/blkid/low-probe-xfs-v5 b/tests/expected/blkid/low-probe-xfs-v5
index 513a3818f..129b41f26 100644
--- a/tests/expected/blkid/low-probe-xfs-v5
+++ b/tests/expected/blkid/low-probe-xfs-v5
@@ -1,4 +1,5 @@
ID_FS_BLOCK_SIZE=512
+ID_FS_FSSIZE=17469440
ID_FS_LABEL=test-xfs-v5
ID_FS_LABEL_ENC=test-xfs-v5
ID_FS_TYPE=xfs
--
2.36.1

@ -0,0 +1,28 @@
From 8ae64e23bc34fd939586705f64a93676bae8c2b2 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 26 Apr 2022 10:32:05 +0200
Subject: libblkid: fix FSSIZE docs
Upstream: http://github.com/util-linux/util-linux/commit/9c01f798f
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2064810
Signed-off-by: Karel Zak <kzak@redhat.com>
---
libblkid/src/superblocks/superblocks.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libblkid/src/superblocks/superblocks.c b/libblkid/src/superblocks/superblocks.c
index 9adc2cfa3..adf4ee025 100644
--- a/libblkid/src/superblocks/superblocks.c
+++ b/libblkid/src/superblocks/superblocks.c
@@ -66,7 +66,7 @@
*
* @SBMAGIC_OFFSET: offset of SBMAGIC
*
- * @FSSIZE: size of filesystem [not-implemented yet]
+ * @FSSIZE: size of filesystem (implemented for XFS only)
*
* @SYSTEM_ID: ISO9660 system identifier
*
--
2.36.1

@ -0,0 +1,113 @@
From fb9ea75a8a69b06eb6a4039b841ce3ccabb76775 Mon Sep 17 00:00:00 2001
From: Andrey Albershteyn <aalbersh@redhat.com>
Date: Wed, 27 Apr 2022 13:24:56 +0200
Subject: libblkid: add FSLASTBLOCK field interface showing area occupied by fs
Add interface to let filesystem set FSLASTBLOCK which is basically
total number of fsblocks (area occupied by fs). Enable that field in
the 'superblocks' sample.
Upstream: http://github.com/util-linux/util-linux/commit/b7cb26ec3
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2064810
Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
---
libblkid/samples/superblocks.c | 3 ++-
libblkid/src/blkid.h.in | 23 ++++++++++++-----------
libblkid/src/superblocks/superblocks.c | 13 +++++++++++++
libblkid/src/superblocks/superblocks.h | 1 +
4 files changed, 28 insertions(+), 12 deletions(-)
diff --git a/libblkid/samples/superblocks.c b/libblkid/samples/superblocks.c
index 38903ecee..b7f94ec14 100644
--- a/libblkid/samples/superblocks.c
+++ b/libblkid/samples/superblocks.c
@@ -44,7 +44,8 @@ int main(int argc, char *argv[])
BLKID_SUBLKS_UUID | BLKID_SUBLKS_UUIDRAW |
BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE |
BLKID_SUBLKS_USAGE | BLKID_SUBLKS_VERSION |
- BLKID_SUBLKS_MAGIC | BLKID_SUBLKS_FSSIZE);
+ BLKID_SUBLKS_MAGIC | BLKID_SUBLKS_FSSIZE |
+ BLKID_SUBLKS_FSLASTBLOCK);
rc = blkid_do_safeprobe(pr);
if (rc == -1)
diff --git a/libblkid/src/blkid.h.in b/libblkid/src/blkid.h.in
index ad4becf0a..56e64f9ab 100644
--- a/libblkid/src/blkid.h.in
+++ b/libblkid/src/blkid.h.in
@@ -271,17 +271,18 @@ extern int blkid_superblocks_get_name(size_t idx, const char **name, int *usage)
extern int blkid_probe_enable_superblocks(blkid_probe pr, int enable)
__ul_attribute__((nonnull));
-#define BLKID_SUBLKS_LABEL (1 << 1) /* read LABEL from superblock */
-#define BLKID_SUBLKS_LABELRAW (1 << 2) /* read and define LABEL_RAW result value*/
-#define BLKID_SUBLKS_UUID (1 << 3) /* read UUID from superblock */
-#define BLKID_SUBLKS_UUIDRAW (1 << 4) /* read and define UUID_RAW result value */
-#define BLKID_SUBLKS_TYPE (1 << 5) /* define TYPE result value */
-#define BLKID_SUBLKS_SECTYPE (1 << 6) /* define compatible fs type (second type) */
-#define BLKID_SUBLKS_USAGE (1 << 7) /* define USAGE result value */
-#define BLKID_SUBLKS_VERSION (1 << 8) /* read FS type from superblock */
-#define BLKID_SUBLKS_MAGIC (1 << 9) /* define SBMAGIC and SBMAGIC_OFFSET */
-#define BLKID_SUBLKS_BADCSUM (1 << 10) /* allow a bad checksum */
-#define BLKID_SUBLKS_FSSIZE (1 << 11) /* read and define FSSIZE from superblock */
+#define BLKID_SUBLKS_LABEL (1 << 1) /* read LABEL from superblock */
+#define BLKID_SUBLKS_LABELRAW (1 << 2) /* read and define LABEL_RAW result value*/
+#define BLKID_SUBLKS_UUID (1 << 3) /* read UUID from superblock */
+#define BLKID_SUBLKS_UUIDRAW (1 << 4) /* read and define UUID_RAW result value */
+#define BLKID_SUBLKS_TYPE (1 << 5) /* define TYPE result value */
+#define BLKID_SUBLKS_SECTYPE (1 << 6) /* define compatible fs type (second type) */
+#define BLKID_SUBLKS_USAGE (1 << 7) /* define USAGE result value */
+#define BLKID_SUBLKS_VERSION (1 << 8) /* read FS type from superblock */
+#define BLKID_SUBLKS_MAGIC (1 << 9) /* define SBMAGIC and SBMAGIC_OFFSET */
+#define BLKID_SUBLKS_BADCSUM (1 << 10) /* allow a bad checksum */
+#define BLKID_SUBLKS_FSSIZE (1 << 11) /* read and define FSSIZE from superblock */
+#define BLKID_SUBLKS_FSLASTBLOCK (1 << 12) /* read and define FSLASTBLOCK from superblock */
#define BLKID_SUBLKS_DEFAULT (BLKID_SUBLKS_LABEL | BLKID_SUBLKS_UUID | \
BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE)
diff --git a/libblkid/src/superblocks/superblocks.c b/libblkid/src/superblocks/superblocks.c
index adf4ee025..5b899a830 100644
--- a/libblkid/src/superblocks/superblocks.c
+++ b/libblkid/src/superblocks/superblocks.c
@@ -68,6 +68,8 @@
*
* @FSSIZE: size of filesystem (implemented for XFS only)
*
+ * @FSLASTBLOCK: last fsblock/total number of fsblocks
+ *
* @SYSTEM_ID: ISO9660 system identifier
*
* @PUBLISHER_ID: ISO9660 publisher identifier
@@ -595,6 +597,17 @@ int blkid_probe_set_fssize(blkid_probe pr, uint64_t size)
return blkid_probe_sprintf_value(pr, "FSSIZE", "%" PRIu64, size);
}
+int blkid_probe_set_fslastblock(blkid_probe pr, uint64_t lastblock)
+{
+ struct blkid_chain *chn = blkid_probe_get_chain(pr);
+
+ if (!(chn->flags & BLKID_SUBLKS_FSLASTBLOCK))
+ return 0;
+
+ return blkid_probe_sprintf_value(pr, "FSLASTBLOCK", "%" PRIu64,
+ lastblock);
+}
+
int blkid_probe_set_id_label(blkid_probe pr, const char *name,
const unsigned char *data, size_t len)
{
diff --git a/libblkid/src/superblocks/superblocks.h b/libblkid/src/superblocks/superblocks.h
index 67803679f..251e2e386 100644
--- a/libblkid/src/superblocks/superblocks.h
+++ b/libblkid/src/superblocks/superblocks.h
@@ -112,6 +112,7 @@ extern int blkid_probe_set_utf8_id_label(blkid_probe pr, const char *name,
int blkid_probe_set_block_size(blkid_probe pr, unsigned block_size);
int blkid_probe_set_fssize(blkid_probe pr, uint64_t size);
+int blkid_probe_set_fslastblock(blkid_probe pr, uint64_t lastblock);
extern int blkid_probe_is_bitlocker(blkid_probe pr);
extern int blkid_probe_is_ntfs(blkid_probe pr);
--
2.36.1

@ -0,0 +1,86 @@
From 9c7f3317fc66fe971a331dd71e76aff7ae091ab2 Mon Sep 17 00:00:00 2001
From: Andrey Albershteyn <aalbersh@redhat.com>
Date: Wed, 27 Apr 2022 14:46:33 +0200
Subject: libblkid: add FSLASTBLOCK implementation for xfs, ext and btrfs
Implementation of FSLASTBLOCK for most common filesystems. Most of
the fs store total number of reserved blocks in superblock.
Upstream: http://github.com/util-linux/util-linux/commit/5f995b3f1
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2064810
Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
---
libblkid/src/superblocks/btrfs.c | 5 +++++
libblkid/src/superblocks/ext.c | 10 ++++++++--
libblkid/src/superblocks/xfs.c | 1 +
3 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/libblkid/src/superblocks/btrfs.c b/libblkid/src/superblocks/btrfs.c
index f0fde700d..9708f2e28 100644
--- a/libblkid/src/superblocks/btrfs.c
+++ b/libblkid/src/superblocks/btrfs.c
@@ -76,6 +76,11 @@ static int probe_btrfs(blkid_probe pr, const struct blkid_idmag *mag)
blkid_probe_set_uuid_as(pr, bfs->dev_item.uuid, "UUID_SUB");
blkid_probe_set_block_size(pr, le32_to_cpu(bfs->sectorsize));
+ uint32_t sectorsize_log = 31 -
+ __builtin_clz(le32_to_cpu(bfs->sectorsize));
+ blkid_probe_set_fslastblock(pr,
+ le64_to_cpu(bfs->total_bytes) >> sectorsize_log);
+
return 0;
}
diff --git a/libblkid/src/superblocks/ext.c b/libblkid/src/superblocks/ext.c
index 3870522fa..0b9023734 100644
--- a/libblkid/src/superblocks/ext.c
+++ b/libblkid/src/superblocks/ext.c
@@ -164,10 +164,11 @@ static struct ext2_super_block *ext_get_super(
static void ext_get_info(blkid_probe pr, int ver, struct ext2_super_block *es)
{
struct blkid_chain *chn = blkid_probe_get_chain(pr);
+ uint32_t s_feature_incompat = le32_to_cpu(es->s_feature_incompat);
DBG(PROBE, ul_debug("ext2_sb.compat = %08X:%08X:%08X",
le32_to_cpu(es->s_feature_compat),
- le32_to_cpu(es->s_feature_incompat),
+ s_feature_incompat,
le32_to_cpu(es->s_feature_ro_compat)));
if (*es->s_volume_name != '\0')
@@ -179,7 +180,7 @@ static void ext_get_info(blkid_probe pr, int ver, struct ext2_super_block *es)
blkid_probe_set_uuid_as(pr, es->s_journal_uuid, "EXT_JOURNAL");
if (ver != 2 && (chn->flags & BLKID_SUBLKS_SECTYPE) &&
- ((le32_to_cpu(es->s_feature_incompat) & EXT2_FEATURE_INCOMPAT_UNSUPPORTED) == 0))
+ ((s_feature_incompat & EXT2_FEATURE_INCOMPAT_UNSUPPORTED) == 0))
blkid_probe_set_value(pr, "SEC_TYPE",
(unsigned char *) "ext2",
sizeof("ext2"));
@@ -190,6 +191,11 @@ static void ext_get_info(blkid_probe pr, int ver, struct ext2_super_block *es)
if (le32_to_cpu(es->s_log_block_size) < 32)
blkid_probe_set_block_size(pr, 1024U << le32_to_cpu(es->s_log_block_size));
+
+ uint64_t fslastblock = le32_to_cpu(es->s_blocks_count) |
+ ((s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT) ?
+ (uint64_t) le32_to_cpu(es->s_blocks_count_hi) << 32 : 0);
+ blkid_probe_set_fslastblock(pr, fslastblock);
}
diff --git a/libblkid/src/superblocks/xfs.c b/libblkid/src/superblocks/xfs.c
index 444050f55..1f2e92cac 100644
--- a/libblkid/src/superblocks/xfs.c
+++ b/libblkid/src/superblocks/xfs.c
@@ -183,6 +183,7 @@ static int probe_xfs(blkid_probe pr, const struct blkid_idmag *mag)
sizeof(xs->sb_fname));
blkid_probe_set_uuid(pr, xs->sb_uuid);
blkid_probe_set_fssize(pr, xfs_fssize(xs));
+ blkid_probe_set_fslastblock(pr, be64_to_cpu(xs->sb_dblocks));
blkid_probe_set_block_size(pr, be16_to_cpu(xs->sb_sectsize));
return 0;
}
--
2.36.1

@ -0,0 +1,146 @@
From ab34732c0aaf7814393acbffa59cb82a79583e3d Mon Sep 17 00:00:00 2001
From: Andrey Albershteyn <aalbersh@redhat.com>
Date: Wed, 27 Apr 2022 17:29:27 +0200
Subject: blkid: add image for btrfs testing
The btrfs is one of the popular filesystem which is supported by
blkid. However, the image for 'low-probe' tests was missing. Add
115M BTRFS default image (mkfs.btrfs btrfs.img).
Upstream: http://github.com/util-linux/util-linux/commit/bf64c83ec
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2064810
Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
---
tests/expected/blkid/low-probe-btrfs | 7 +++++++
tests/ts/blkid/images-fs/btrfs.img.xz | Bin 0 -> 21696 bytes
2 files changed, 7 insertions(+)
create mode 100644 tests/expected/blkid/low-probe-btrfs
create mode 100644 tests/ts/blkid/images-fs/btrfs.img.xz
diff --git a/tests/expected/blkid/low-probe-btrfs b/tests/expected/blkid/low-probe-btrfs
new file mode 100644
index 000000000..509fac378
--- /dev/null
+++ b/tests/expected/blkid/low-probe-btrfs
@@ -0,0 +1,7 @@
+ID_FS_BLOCK_SIZE=4096
+ID_FS_TYPE=btrfs
+ID_FS_USAGE=filesystem
+ID_FS_UUID=d4a78b72-55e4-4811-86a6-09af936d43f9
+ID_FS_UUID_ENC=d4a78b72-55e4-4811-86a6-09af936d43f9
+ID_FS_UUID_SUB=1e7603cb-d0be-4d8f-8972-9dddf7d5543c
+ID_FS_UUID_SUB_ENC=1e7603cb-d0be-4d8f-8972-9dddf7d5543c
diff --git a/tests/ts/blkid/images-fs/btrfs.img.xz b/tests/ts/blkid/images-fs/btrfs.img.xz
new file mode 100644
index 0000000000000000000000000000000000000000..418833d42078492f0266d73b22170d5626b80cc0
GIT binary patch
literal 21696
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
literal 0
HcmV?d00001
--
2.36.1

@ -0,0 +1,94 @@
From 96a699563b65b6a9204f2c3184faf1366155a614 Mon Sep 17 00:00:00 2001
From: Andrey Albershteyn <aalbersh@redhat.com>
Date: Wed, 27 Apr 2022 17:33:33 +0200
Subject: blkid: add tests for FSLASTBLOCK tag
Upstream: http://github.com/util-linux/util-linux/commit/800ed56f4
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2064810
Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
---
misc-utils/blkid.c | 2 +-
tests/expected/blkid/low-probe-btrfs | 1 +
tests/expected/blkid/low-probe-ext2 | 1 +
tests/expected/blkid/low-probe-ext3 | 1 +
tests/expected/blkid/low-probe-jbd | 1 +
tests/expected/blkid/low-probe-xfs | 1 +
tests/expected/blkid/low-probe-xfs-v5 | 1 +
7 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/misc-utils/blkid.c b/misc-utils/blkid.c
index 4f456be52..f2b190ce3 100644
--- a/misc-utils/blkid.c
+++ b/misc-utils/blkid.c
@@ -893,7 +893,7 @@ int main(int argc, char **argv)
BLKID_SUBLKS_LABEL | BLKID_SUBLKS_UUID |
BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE |
BLKID_SUBLKS_USAGE | BLKID_SUBLKS_VERSION |
- BLKID_SUBLKS_FSSIZE);
+ BLKID_SUBLKS_FSSIZE | BLKID_SUBLKS_FSLASTBLOCK);
if (fltr_usage &&
diff --git a/tests/expected/blkid/low-probe-btrfs b/tests/expected/blkid/low-probe-btrfs
index 509fac378..48649389a 100644
--- a/tests/expected/blkid/low-probe-btrfs
+++ b/tests/expected/blkid/low-probe-btrfs
@@ -1,4 +1,5 @@
ID_FS_BLOCK_SIZE=4096
+ID_FS_FSLASTBLOCK=29440
ID_FS_TYPE=btrfs
ID_FS_USAGE=filesystem
ID_FS_UUID=d4a78b72-55e4-4811-86a6-09af936d43f9
diff --git a/tests/expected/blkid/low-probe-ext2 b/tests/expected/blkid/low-probe-ext2
index 087da97a4..e236c6e8a 100644
--- a/tests/expected/blkid/low-probe-ext2
+++ b/tests/expected/blkid/low-probe-ext2
@@ -1,4 +1,5 @@
ID_FS_BLOCK_SIZE=1024
+ID_FS_FSLASTBLOCK=100
ID_FS_LABEL=test-ext2
ID_FS_LABEL_ENC=test-ext2
ID_FS_TYPE=ext2
diff --git a/tests/expected/blkid/low-probe-ext3 b/tests/expected/blkid/low-probe-ext3
index 8684884c1..164fefb7b 100644
--- a/tests/expected/blkid/low-probe-ext3
+++ b/tests/expected/blkid/low-probe-ext3
@@ -1,4 +1,5 @@
ID_FS_BLOCK_SIZE=1024
+ID_FS_FSLASTBLOCK=2048
ID_FS_LABEL=test-ext3
ID_FS_LABEL_ENC=test-ext3
ID_FS_SEC_TYPE=ext2
diff --git a/tests/expected/blkid/low-probe-jbd b/tests/expected/blkid/low-probe-jbd
index c9f9f6b79..f5462a2a3 100644
--- a/tests/expected/blkid/low-probe-jbd
+++ b/tests/expected/blkid/low-probe-jbd
@@ -1,4 +1,5 @@
ID_FS_BLOCK_SIZE=1024
+ID_FS_FSLASTBLOCK=1024
ID_FS_LOGUUID=0d7a07df-7b06-4829-bce7-3b9c3ece570c
ID_FS_TYPE=jbd
ID_FS_USAGE=other
diff --git a/tests/expected/blkid/low-probe-xfs b/tests/expected/blkid/low-probe-xfs
index a91e92bcc..be9c4194a 100644
--- a/tests/expected/blkid/low-probe-xfs
+++ b/tests/expected/blkid/low-probe-xfs
@@ -1,4 +1,5 @@
ID_FS_BLOCK_SIZE=512
+ID_FS_FSLASTBLOCK=4096
ID_FS_FSSIZE=11862016
ID_FS_LABEL=test-xfs
ID_FS_LABEL_ENC=test-xfs
diff --git a/tests/expected/blkid/low-probe-xfs-v5 b/tests/expected/blkid/low-probe-xfs-v5
index 129b41f26..fd2cba933 100644
--- a/tests/expected/blkid/low-probe-xfs-v5
+++ b/tests/expected/blkid/low-probe-xfs-v5
@@ -1,4 +1,5 @@
ID_FS_BLOCK_SIZE=512
+ID_FS_FSLASTBLOCK=5120
ID_FS_FSSIZE=17469440
ID_FS_LABEL=test-xfs-v5
ID_FS_LABEL_ENC=test-xfs-v5
--
2.36.1

@ -0,0 +1,120 @@
From f58a63a3d88cccd5fdf53ead425c5e8186f32cc1 Mon Sep 17 00:00:00 2001
From: Andrey Albershteyn <aalbersh@redhat.com>
Date: Mon, 2 May 2022 17:08:33 +0200
Subject: libblkid: merge FS* flags into one FSINFO
Put BLOCK_SIZE, FSSIZE and FSLASTBLOCK tags under one FSINFO flag.
These, and probably future ones, are read directly from the
superblock (with minor post-processing). These properties are
combined under one flag to escape adding a flag per superblock
member.
Upstream: http://github.com/util-linux/util-linux/commit/c9b2297eb
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2064810
Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
---
libblkid/samples/superblocks.c | 3 +--
libblkid/src/blkid.h.in | 23 +++++++++++------------
libblkid/src/superblocks/superblocks.c | 9 +++++++--
misc-utils/blkid.c | 3 +--
4 files changed, 20 insertions(+), 18 deletions(-)
diff --git a/libblkid/samples/superblocks.c b/libblkid/samples/superblocks.c
index b7f94ec14..5253f9cc4 100644
--- a/libblkid/samples/superblocks.c
+++ b/libblkid/samples/superblocks.c
@@ -44,8 +44,7 @@ int main(int argc, char *argv[])
BLKID_SUBLKS_UUID | BLKID_SUBLKS_UUIDRAW |
BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE |
BLKID_SUBLKS_USAGE | BLKID_SUBLKS_VERSION |
- BLKID_SUBLKS_MAGIC | BLKID_SUBLKS_FSSIZE |
- BLKID_SUBLKS_FSLASTBLOCK);
+ BLKID_SUBLKS_MAGIC | BLKID_SUBLKS_FSINFO);
rc = blkid_do_safeprobe(pr);
if (rc == -1)
diff --git a/libblkid/src/blkid.h.in b/libblkid/src/blkid.h.in
index 56e64f9ab..ae4e555e3 100644
--- a/libblkid/src/blkid.h.in
+++ b/libblkid/src/blkid.h.in
@@ -271,18 +271,17 @@ extern int blkid_superblocks_get_name(size_t idx, const char **name, int *usage)
extern int blkid_probe_enable_superblocks(blkid_probe pr, int enable)
__ul_attribute__((nonnull));
-#define BLKID_SUBLKS_LABEL (1 << 1) /* read LABEL from superblock */
-#define BLKID_SUBLKS_LABELRAW (1 << 2) /* read and define LABEL_RAW result value*/
-#define BLKID_SUBLKS_UUID (1 << 3) /* read UUID from superblock */
-#define BLKID_SUBLKS_UUIDRAW (1 << 4) /* read and define UUID_RAW result value */
-#define BLKID_SUBLKS_TYPE (1 << 5) /* define TYPE result value */
-#define BLKID_SUBLKS_SECTYPE (1 << 6) /* define compatible fs type (second type) */
-#define BLKID_SUBLKS_USAGE (1 << 7) /* define USAGE result value */
-#define BLKID_SUBLKS_VERSION (1 << 8) /* read FS type from superblock */
-#define BLKID_SUBLKS_MAGIC (1 << 9) /* define SBMAGIC and SBMAGIC_OFFSET */
-#define BLKID_SUBLKS_BADCSUM (1 << 10) /* allow a bad checksum */
-#define BLKID_SUBLKS_FSSIZE (1 << 11) /* read and define FSSIZE from superblock */
-#define BLKID_SUBLKS_FSLASTBLOCK (1 << 12) /* read and define FSLASTBLOCK from superblock */
+#define BLKID_SUBLKS_LABEL (1 << 1) /* read LABEL from superblock */
+#define BLKID_SUBLKS_LABELRAW (1 << 2) /* read and define LABEL_RAW result value*/
+#define BLKID_SUBLKS_UUID (1 << 3) /* read UUID from superblock */
+#define BLKID_SUBLKS_UUIDRAW (1 << 4) /* read and define UUID_RAW result value */
+#define BLKID_SUBLKS_TYPE (1 << 5) /* define TYPE result value */
+#define BLKID_SUBLKS_SECTYPE (1 << 6) /* define compatible fs type (second type) */
+#define BLKID_SUBLKS_USAGE (1 << 7) /* define USAGE result value */
+#define BLKID_SUBLKS_VERSION (1 << 8) /* read FS type from superblock */
+#define BLKID_SUBLKS_MAGIC (1 << 9) /* define SBMAGIC and SBMAGIC_OFFSET */
+#define BLKID_SUBLKS_BADCSUM (1 << 10) /* allow a bad checksum */
+#define BLKID_SUBLKS_FSINFO (1 << 11) /* read and define fs properties from superblock */
#define BLKID_SUBLKS_DEFAULT (BLKID_SUBLKS_LABEL | BLKID_SUBLKS_UUID | \
BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE)
diff --git a/libblkid/src/superblocks/superblocks.c b/libblkid/src/superblocks/superblocks.c
index 5b899a830..a1f42c611 100644
--- a/libblkid/src/superblocks/superblocks.c
+++ b/libblkid/src/superblocks/superblocks.c
@@ -562,6 +562,11 @@ int blkid_probe_sprintf_version(blkid_probe pr, const char *fmt, ...)
int blkid_probe_set_block_size(blkid_probe pr, unsigned block_size)
{
+ struct blkid_chain *chn = blkid_probe_get_chain(pr);
+
+ if (!(chn->flags & BLKID_SUBLKS_FSINFO))
+ return 0;
+
return blkid_probe_sprintf_value(pr, "BLOCK_SIZE", "%u", block_size);
}
@@ -591,7 +596,7 @@ int blkid_probe_set_fssize(blkid_probe pr, uint64_t size)
{
struct blkid_chain *chn = blkid_probe_get_chain(pr);
- if (!(chn->flags & BLKID_SUBLKS_FSSIZE))
+ if (!(chn->flags & BLKID_SUBLKS_FSINFO))
return 0;
return blkid_probe_sprintf_value(pr, "FSSIZE", "%" PRIu64, size);
@@ -601,7 +606,7 @@ int blkid_probe_set_fslastblock(blkid_probe pr, uint64_t lastblock)
{
struct blkid_chain *chn = blkid_probe_get_chain(pr);
- if (!(chn->flags & BLKID_SUBLKS_FSLASTBLOCK))
+ if (!(chn->flags & BLKID_SUBLKS_FSINFO))
return 0;
return blkid_probe_sprintf_value(pr, "FSLASTBLOCK", "%" PRIu64,
diff --git a/misc-utils/blkid.c b/misc-utils/blkid.c
index f2b190ce3..744151616 100644
--- a/misc-utils/blkid.c
+++ b/misc-utils/blkid.c
@@ -893,8 +893,7 @@ int main(int argc, char **argv)
BLKID_SUBLKS_LABEL | BLKID_SUBLKS_UUID |
BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE |
BLKID_SUBLKS_USAGE | BLKID_SUBLKS_VERSION |
- BLKID_SUBLKS_FSSIZE | BLKID_SUBLKS_FSLASTBLOCK);
-
+ BLKID_SUBLKS_FSINFO);
if (fltr_usage &&
blkid_probe_filter_superblocks_usage(pr, fltr_flag, fltr_usage))
--
2.36.1

File diff suppressed because it is too large Load Diff

@ -0,0 +1,32 @@
From 5300d69be2919d0a50968377d23807831fdf3f71 Mon Sep 17 00:00:00 2001
From: Andrey Albershteyn <aalbersh@redhat.com>
Date: Fri, 27 May 2022 12:56:27 +0200
Subject: libblkid: update documentation of BLOCK_SIZE tag
The name BLOCK_SIZE is unfortunate. This tag doesn't represent
commonly used file system block size but minimal block size
accessible by file system (sector size).
Upstream: http://github.com/util-linux/util-linux/commit/895f0b609
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2064810
Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
---
libblkid/src/superblocks/superblocks.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libblkid/src/superblocks/superblocks.c b/libblkid/src/superblocks/superblocks.c
index 9cfa991fc..9c32bc9d5 100644
--- a/libblkid/src/superblocks/superblocks.c
+++ b/libblkid/src/superblocks/superblocks.c
@@ -80,7 +80,7 @@
*
* @BOOT_SYSTEM_ID: ISO9660 boot system identifier
*
- * @BLOCK_SIZE: block size
+ * @BLOCK_SIZE: minimal block size accessible by file system
*/
static int superblocks_probe(blkid_probe pr, struct blkid_chain *chn);
--
2.36.1

@ -0,0 +1,28 @@
From da3add097b70160cd2c6bab0a4acb699df07ebe8 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Thu, 17 Mar 2022 10:48:33 +0100
Subject: cfdisk: don't use NULL in printf [coverity scan]
Upstream: http://github.com/util-linux/util-linux/commit/30cc5f5751698cccb625193f715f1a606a7f91b4
Addresses: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=2109459
Signed-off-by: Karel Zak <kzak@redhat.com>
---
disk-utils/cfdisk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/disk-utils/cfdisk.c b/disk-utils/cfdisk.c
index c1b28889f..36eb3f8c6 100644
--- a/disk-utils/cfdisk.c
+++ b/disk-utils/cfdisk.c
@@ -2080,7 +2080,7 @@ done:
}
free(cm);
DBG(UI, ul_debug("get parrtype done [type=%s] ", t ?
- fdisk_parttype_get_name(t) : NULL));
+ fdisk_parttype_get_name(t) : ""));
return t;
}
--
2.36.1

@ -0,0 +1,28 @@
From cee4a7f69d853fcc574241d394edc5bcb91469a5 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 6 Jun 2022 16:19:16 +0200
Subject: zramctl: fix compiler warning [-Werror=maybe-uninitialized]
Upstream: http://github.com/util-linux/util-linux/commit/8883f037466a5534554d7d9114aceb740295ef20
Addresses: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=2109459
Signed-off-by: Karel Zak <kzak@redhat.com>
---
sys-utils/zramctl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sys-utils/zramctl.c b/sys-utils/zramctl.c
index 003349fad..64d5fcd81 100644
--- a/sys-utils/zramctl.c
+++ b/sys-utils/zramctl.c
@@ -291,7 +291,7 @@ static struct path_cxt *zram_get_control(void)
static int zram_control_add(struct zram *z)
{
- int n;
+ int n = 0;
struct path_cxt *ctl;
if (!zram_has_control(z) || !(ctl = zram_get_control()))
--
2.36.1

@ -0,0 +1,46 @@
From f6fffc1a89e57b7d5dd4adf1ee6b2146e58ec411 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Thu, 17 Mar 2022 12:18:03 +0100
Subject: lib/path: make ul_path_read_buffer() more robust [coverity scan]
Make sure we never call buf[rc - 1] for rc=0.
Upstream: http://github.com/util-linux/util-linux/commit/ea459dcf95d0bb04c816b71d2b85fbcd8cfc5ee4
Addresses: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=2109459
Signed-off-by: Karel Zak <kzak@redhat.com>
---
lib/path.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/lib/path.c b/lib/path.c
index 21f9bd1c4..ab034e110 100644
--- a/lib/path.c
+++ b/lib/path.c
@@ -666,14 +666,17 @@ int ul_path_readf_string(struct path_cxt *pc, char **str, const char *path, ...)
int ul_path_read_buffer(struct path_cxt *pc, char *buf, size_t bufsz, const char *path)
{
int rc = ul_path_read(pc, buf, bufsz - 1, path);
- if (rc < 0)
- return rc;
- /* Remove tailing newline (usual in sysfs) */
- if (rc > 0 && *(buf + rc - 1) == '\n')
- buf[--rc] = '\0';
- else
- buf[rc - 1] = '\0';
+ if (rc == 0)
+ buf[0] = '\0';
+
+ else if (rc > 0) {
+ /* Remove tailing newline (usual in sysfs) */
+ if (*(buf + rc - 1) == '\n')
+ buf[--rc] = '\0';
+ else
+ buf[rc - 1] = '\0';
+ }
return rc;
}
--
2.36.1

@ -0,0 +1,27 @@
From 53af90a8edf2e60342b477d28e0d802dc26f18b7 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 9 Aug 2022 12:35:05 +0200
Subject: lslogins: improve for static analyzer
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2094216
Signed-off-by: Karel Zak <kzak@redhat.com>
---
login-utils/lslogins.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c
index ff4386d1b..56431212d 100644
--- a/login-utils/lslogins.c
+++ b/login-utils/lslogins.c
@@ -852,7 +852,7 @@ static struct lslogins_user *get_user_info(struct lslogins_control *ctl, const c
while (p && *p == '!')
p++, i++;
- if (i != 0 && (!*p || valid_pwd(p)))
+ if (i != 0 && p && (!*p || valid_pwd(p)))
user->pwd_lock = STATUS_TRUE;
} else
user->pwd_lock = STATUS_UNKNOWN;
--
2.37.1

@ -0,0 +1,48 @@
From 723438ad02928d9614439def99b36e0758f62d26 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Fri, 12 Aug 2022 08:30:49 +0200
Subject: tests: add udevadm settle to loop overlap test
Addresses: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=2117203
Signed-off-by: Karel Zak <kzak@redhat.com>
---
tests/ts/libmount/loop-overlay | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tests/ts/libmount/loop-overlay b/tests/ts/libmount/loop-overlay
index 62874a182..c27f60d0f 100755
--- a/tests/ts/libmount/loop-overlay
+++ b/tests/ts/libmount/loop-overlay
@@ -43,22 +43,29 @@ dd if="$IMG" of="$IMG" oflag=append bs=1024k count=5 conv=notrunc &>/dev/null
echo "second should fail" >>$TS_OUTPUT
$TS_CMD_MOUNT -oloop "$IMG" "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>> $TS_ERRLOG
+udevadm settle
$TS_CMD_MOUNT -oloop,offset=$OFFSET "$IMG" "$TS_MOUNTPOINT-2" 2>&1 \
| sed 's/:.*:/: <target>/; s/for .*/for <source>/' >> $TS_OUTPUT
$TS_CMD_UMOUNT "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>> $TS_ERRLOG
+udevadm settle
echo "should succeed" >>$TS_OUTPUT
$TS_CMD_MOUNT -oloop,sizelimit=$OFFSET "$IMG" "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>> $TS_ERRLOG
+udevadm settle
$TS_CMD_MOUNT -oloop,offset=$OFFSET "$IMG" "$TS_MOUNTPOINT-2" >> $TS_OUTPUT 2>> $TS_ERRLOG
+udevadm settle
$TS_CMD_UMOUNT "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>> $TS_ERRLOG
$TS_CMD_UMOUNT "$TS_MOUNTPOINT-2" >> $TS_OUTPUT 2>> $TS_ERRLOG
+udevadm settle
echo "both should fail" >>$TS_OUTPUT
LOOPDEV=$($TS_CMD_LOSETUP --show -f --offset 1 --sizelimit $OFFSET "$IMG")
+udevadm settle
$TS_CMD_MOUNT -oloop,sizelimit=$OFFSET "$IMG" "$TS_MOUNTPOINT-1" 2>&1 \
| sed 's/:.*:/: <target>/; s/for .*/for <source>/' >> $TS_OUTPUT
$TS_CMD_MOUNT -oloop,offset=$OFFSET "$IMG" "$TS_MOUNTPOINT-2" 2>&1 \
| sed 's/:.*:/: <target>/; s/for .*/for <source>/' >> $TS_OUTPUT
+udevadm settle
$TS_CMD_LOSETUP --detach $LOOPDEV
ts_log "Success"
--
2.37.2

@ -0,0 +1,161 @@
From a1dfd3c737f7dad832b0f6ec975bcc5c9cc80ffe Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Wed, 24 Aug 2022 12:20:25 +0200
Subject: lslogins: support more password methods
* detect more hashing methods
* don't care about hash size
* follow crypt(5) when check for valid chars
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2094216
Upstream: http://github.com/util-linux/util-linux/commit/2b9373e06243d5adf93d627916a5421b34a7e63f
Reported-by: Radka Skvarilova <rskvaril@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
---
login-utils/lslogins.c | 66 +++++++++++++++++++++++++++---------------
1 file changed, 42 insertions(+), 24 deletions(-)
diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c
index 56431212d..22e3cd23e 100644
--- a/login-utils/lslogins.c
+++ b/login-utils/lslogins.c
@@ -598,7 +598,7 @@ static int get_nprocs(const uid_t uid)
}
#endif
-static const char *get_pwd_method(const char *str, const char **next, unsigned int *sz)
+static const char *get_pwd_method(const char *str, const char **next)
{
const char *p = str;
const char *res = NULL;
@@ -606,32 +606,50 @@ static const char *get_pwd_method(const char *str, const char **next, unsigned i
if (!p || *p++ != '$')
return NULL;
- if (sz)
- *sz = 0;
-
switch (*p) {
case '1':
res = "MD5";
- if (sz)
- *sz = 22;
break;
case '2':
- p++;
- if (*p == 'a' || *p == 'y')
+ switch(*(p+1)) {
+ case 'a':
+ case 'y':
+ p++;
res = "Blowfish";
+ break;
+ case 'b':
+ p++;
+ res = "bcrypt";
+ break;
+ }
+ break;
+ case '3':
+ res = "NT";
break;
case '5':
res = "SHA-256";
- if (sz)
- *sz = 43;
break;
case '6':
res = "SHA-512";
- if (sz)
- *sz = 86;
+ break;
+ case '7':
+ res = "scrypt";
+ break;
+ case 'y':
+ res = "yescrypt";
+ break;
+ case 'g':
+ if (*(p + 1) == 'y') {
+ p++;
+ res = "gost-yescrypt";
+ }
+ break;
+ case '_':
+ res = "bsdicrypt";
break;
default:
- return NULL;
+ res = "unknown";
+ break;
}
p++;
@@ -642,7 +660,10 @@ static const char *get_pwd_method(const char *str, const char **next, unsigned i
return res;
}
-#define is_valid_pwd_char(x) (isalnum((unsigned char) (x)) || (x) == '.' || (x) == '/')
+#define is_invalid_pwd_char(x) (isspace((unsigned char) (x)) || \
+ (x) == ':' || (x) == ';' || (x) == '*' || \
+ (x) == '!' || (x) == '\\')
+#define is_valid_pwd_char(x) (isascii((unsigned char) (x)) && !is_invalid_pwd_char(x))
/*
* This function do not accept empty passwords or locked accouns.
@@ -650,17 +671,16 @@ static const char *get_pwd_method(const char *str, const char **next, unsigned i
static int valid_pwd(const char *str)
{
const char *p = str;
- unsigned int sz = 0, n;
if (!str || !*str)
return 0;
/* $id$ */
- if (get_pwd_method(str, &p, &sz) == NULL)
+ if (get_pwd_method(str, &p) == NULL)
return 0;
+
if (!p || !*p)
return 0;
-
/* salt$ */
for (; *p; p++) {
if (*p == '$') {
@@ -670,17 +690,15 @@ static int valid_pwd(const char *str)
if (!is_valid_pwd_char(*p))
return 0;
}
+
if (!*p)
return 0;
-
/* encrypted */
- for (n = 0; *p; p++, n++) {
- if (!is_valid_pwd_char(*p))
+ for (; *p; p++) {
+ if (!is_valid_pwd_char(*p)) {
return 0;
+ }
}
-
- if (sz && n != sz)
- return 0;
return 1;
}
@@ -863,7 +881,7 @@ static struct lslogins_user *get_user_info(struct lslogins_control *ctl, const c
while (p && (*p == '!' || *p == '*'))
p++;
- user->pwd_method = get_pwd_method(p, NULL, NULL);
+ user->pwd_method = get_pwd_method(p, NULL);
} else
user->pwd_method = NULL;
break;
--
2.37.2

@ -0,0 +1,93 @@
From 07ed253a49cbe80c15d43ed3800206f99d15b43e Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 4 Oct 2021 11:14:01 +0200
Subject: fstrim: don't trigger autofs
- ignore read-only entries
- ignore autofs entries (for example from /proc/self/mountinfo)
- ignore autofs mountpoints where automounter has not been triggered yet
Fixes: https://github.com/karelzak/util-linux/issues/1463
Signed-off-by: Karel Zak <kzak@redhat.com>
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2165981
---
sys-utils/fstrim.8.adoc | 2 +-
sys-utils/fstrim.c | 28 +++++++++++++++++++++++++++-
2 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/sys-utils/fstrim.8.adoc b/sys-utils/fstrim.8.adoc
index 66671c293..d2f3b05be 100644
--- a/sys-utils/fstrim.8.adoc
+++ b/sys-utils/fstrim.8.adoc
@@ -29,7 +29,7 @@ Running *fstrim* frequently, or even using *mount -o discard*, might negatively
The _offset_, _length_, and _minimum-size_ arguments may be followed by the multiplicative suffixes KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB (the "iB" is optional, e.g., "K" has the same meaning as "KiB") or the suffixes KB (=1000), MB (=1000*1000), and so on for GB, TB, PB, EB, ZB and YB.
*-A, --fstab*::
-Trim all mounted filesystems mentioned in _/etc/fstab_ on devices that support the discard operation. The root filesystem is determined from kernel command line if missing in the file. The other supplied options, like *--offset*, *--length* and *--minimum*, are applied to all these devices. Errors from filesystems that do not support the discard operation, read-only devices and read-only filesystems are silently ignored.
+Trim all mounted filesystems mentioned in _/etc/fstab_ on devices that support the discard operation. The root filesystem is determined from kernel command line if missing in the file. The other supplied options, like *--offset*, *--length* and *--minimum*, are applied to all these devices. Errors from filesystems that do not support the discard operation, read-only devices, autofs and read-only filesystems are silently ignored.
*-a, --all*::
Trim all mounted filesystems on devices that support the discard operation. The other supplied options, like *--offset*, *--length* and *--minimum*, are applied to all these devices. Errors from filesystems that do not support the discard operation, read-only devices and read-only filesystems are silently ignored.
diff --git a/sys-utils/fstrim.c b/sys-utils/fstrim.c
index d2aec4f71..ea787f42c 100644
--- a/sys-utils/fstrim.c
+++ b/sys-utils/fstrim.c
@@ -35,6 +35,7 @@
#include <sys/ioctl.h>
#include <sys/stat.h>
+#include <sys/vfs.h>
#include <linux/fs.h>
#include "nls.h"
@@ -45,6 +46,7 @@
#include "pathnames.h"
#include "sysfs.h"
#include "optutils.h"
+#include "statfs_magic.h"
#include <libmount.h>
@@ -207,6 +209,30 @@ fail:
return 1;
}
+static int is_unwanted_fs(struct libmnt_fs *fs, const char *tgt)
+{
+ struct statfs vfs;
+ int fd, rc;
+
+ if (mnt_fs_is_pseudofs(fs))
+ return 1;
+ if (mnt_fs_is_netfs(fs))
+ return 1;
+ if (mnt_fs_is_swaparea(fs))
+ return 1;
+ if (mnt_fs_match_fstype(fs, "autofs"))
+ return 1;
+ if (mnt_fs_match_options(fs, "ro"))
+ return 1;
+
+ fd = open(tgt, O_PATH);
+ if (!fd)
+ return 1;
+ rc = fstatfs(fd, &vfs) != 0 || vfs.f_type == STATFS_AUTOFS_MAGIC;
+ close(fd);
+
+ return rc;
+}
static int uniq_fs_target_cmp(
struct libmnt_table *tb __attribute__((__unused__)),
@@ -292,7 +318,7 @@ static int fstrim_all_from_file(struct fstrim_control *ctl, const char *filename
const char *src = mnt_fs_get_srcpath(fs),
*tgt = mnt_fs_get_target(fs);
- if (!tgt || mnt_fs_is_pseudofs(fs) || mnt_fs_is_netfs(fs)) {
+ if (!tgt || is_unwanted_fs(fs, tgt)) {
mnt_table_remove_fs(tab, fs);
continue;
}
--
2.39.1

@ -0,0 +1,28 @@
From 825f9a8eb7800c572d4ded17dd202249312e3240 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 4 Oct 2021 11:14:01 +0200
Subject: fstrim: fix typo
Addresses: https://github.com/karelzak/util-linux/issues/1463
Signed-off-by: Karel Zak <kzak@redhat.com>
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2165981
---
sys-utils/fstrim.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sys-utils/fstrim.c b/sys-utils/fstrim.c
index ea787f42c..88397f0ec 100644
--- a/sys-utils/fstrim.c
+++ b/sys-utils/fstrim.c
@@ -226,7 +226,7 @@ static int is_unwanted_fs(struct libmnt_fs *fs, const char *tgt)
return 1;
fd = open(tgt, O_PATH);
- if (!fd)
+ if (fd < 0)
return 1;
rc = fstatfs(fd, &vfs) != 0 || vfs.f_type == STATFS_AUTOFS_MAGIC;
close(fd);
--
2.39.1

@ -0,0 +1,114 @@
From c76c1e5d7d3b043549f69c8dc8d6b878b1db0231 Mon Sep 17 00:00:00 2001
From: Scott Shambarger <devel@shambarger.net>
Date: Thu, 12 May 2022 16:27:26 -0700
Subject: fstrim: Remove all skipped entries before de-duplication
When processing fstab entries, de-duplication is performed based on the
source before all tests on the target have been checked, resulting in
some entries being skipped when a removed duplicate with a different
target would not have been.
The fix is to move all the target checks before the source
de-duplication.
Addresses: #1686
Signed-off-by: Scott Shambarger <devel@shambarger.net>
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2165981
---
sys-utils/fstrim.c | 53 ++++++++++++++++++++++++++--------------------
1 file changed, 30 insertions(+), 23 deletions(-)
diff --git a/sys-utils/fstrim.c b/sys-utils/fstrim.c
index 88397f0ec..0b05e590e 100644
--- a/sys-utils/fstrim.c
+++ b/sys-utils/fstrim.c
@@ -230,8 +230,17 @@ static int is_unwanted_fs(struct libmnt_fs *fs, const char *tgt)
return 1;
rc = fstatfs(fd, &vfs) != 0 || vfs.f_type == STATFS_AUTOFS_MAGIC;
close(fd);
+ if (rc)
+ return 1;
- return rc;
+ /* FITRIM on read-only filesystem can fail, and it can fail */
+ if (access(tgt, W_OK) != 0) {
+ if (errno == EROFS)
+ return 1;
+ if (errno == EACCES)
+ return 1;
+ }
+ return 0;
}
static int uniq_fs_target_cmp(
@@ -317,6 +326,8 @@ static int fstrim_all_from_file(struct fstrim_control *ctl, const char *filename
while (mnt_table_next_fs(tab, itr, &fs) == 0) {
const char *src = mnt_fs_get_srcpath(fs),
*tgt = mnt_fs_get_target(fs);
+ char *path;
+ int rc = 1;
if (!tgt || is_unwanted_fs(fs, tgt)) {
mnt_table_remove_fs(tab, fs);
@@ -339,19 +350,6 @@ static int fstrim_all_from_file(struct fstrim_control *ctl, const char *filename
mnt_table_remove_fs(tab, fs);
continue;
}
- }
-
- /* de-duplicate by source */
- mnt_table_uniq_fs(tab, MNT_UNIQ_FORWARD, uniq_fs_source_cmp);
-
- mnt_reset_iter(itr, MNT_ITER_BACKWARD);
-
- /* Do FITRIM */
- while (mnt_table_next_fs(tab, itr, &fs) == 0) {
- const char *src = mnt_fs_get_srcpath(fs),
- *tgt = mnt_fs_get_target(fs);
- char *path;
- int rc = 1;
/* Is it really accessible mountpoint? Not all mountpoints are
* accessible (maybe over mounted by another filesystem) */
@@ -359,20 +357,29 @@ static int fstrim_all_from_file(struct fstrim_control *ctl, const char *filename
if (path && streq_paths(path, tgt))
rc = 0;
free(path);
- if (rc)
+ if (rc) {
+ mnt_table_remove_fs(tab, fs);
continue; /* overlaying mount */
-
- /* FITRIM on read-only filesystem can fail, and it can fail */
- if (access(tgt, W_OK) != 0) {
- if (errno == EROFS)
- continue;
- if (errno == EACCES)
- continue;
}
if (!is_directory(tgt, 1) ||
- !has_discard(src, &wholedisk))
+ !has_discard(src, &wholedisk)) {
+ mnt_table_remove_fs(tab, fs);
continue;
+ }
+ }
+
+ /* de-duplicate by source */
+ mnt_table_uniq_fs(tab, MNT_UNIQ_FORWARD, uniq_fs_source_cmp);
+
+ mnt_reset_iter(itr, MNT_ITER_BACKWARD);
+
+ /* Do FITRIM */
+ while (mnt_table_next_fs(tab, itr, &fs) == 0) {
+ const char *src = mnt_fs_get_srcpath(fs),
+ *tgt = mnt_fs_get_target(fs);
+ int rc;
+
cnt++;
/*
--
2.39.1

@ -0,0 +1,339 @@
From a3b3df8d0891ff83b61f62020652798d365299c0 Mon Sep 17 00:00:00 2001
From: Michael Trapp <michael.trapp@sap.com>
Date: Mon, 20 Jun 2022 17:10:36 +0200
Subject: libuuid: Implement continuous clock handling for time based UUIDs
In a uuidd setup, the daemon is a singleton and can maintain it's own
resources for time based UUID generation. This requires a dedicated
'clock sequence range' but does not need any further lock/update of
the LIBUUID_CLOCK_FILE from uuidd. The range of available clock values
is extended by a continuous handling of the clock updates - instead of
updating the value to the current timestamp, it is incremented by
the number of requested UUIDs.
Upstream: http://github.com/util-linux/util-linux/commit/3cfba7d39b66eff4307218fefd8bb34bb1621f83
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2141970
Signed-off-by: Karel Zak <kzak@redhat.com>
---
libuuid/src/gen_uuid.c | 91 ++++++++++++++++++++++++++++++++++++++---
libuuid/src/libuuid.sym | 1 +
libuuid/src/uuidd.h | 1 +
misc-utils/uuidd.8.adoc | 3 ++
misc-utils/uuidd.c | 54 +++++++++++++++++++++---
5 files changed, 140 insertions(+), 10 deletions(-)
diff --git a/libuuid/src/gen_uuid.c b/libuuid/src/gen_uuid.c
index d353fa1a0..ac682a1d8 100644
--- a/libuuid/src/gen_uuid.c
+++ b/libuuid/src/gen_uuid.c
@@ -209,6 +209,8 @@ static int get_node_id(unsigned char *node_id)
/* Assume that the gettimeofday() has microsecond granularity */
#define MAX_ADJUSTMENT 10
+/* Reserve a clock_seq value for the 'continuous clock' implementation */
+#define CLOCK_SEQ_CONT 0
/*
* Get clock from global sequence clock counter.
@@ -275,8 +277,10 @@ static int get_clock(uint32_t *clock_high, uint32_t *clock_low,
}
if ((last.tv_sec == 0) && (last.tv_usec == 0)) {
- ul_random_get_bytes(&clock_seq, sizeof(clock_seq));
- clock_seq &= 0x3FFF;
+ do {
+ ul_random_get_bytes(&clock_seq, sizeof(clock_seq));
+ clock_seq &= 0x3FFF;
+ } while (clock_seq == CLOCK_SEQ_CONT);
gettimeofday(&last, NULL);
last.tv_sec--;
}
@@ -286,7 +290,9 @@ try_again:
if ((tv.tv_sec < last.tv_sec) ||
((tv.tv_sec == last.tv_sec) &&
(tv.tv_usec < last.tv_usec))) {
- clock_seq = (clock_seq+1) & 0x3FFF;
+ do {
+ clock_seq = (clock_seq+1) & 0x3FFF;
+ } while (clock_seq == CLOCK_SEQ_CONT);
adjustment = 0;
last = tv;
} else if ((tv.tv_sec == last.tv_sec) &&
@@ -331,6 +337,64 @@ try_again:
return ret;
}
+/*
+ * Get current time in 100ns ticks.
+ */
+static uint64_t get_clock_counter(void)
+{
+ struct timeval tv;
+ uint64_t clock_reg;
+
+ gettimeofday(&tv, NULL);
+ clock_reg = tv.tv_usec*10;
+ clock_reg += ((uint64_t) tv.tv_sec) * 10000000ULL;
+
+ return clock_reg;
+}
+
+/*
+ * Get continuous clock value.
+ *
+ * Return -1 if there is no further clock counter available,
+ * otherwise return 0.
+ *
+ * This implementation doesn't deliver clock counters based on
+ * the current time because last_clock_reg is only incremented
+ * by the number of requested UUIDs.
+ * max_clock_offset is used to limit the offset of last_clock_reg.
+ */
+static int get_clock_cont(uint32_t *clock_high,
+ uint32_t *clock_low,
+ int num,
+ uint32_t max_clock_offset)
+{
+ /* 100ns based time offset according to RFC 4122. 4.1.4. */
+ const uint64_t reg_offset = (((uint64_t) 0x01B21DD2) << 32) + 0x13814000;
+ static uint64_t last_clock_reg = 0;
+ uint64_t clock_reg;
+
+ if (last_clock_reg == 0)
+ last_clock_reg = get_clock_counter();
+
+ clock_reg = get_clock_counter();
+ if (max_clock_offset) {
+ uint64_t clock_offset = max_clock_offset * 10000000ULL;
+ if (last_clock_reg < (clock_reg - clock_offset))
+ last_clock_reg = clock_reg - clock_offset;
+ }
+
+ clock_reg += MAX_ADJUSTMENT;
+
+ if ((last_clock_reg + num) >= clock_reg)
+ return -1;
+
+ *clock_high = (last_clock_reg + reg_offset) >> 32;
+ *clock_low = last_clock_reg + reg_offset;
+ last_clock_reg += num;
+
+ return 0;
+}
+
#if defined(HAVE_UUIDD) && defined(HAVE_SYS_UN_H)
/*
@@ -403,7 +467,7 @@ static int get_uuid_via_daemon(int op __attribute__((__unused__)),
}
#endif
-int __uuid_generate_time(uuid_t out, int *num)
+static int __uuid_generate_time_internal(uuid_t out, int *num, uint32_t cont_offset)
{
static unsigned char node_id[6];
static int has_init = 0;
@@ -423,7 +487,14 @@ int __uuid_generate_time(uuid_t out, int *num)
}
has_init = 1;
}
- ret = get_clock(&clock_mid, &uu.time_low, &uu.clock_seq, num);
+ if (cont_offset) {
+ ret = get_clock_cont(&clock_mid, &uu.time_low, *num, cont_offset);
+ uu.clock_seq = CLOCK_SEQ_CONT;
+ if (ret != 0) /* fallback to previous implpementation */
+ ret = get_clock(&clock_mid, &uu.time_low, &uu.clock_seq, num);
+ } else {
+ ret = get_clock(&clock_mid, &uu.time_low, &uu.clock_seq, num);
+ }
uu.clock_seq |= 0x8000;
uu.time_mid = (uint16_t) clock_mid;
uu.time_hi_and_version = ((clock_mid >> 16) & 0x0FFF) | 0x1000;
@@ -432,6 +503,16 @@ int __uuid_generate_time(uuid_t out, int *num)
return ret;
}
+int __uuid_generate_time(uuid_t out, int *num)
+{
+ return __uuid_generate_time_internal(out, num, 0);
+}
+
+int __uuid_generate_time_cont(uuid_t out, int *num, uint32_t cont_offset)
+{
+ return __uuid_generate_time_internal(out, num, cont_offset);
+}
+
/*
* Generate time-based UUID and store it to @out
*
diff --git a/libuuid/src/libuuid.sym b/libuuid/src/libuuid.sym
index 342453368..96372a857 100644
--- a/libuuid/src/libuuid.sym
+++ b/libuuid/src/libuuid.sym
@@ -60,6 +60,7 @@ global:
UUIDD_PRIVATE {
global:
__uuid_generate_time;
+ __uuid_generate_time_cont;
__uuid_generate_random;
local:
*;
diff --git a/libuuid/src/uuidd.h b/libuuid/src/uuidd.h
index fbe821ff3..f76acc8b2 100644
--- a/libuuid/src/uuidd.h
+++ b/libuuid/src/uuidd.h
@@ -49,6 +49,7 @@
#define UUIDD_MAX_OP UUIDD_OP_BULK_RANDOM_UUID
extern int __uuid_generate_time(uuid_t out, int *num);
+extern int __uuid_generate_time_cont(uuid_t out, int *num, uint32_t cont);
extern int __uuid_generate_random(uuid_t out, int *num);
#endif /* _UUID_UUID_H */
diff --git a/misc-utils/uuidd.8.adoc b/misc-utils/uuidd.8.adoc
index 77ee2b3e6..c87125901 100644
--- a/misc-utils/uuidd.8.adoc
+++ b/misc-utils/uuidd.8.adoc
@@ -24,6 +24,9 @@ The *uuidd* daemon is used by the UUID library to generate universally unique id
== OPTIONS
+*-C*, *--cont-clock* _opt_arg_::
+Activate continuous clock handling for time based UUIDs. *uuidd* could use all possible clock values, beginning with the daemon's start time. The optional argument can be used to set a value for the max_clock_offset. This gurantees, that a clock value of a UUID will always be within the range of the max_clock_offset. '-C' or '--cont-clock' enables the feature with a default max_clock_offset of 2 hours. '-C<NUM>[hd]' or '--cont-clock=<NUM>[hd]' enables the feature with a max_clock_offset of NUM seconds. In case of an appended h or d, the NUM value is read in hours or days. The minimum value is 60 seconds, the maximum value is 365 days.
+
*-d*, *--debug*::
Run uuidd in debugging mode. This prevents uuidd from running as a daemon.
diff --git a/misc-utils/uuidd.c b/misc-utils/uuidd.c
index 78a37d2e8..b859ccb8c 100644
--- a/misc-utils/uuidd.c
+++ b/misc-utils/uuidd.c
@@ -72,6 +72,8 @@ struct uuidd_cxt_t {
const char *cleanup_pidfile;
const char *cleanup_socket;
uint32_t timeout;
+ uint32_t cont_clock_offset;
+
unsigned int debug: 1,
quiet: 1,
no_fork: 1,
@@ -106,6 +108,8 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_(" -P, --no-pid do not create pid file\n"), out);
fputs(_(" -F, --no-fork do not daemonize using double-fork\n"), out);
fputs(_(" -S, --socket-activation do not create listening socket\n"), out);
+ fputs(_(" -C, --cont-clock[=<NUM>[hd]]\n"), out);
+ fputs(_(" activate continuous clock handling\n"), out);
fputs(_(" -d, --debug run in debugging mode\n"), out);
fputs(_(" -q, --quiet turn on quiet mode\n"), out);
fputs(USAGE_SEPARATOR, out);
@@ -438,6 +442,15 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
pfd[POLLFD_SOCKET].fd = s;
pfd[POLLFD_SIGNAL].events = pfd[POLLFD_SOCKET].events = POLLIN | POLLERR | POLLHUP;
+ num = 1;
+ if (uuidd_cxt->cont_clock_offset) {
+ /* trigger initialization */
+ (void) __uuid_generate_time_cont(uu, &num, uuidd_cxt->cont_clock_offset);
+ if (uuidd_cxt->debug)
+ fprintf(stderr, _("max_clock_offset = %u sec\n"),
+ uuidd_cxt->cont_clock_offset);
+ }
+
while (1) {
ret = poll(pfd, ARRAY_SIZE(pfd),
uuidd_cxt->timeout ?
@@ -494,7 +507,8 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
break;
case UUIDD_OP_TIME_UUID:
num = 1;
- if (__uuid_generate_time(uu, &num) < 0 && !uuidd_cxt->quiet)
+ ret = __uuid_generate_time_cont(uu, &num, uuidd_cxt->cont_clock_offset);
+ if (ret < 0 && !uuidd_cxt->quiet)
warnx(_("failed to open/lock clock counter"));
if (uuidd_cxt->debug) {
uuid_unparse(uu, str);
@@ -505,7 +519,8 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
break;
case UUIDD_OP_RANDOM_UUID:
num = 1;
- if (__uuid_generate_time(uu, &num) < 0 && !uuidd_cxt->quiet)
+ ret = __uuid_generate_time_cont(uu, &num, uuidd_cxt->cont_clock_offset);
+ if (ret < 0 && !uuidd_cxt->quiet)
warnx(_("failed to open/lock clock counter"));
if (uuidd_cxt->debug) {
uuid_unparse(uu, str);
@@ -515,7 +530,8 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
reply_len = sizeof(uu);
break;
case UUIDD_OP_BULK_TIME_UUID:
- if (__uuid_generate_time(uu, &num) < 0 && !uuidd_cxt->quiet)
+ ret = __uuid_generate_time_cont(uu, &num, uuidd_cxt->cont_clock_offset);
+ if (ret < 0 && !uuidd_cxt->quiet)
warnx(_("failed to open/lock clock counter"));
if (uuidd_cxt->debug) {
uuid_unparse(uu, str);
@@ -567,6 +583,27 @@ static void __attribute__ ((__noreturn__)) unexpected_size(int size)
errx(EXIT_FAILURE, _("Unexpected reply length from server %d"), size);
}
+static uint32_t parse_cont_clock(char *arg)
+{
+ uint32_t min_val = 60,
+ max_val = (3600 * 24 * 365),
+ factor = 1;
+ char *p = &arg[strlen(arg)-1];
+
+ if ('h' == *p) {
+ *p = '\0';
+ factor = 3600;
+ min_val = 1;
+ }
+ if ('d' == *p) {
+ *p = '\0';
+ factor = 24 * 3600;
+ min_val = 1;
+ }
+ return factor * str2num_or_err(optarg, 10, _("failed to parse --cont-clock/-C"),
+ min_val, max_val / factor);
+}
+
static void parse_options(int argc, char **argv, struct uuidd_cxt_t *uuidd_cxt,
struct uuidd_options_t *uuidd_opts)
{
@@ -581,6 +618,7 @@ static void parse_options(int argc, char **argv, struct uuidd_cxt_t *uuidd_cxt,
{"no-pid", no_argument, NULL, 'P'},
{"no-fork", no_argument, NULL, 'F'},
{"socket-activation", no_argument, NULL, 'S'},
+ {"cont-clock", optional_argument, NULL, 'C'},
{"debug", no_argument, NULL, 'd'},
{"quiet", no_argument, NULL, 'q'},
{"version", no_argument, NULL, 'V'},
@@ -596,9 +634,15 @@ static void parse_options(int argc, char **argv, struct uuidd_cxt_t *uuidd_cxt,
int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;
int c;
- while ((c = getopt_long(argc, argv, "p:s:T:krtn:PFSdqVh", longopts, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "p:s:T:krtn:PFSC::dqVh", longopts, NULL)) != -1) {
err_exclusive_options(c, longopts, excl, excl_st);
switch (c) {
+ case 'C':
+ if (optarg != NULL)
+ uuidd_cxt->cont_clock_offset = parse_cont_clock(optarg);
+ else
+ uuidd_cxt->cont_clock_offset = 7200; /* default 2h */
+ break;
case 'd':
uuidd_cxt->debug = 1;
break;
@@ -673,7 +717,7 @@ int main(int argc, char **argv)
char *cp;
int ret;
- struct uuidd_cxt_t uuidd_cxt = { .timeout = 0 };
+ struct uuidd_cxt_t uuidd_cxt = { .timeout = 0, .cont_clock_offset = 0 };
struct uuidd_options_t uuidd_opts = { .socket_path = UUIDD_SOCKET_PATH };
setlocale(LC_ALL, "");
--
2.39.1

@ -0,0 +1,35 @@
From cede4c481ba0f8fa4256341a0acca33f826fca4f Mon Sep 17 00:00:00 2001
From: Michael Trapp <michael.trapp@sap.com>
Date: Tue, 2 Aug 2022 14:16:43 +0200
Subject: libuuid: check clock value from LIBUUID_CLOCK_FILE
The clock value from the LIBUUID_CLOCK_FILE must be checked in
case of an update of libuuid. If clock==CLOCK_SEQ_CONT it must
be set to a new value.
Upstream: http://github.com/util-linux/util-linux/commit/5d1424d85ac9e2a1369ee920038825c154ee5443
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2141970
Signed-off-by: Karel Zak <kzak@redhat.com>
---
libuuid/src/gen_uuid.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/libuuid/src/gen_uuid.c b/libuuid/src/gen_uuid.c
index ac682a1d8..f05db467e 100644
--- a/libuuid/src/gen_uuid.c
+++ b/libuuid/src/gen_uuid.c
@@ -274,6 +274,11 @@ static int get_clock(uint32_t *clock_high, uint32_t *clock_low,
last.tv_usec = tv2;
adjustment = a;
}
+ // reset in case of reserved CLOCK_SEQ_CONT
+ if (clock_seq == CLOCK_SEQ_CONT) {
+ last.tv_sec = 0;
+ last.tv_usec = 0;
+ }
}
if ((last.tv_sec == 0) && (last.tv_usec == 0)) {
--
2.39.1

@ -0,0 +1,34 @@
From cae4f3f433e4a308f70103e166c6afad30b59ca7 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 10 Oct 2022 09:37:51 +0200
Subject: uuidd: fix random UUIDs
Commit f27876f introduces copy & past bug and replaces
__uuid_generate_random() with __uuid_generate_time().
Fixes: https://github.com/util-linux/util-linux/issues/1837
Signed-off-by: Karel Zak <kzak@redhat.com>
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2133385
Upstream: http://github.com/util-linux/util-linux/commit/b408a291d39e9b637f6104eb4e1f8e60816421e2
---
misc-utils/uuidd.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/misc-utils/uuidd.c b/misc-utils/uuidd.c
index b859ccb8c..489d6b79a 100644
--- a/misc-utils/uuidd.c
+++ b/misc-utils/uuidd.c
@@ -519,9 +519,7 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
break;
case UUIDD_OP_RANDOM_UUID:
num = 1;
- ret = __uuid_generate_time_cont(uu, &num, uuidd_cxt->cont_clock_offset);
- if (ret < 0 && !uuidd_cxt->quiet)
- warnx(_("failed to open/lock clock counter"));
+ __uuid_generate_random(uu, &num);
if (uuidd_cxt->debug) {
uuid_unparse(uu, str);
fprintf(stderr, _("Generated random UUID: %s\n"), str);
--
2.39.1

@ -0,0 +1,106 @@
From b77ac3951932d2ea8bdba2b800380b3e70f8eca2 Mon Sep 17 00:00:00 2001
From: tamz <totemz@protonmail.com>
Date: Thu, 6 Jan 2022 11:56:58 +0100
Subject: agetty: resolve tty name even if stdin is specified
[kzak@redhat.com: - use "const" for options->tty (and friends)
as expected by get_terminal_name()]
Addresses: https://github.com/util-linux/util-linux/issues/1546
Signed-off-by: tamz <totemz@protonmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2156946
Upstream: http://github.com/util-linux/util-linux/commit/47831cc02ac0d71c335caecef1753f4c8861277c
---
term-utils/agetty.c | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/term-utils/agetty.c b/term-utils/agetty.c
index 3b3d5101a..e65cbdeaf 100644
--- a/term-utils/agetty.c
+++ b/term-utils/agetty.c
@@ -186,8 +186,8 @@ struct options {
char *chroot; /* Chroot before the login */
char *login; /* login program */
char *logopt; /* options for login program */
- char *tty; /* name of tty */
- char *vcline; /* line of virtual console */
+ const char *tty; /* name of tty */
+ const char *vcline; /* line of virtual console */
char *term; /* terminal type */
char *initstring; /* modem init string */
char *issue; /* alternative issue file or directory */
@@ -199,6 +199,7 @@ struct options {
int numspeed; /* number of baud rates to try */
int clocal; /* CLOCAL_MODE_* */
int kbmode; /* Keyboard mode if virtual console */
+ int tty_is_stdin; /* is the tty the standard input stream */
speed_t speeds[MAX_SPEED]; /* baud rates to be tried */
};
@@ -315,7 +316,7 @@ static void init_special_char(char* arg, struct options *op);
static void parse_args(int argc, char **argv, struct options *op);
static void parse_speeds(struct options *op, char *arg);
static void update_utmp(struct options *op);
-static void open_tty(char *tty, struct termios *tp, struct options *op);
+static void open_tty(const char *tty, struct termios *tp, struct options *op);
static void termio_init(struct options *op, struct termios *tp);
static void reset_vc(const struct options *op, struct termios *tp, int canon);
static void auto_baud(struct termios *tp);
@@ -918,6 +919,15 @@ static void parse_args(int argc, char **argv, struct options *op)
}
}
+ /* resolve the tty path in case it was provided as stdin */
+ if (strcmp(op->tty, "-") == 0) {
+ op->tty_is_stdin = 1;
+ int fd = get_terminal_name(NULL, &op->tty, NULL);
+ if (fd < 0) {
+ log_warn(_("could not get terminal name: %d"), fd);
+ }
+ }
+
/* On virtual console remember the line which is used for */
if (strncmp(op->tty, "tty", 3) == 0 &&
strspn(op->tty + 3, "0123456789") == strlen(op->tty+3))
@@ -958,8 +968,8 @@ static void update_utmp(struct options *op)
time_t t;
pid_t pid = getpid();
pid_t sid = getsid(0);
- char *vcline = op->vcline;
- char *line = op->tty;
+ const char *vcline = op->vcline;
+ const char *line = op->tty;
struct utmpx *utp;
/*
@@ -998,7 +1008,7 @@ static void update_utmp(struct options *op)
str2memcpy(ut.ut_id, vcline, sizeof(ut.ut_id));
else {
size_t len = strlen(line);
- char * ptr;
+ const char * ptr;
if (len >= sizeof(ut.ut_id))
ptr = line + len - sizeof(ut.ut_id);
else
@@ -1026,7 +1036,7 @@ static void update_utmp(struct options *op)
#endif /* SYSV_STYLE */
/* Set up tty as stdin, stdout & stderr. */
-static void open_tty(char *tty, struct termios *tp, struct options *op)
+static void open_tty(const char *tty, struct termios *tp, struct options *op)
{
const pid_t pid = getpid();
int closed = 0;
@@ -1036,7 +1046,7 @@ static void open_tty(char *tty, struct termios *tp, struct options *op)
/* Set up new standard input, unless we are given an already opened port. */
- if (strcmp(tty, "-") != 0) {
+ if (!op->tty_is_stdin) {
char buf[PATH_MAX+1];
struct group *gr = NULL;
struct stat st;
--
2.39.1

@ -0,0 +1,112 @@
From d4a05cc653c9e251a04afa9bd4f5a75777029445 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Thu, 2 Feb 2023 15:46:43 +0100
Subject: last: use snprintf() rather than sprintf()
Signed-off-by: Karel Zak <kzak@redhat.com>
Upstream: http://github.com/util-linux/util-linux/commit/79fb7e18f45e84c6f1a030b5df56cb2bdad26df0
Upstream: http://github.com/util-linux/util-linux/commit/6cd0043221b31a344db8f5dcb82822a2519a2e74
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2166653
---
login-utils/last.c | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/login-utils/last.c b/login-utils/last.c
index f3272caeb..7f4421c89 100644
--- a/login-utils/last.c
+++ b/login-utils/last.c
@@ -463,48 +463,48 @@ static int list(const struct last_control *ctl, struct utmpx *p, time_t logout_t
if (logout_time == currentdate) {
if (ctl->time_fmt > LAST_TIMEFTM_SHORT) {
- sprintf(logouttime, " still running");
+ snprintf(logouttime, sizeof(logouttime), " still running");
length[0] = 0;
} else {
- sprintf(logouttime, " still");
- sprintf(length, "running");
+ snprintf(logouttime, sizeof(logouttime), " still");
+ snprintf(length, sizeof(length), "running");
}
} else if (days) {
- sprintf(length, "(%d+%02d:%02d)", days, abs(hours), abs(mins)); /* hours and mins always shown as positive (w/o minus sign!) even if secs < 0 */
+ snprintf(length, sizeof(length), "(%d+%02d:%02d)", days, abs(hours), abs(mins)); /* hours and mins always shown as positive (w/o minus sign!) even if secs < 0 */
} else if (hours) {
- sprintf(length, " (%02d:%02d)", hours, abs(mins)); /* mins always shown as positive (w/o minus sign!) even if secs < 0 */
+ snprintf(length, sizeof(length), " (%02d:%02d)", hours, abs(mins)); /* mins always shown as positive (w/o minus sign!) even if secs < 0 */
} else if (secs >= 0) {
- sprintf(length, " (%02d:%02d)", hours, mins);
+ snprintf(length, sizeof(length), " (%02d:%02d)", hours, mins);
} else {
- sprintf(length, " (-00:%02d)", abs(mins)); /* mins always shown as positive (w/o minus sign!) even if secs < 0 */
+ snprintf(length, sizeof(length), " (-00:%02d)", abs(mins)); /* mins always shown as positive (w/o minus sign!) even if secs < 0 */
}
switch(what) {
case R_CRASH:
- sprintf(logouttime, "- crash");
+ snprintf(logouttime, sizeof(logouttime), "- crash");
break;
case R_DOWN:
- sprintf(logouttime, "- down ");
+ snprintf(logouttime, sizeof(logouttime), "- down ");
break;
case R_NOW:
if (ctl->time_fmt > LAST_TIMEFTM_SHORT) {
- sprintf(logouttime, " still logged in");
+ snprintf(logouttime, sizeof(logouttime), " still logged in");
length[0] = 0;
} else {
- sprintf(logouttime, " still");
- sprintf(length, "logged in");
+ snprintf(logouttime, sizeof(logouttime), " still");
+ snprintf(length, sizeof(length), "logged in");
}
break;
case R_PHANTOM:
if (ctl->time_fmt > LAST_TIMEFTM_SHORT) {
- sprintf(logouttime, " gone - no logout");
+ snprintf(logouttime, sizeof(logouttime), " gone - no logout");
length[0] = 0;
} else if (ctl->time_fmt == LAST_TIMEFTM_SHORT) {
- sprintf(logouttime, " gone");
- sprintf(length, "- no logout");
+ snprintf(logouttime, sizeof(logouttime), " gone");
+ snprintf(length, sizeof(length), "- no logout");
} else {
logouttime[0] = 0;
- sprintf(length, "no logout");
+ snprintf(length, sizeof(length), "no logout");
}
break;
case R_TIMECHANGE:
@@ -756,7 +756,7 @@ static void process_wtmp_file(const struct last_control *ctl,
else {
if (ut.ut_type != DEAD_PROCESS &&
ut.ut_user[0] && ut.ut_line[0] &&
- strcmp(ut.ut_user, "LOGIN") != 0)
+ strncmp(ut.ut_user, "LOGIN", 5) != 0)
ut.ut_type = USER_PROCESS;
/*
* Even worse, applications that write ghost
@@ -769,7 +769,7 @@ static void process_wtmp_file(const struct last_control *ctl,
/*
* Clock changes.
*/
- if (strcmp(ut.ut_user, "date") == 0) {
+ if (strncmp(ut.ut_user, "date", 4) == 0) {
if (ut.ut_line[0] == '|')
ut.ut_type = OLD_TIME;
if (ut.ut_line[0] == '{')
@@ -804,7 +804,7 @@ static void process_wtmp_file(const struct last_control *ctl,
case RUN_LVL:
x = ut.ut_pid & 255;
if (ctl->extended) {
- sprintf(ut.ut_line, "(to lvl %c)", x);
+ snprintf(ut.ut_line, sizeof(ut.ut_line), "(to lvl %c)", x);
quit = list(ctl, &ut, lastrch, R_NORMAL);
}
if (x == '0' || x == '6') {
--
2.39.1

@ -0,0 +1,47 @@
From 5285f83b77df9e206f4904eba92c741eb42acc93 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 13 Dec 2021 13:19:18 +0100
Subject: include/c: add cmp_timespec() and cmp_stat_mtime()
It's like timercmp() in libc, but for timespec and for stat.st_mtim
(or stat.st_mtime for old struct stat versions).
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2180414
Upstream: http://github.com/util-linux/util-linux/commit/0cfb8c5c3205a92ae81def278cdded63ea47094f
Signed-off-by: Karel Zak <kzak@redhat.com>
---
include/c.h | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/include/c.h b/include/c.h
index 354b59e29..01f0fa507 100644
--- a/include/c.h
+++ b/include/c.h
@@ -167,6 +167,24 @@
_a == _b ? 0 : _a > _b ? 1 : -1; })
#endif
+
+#ifndef cmp_timespec
+# define cmp_timespec(a, b, CMP) \
+ (((a)->tv_sec == (b)->tv_sec) \
+ ? ((a)->tv_nsec CMP (b)->tv_nsec) \
+ : ((a)->tv_sec CMP (b)->tv_sec))
+#endif
+
+
+#ifndef cmp_stat_mtime
+# ifdef HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
+# define cmp_stat_mtime(_a, _b, CMP) cmp_timespec(&(_a)->st_mtim, &(_b)->st_mtim, CMP)
+# else
+# define cmp_stat_mtime(_a, _b, CMP) ((_a)->st_mtime CMP (_b)->st_mtime)
+# endif
+#endif
+
+
#ifndef offsetof
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#endif
--
2.39.2

@ -0,0 +1,86 @@
From 5d150964f0b2fbcaa9f9d11809eede9255159a5d Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 13 Dec 2021 13:22:56 +0100
Subject: 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
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2180414
Upstream: http://github.com/util-linux/util-linux/commit/1db0715169954a8f3898f7ca9d3902cd6c27084d
Signed-off-by: Karel Zak <kzak@redhat.com>
---
include/pathnames.h | 2 ++
sys-utils/mount.c | 23 +++++++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/include/pathnames.h b/include/pathnames.h
index 7e7d9053f..8c3c36477 100644
--- a/include/pathnames.h
+++ b/include/pathnames.h
@@ -82,6 +82,8 @@
#define _PATH_NUMLOCK_ON _PATH_RUNSTATEDIR "/numlock-on"
#define _PATH_LOGINDEFS "/etc/login.defs"
+#define _PATH_SD_UNITSLOAD _PATH_RUNSTATEDIR "/systemd/systemd-units-load"
+
/* misc paths */
#define _PATH_WORDS "/usr/share/dict/words"
#define _PATH_WORDS_ALT "/usr/share/dict/web2"
diff --git a/sys-utils/mount.c b/sys-utils/mount.c
index ce1de16dc..90a0331c3 100644
--- a/sys-utils/mount.c
+++ b/sys-utils/mount.c
@@ -38,6 +38,7 @@
#include "strutils.h"
#include "closestream.h"
#include "canonicalize.h"
+#include "pathnames.h"
#define XALLOC_EXIT_CODE MNT_EX_SYSERR
#include "xalloc.h"
@@ -336,6 +337,25 @@ static void selinux_warning(struct libmnt_context *cxt, const char *tgt)
# define selinux_warning(_x, _y)
#endif
+static void systemd_hint(void)
+{
+ static int fstab_check_done = 0;
+
+ if (fstab_check_done == 0) {
+ struct stat a, b;
+
+ if (isatty(STDERR_FILENO) &&
+ stat(_PATH_SD_UNITSLOAD, &a) == 0 &&
+ stat(_PATH_MNTTAB, &b) == 0 &&
+ cmp_stat_mtime(&a, &b, <))
+ printf(_(
+ "mount: (hint) your fstab has been modified, but systemd still uses\n"
+ " the old version; use 'systemctl daemon-reload' to reload.\n"));
+
+ fstab_check_done = 1;
+ }
+}
+
/*
* Returns exit status (MNT_EX_*) and/or prints error message.
*/
@@ -359,6 +379,9 @@ static int mk_exit_code(struct libmnt_context *cxt, int rc)
if (rc == MNT_EX_SUCCESS && mnt_context_get_status(cxt) == 1) {
selinux_warning(cxt, tgt);
}
+
+ systemd_hint();
+
return rc;
}
--
2.39.2

@ -0,0 +1,73 @@
From 3dc40e180aaf653bc76fc0097a8bb112f48af5ae Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Wed, 2 Mar 2022 11:34:06 +0100
Subject: tests: improve cramfs tests
* make GID and mode use more robust (already used in tests/ts/cramfs/mkfs)
* mark cramfs fsck/mkfs tests as TS_KNOWN_FAIL, the tests are based on
image checksums and it produces a different binary image on s390
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2133396
Addresses: https://github.com/util-linux/util-linux/issues/1613
Signed-off-by: Karel Zak <kzak@redhat.com>
---
tests/ts/cramfs/doubles | 9 ++++++++-
tests/ts/cramfs/fsck-endianness | 3 +++
tests/ts/cramfs/mkfs-endianness | 3 +++
3 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/tests/ts/cramfs/doubles b/tests/ts/cramfs/doubles
index 8a1b7bb88..eb2c7fa0f 100755
--- a/tests/ts/cramfs/doubles
+++ b/tests/ts/cramfs/doubles
@@ -36,10 +36,17 @@ IMAGE_SRC="$TS_OUTDIR/${TS_TESTNAME}-data"
ts_log "create mountpoint dir"
[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
-mkdir -p $IMAGE_SRC
+rm -rf "$IMAGE_SRC"
+mkdir -m 755 -p $IMAGE_SRC
+
+umask 133
+
echo hello > $IMAGE_SRC/a
echo hello > $IMAGE_SRC/b
+# sudo may use whatever group
+chgrp -R 0 "$IMAGE_SRC"
+
ts_log "create cramfs image"
$TS_CMD_MKCRAMFS $IMAGE_SRC $IMAGE_PATH >> $TS_OUTPUT 2>> $TS_ERRLOG
[ -s "$IMAGE_PATH" ] || ts_die "Cannot create $IMAGE_PATH"
diff --git a/tests/ts/cramfs/fsck-endianness b/tests/ts/cramfs/fsck-endianness
index bcfb46c90..222ea3fd3 100755
--- a/tests/ts/cramfs/fsck-endianness
+++ b/tests/ts/cramfs/fsck-endianness
@@ -27,6 +27,9 @@ ts_check_test_command "$TS_HELPER_MD5"
ts_skip_nonroot
+# does not work on s390
+TS_KNOWN_FAIL="yes"
+
IMAGE_LITTLE="$TS_SELF/cramfs-little.img" #Known good little endian image
IMAGE_BIG="$TS_SELF/cramfs-big.img" #Known good big endian image
diff --git a/tests/ts/cramfs/mkfs-endianness b/tests/ts/cramfs/mkfs-endianness
index 91d476579..5f0ff714d 100755
--- a/tests/ts/cramfs/mkfs-endianness
+++ b/tests/ts/cramfs/mkfs-endianness
@@ -26,6 +26,9 @@ ts_check_test_command "$TS_CMD_HEXDUMP"
ts_skip_nonroot
+# does not work on s390
+TS_KNOWN_FAIL="yes"
+
IMAGE_DATA="$TS_OUTDIR/${TS_TESTNAME}-data"
IMAGE_CREATED="$TS_OUTDIR/${TS_TESTNAME}-cramfs.img" #Image created during the test and compared against the known images.
--
2.40.1

@ -0,0 +1,33 @@
From f0f4fe8901462ca335d89267037ffe99096bac72 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Wed, 9 Aug 2023 12:56:42 +0200
Subject: uuidd: improve man page for -cont-clock
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2174748
Signed-off-by: Karel Zak <kzak@redhat.com>
---
misc-utils/uuidd.8.adoc | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/misc-utils/uuidd.8.adoc b/misc-utils/uuidd.8.adoc
index c87125901..38ef39598 100644
--- a/misc-utils/uuidd.8.adoc
+++ b/misc-utils/uuidd.8.adoc
@@ -24,8 +24,12 @@ The *uuidd* daemon is used by the UUID library to generate universally unique id
== OPTIONS
-*-C*, *--cont-clock* _opt_arg_::
-Activate continuous clock handling for time based UUIDs. *uuidd* could use all possible clock values, beginning with the daemon's start time. The optional argument can be used to set a value for the max_clock_offset. This gurantees, that a clock value of a UUID will always be within the range of the max_clock_offset. '-C' or '--cont-clock' enables the feature with a default max_clock_offset of 2 hours. '-C<NUM>[hd]' or '--cont-clock=<NUM>[hd]' enables the feature with a max_clock_offset of NUM seconds. In case of an appended h or d, the NUM value is read in hours or days. The minimum value is 60 seconds, the maximum value is 365 days.
+*-C*, *--cont-clock*[=_time_]::
+Activate continuous clock handling for time based UUIDs. *uuidd* could use all possible clock values, beginning with the daemon's start time. The optional argument can be used to set a value for the max_clock_offset. This gurantees, that a clock value of a UUID will always be within the range of the max_clock_offset.
++
+The option '-C' or '--cont-clock' enables the feature with a default max_clock_offset of 2 hours.
++
+The option '-C<NUM>[hd]' or '--cont-clock=<NUM>[hd]' enables the feature with a max_clock_offset of NUM seconds. In case of an appended h or d, the NUM value is read in hours or days. The minimum value is 60 seconds, the maximum value is 365 days.
*-d*, *--debug*::
Run uuidd in debugging mode. This prevents uuidd from running as a daemon.
--
2.40.1

@ -0,0 +1,27 @@
From 9d5e7c1357b8f4745d28b5a1aa8726b58666ad59 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Wed, 9 Aug 2023 13:12:34 +0200
Subject: uuidd: enable cont-clock in service file
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2174748
Signed-off-by: Karel Zak <kzak@redhat.com>
---
misc-utils/uuidd.service.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/misc-utils/uuidd.service.in b/misc-utils/uuidd.service.in
index 4ad6d97c9..330f1ab9b 100644
--- a/misc-utils/uuidd.service.in
+++ b/misc-utils/uuidd.service.in
@@ -4,7 +4,7 @@ Documentation=man:uuidd(8)
Requires=uuidd.socket
[Service]
-ExecStart=@usrsbin_execdir@/uuidd --socket-activation
+ExecStart=@usrsbin_execdir@/uuidd --socket-activation --cont-clock
Restart=no
User=uuidd
Group=uuidd
--
2.40.1

@ -0,0 +1,205 @@
From 5f44ec9a0096a0c220666d5586618fd718a9a40d Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Wed, 9 Aug 2023 13:21:02 +0200
Subject: lscpu: backport ARM human-readable names from upstream
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2182169
Signed-off-by: Karel Zak <kzak@redhat.com>
---
sys-utils/lscpu-arm.c | 109 +++++++++++++++++++++++++++++++++++++-----
1 file changed, 96 insertions(+), 13 deletions(-)
diff --git a/sys-utils/lscpu-arm.c b/sys-utils/lscpu-arm.c
index 79b8e3aa5..5716f6c51 100644
--- a/sys-utils/lscpu-arm.c
+++ b/sys-utils/lscpu-arm.c
@@ -64,6 +64,7 @@ static const struct id_part arm_part[] = {
{ 0xc27, "Cortex-M7" },
{ 0xc60, "Cortex-M0+" },
{ 0xd01, "Cortex-A32" },
+ { 0xd02, "Cortex-A34" },
{ 0xd03, "Cortex-A53" },
{ 0xd04, "Cortex-A35" },
{ 0xd05, "Cortex-A55" },
@@ -77,18 +78,36 @@ static const struct id_part arm_part[] = {
{ 0xd0d, "Cortex-A77" },
{ 0xd0e, "Cortex-A76AE" },
{ 0xd13, "Cortex-R52" },
+ { 0xd15, "Cortex-R82" },
+ { 0xd16, "Cortex-R52+" },
{ 0xd20, "Cortex-M23" },
{ 0xd21, "Cortex-M33" },
+ { 0xd22, "Cortex-M55" },
+ { 0xd23, "Cortex-M85" },
+ { 0xd40, "Neoverse-V1" },
{ 0xd41, "Cortex-A78" },
{ 0xd42, "Cortex-A78AE" },
+ { 0xd43, "Cortex-A65AE" },
+ { 0xd44, "Cortex-X1" },
+ { 0xd46, "Cortex-A510" },
+ { 0xd47, "Cortex-A710" },
+ { 0xd48, "Cortex-X2" },
+ { 0xd49, "Neoverse-N2" },
{ 0xd4a, "Neoverse-E1" },
{ 0xd4b, "Cortex-A78C" },
+ { 0xd4c, "Cortex-X1C" },
+ { 0xd4d, "Cortex-A715" },
+ { 0xd4e, "Cortex-X3" },
+ { 0xd4f, "Neoverse-V2" },
+ { 0xd80, "Cortex-A520" },
+ { 0xd81, "Cortex-A720" },
+ { 0xd82, "Cortex-X4" },
{ -1, "unknown" },
};
static const struct id_part brcm_part[] = {
- { 0x0f, "Brahma B15" },
- { 0x100, "Brahma B53" },
+ { 0x0f, "Brahma-B15" },
+ { 0x100, "Brahma-B53" },
{ 0x516, "ThunderX2" },
{ -1, "unknown" },
};
@@ -101,10 +120,18 @@ static const struct id_part dec_part[] = {
static const struct id_part cavium_part[] = {
{ 0x0a0, "ThunderX" },
- { 0x0a1, "ThunderX 88XX" },
- { 0x0a2, "ThunderX 81XX" },
- { 0x0a3, "ThunderX 83XX" },
- { 0x0af, "ThunderX2 99xx" },
+ { 0x0a1, "ThunderX-88XX" },
+ { 0x0a2, "ThunderX-81XX" },
+ { 0x0a3, "ThunderX-83XX" },
+ { 0x0af, "ThunderX2-99xx" },
+ { 0x0b0, "OcteonTX2" },
+ { 0x0b1, "OcteonTX2-98XX" },
+ { 0x0b2, "OcteonTX2-96XX" },
+ { 0x0b3, "OcteonTX2-95XX" },
+ { 0x0b4, "OcteonTX2-95XXN" },
+ { 0x0b5, "OcteonTX2-95XXMM" },
+ { 0x0b6, "OcteonTX2-95XXO" },
+ { 0x0b8, "ThunderX3-T110" },
{ -1, "unknown" },
};
@@ -121,8 +148,12 @@ static const struct id_part qcom_part[] = {
{ 0x201, "Kryo" },
{ 0x205, "Kryo" },
{ 0x211, "Kryo" },
- { 0x800, "Falkor V1/Kryo" },
- { 0x801, "Kryo V2" },
+ { 0x800, "Falkor-V1/Kryo" },
+ { 0x801, "Kryo-V2" },
+ { 0x802, "Kryo-3XX-Gold" },
+ { 0x803, "Kryo-3XX-Silver" },
+ { 0x804, "Kryo-4XX-Gold" },
+ { 0x805, "Kryo-4XX-Silver" },
{ 0xc00, "Falkor" },
{ 0xc01, "Saphira" },
{ -1, "unknown" },
@@ -130,6 +161,9 @@ static const struct id_part qcom_part[] = {
static const struct id_part samsung_part[] = {
{ 0x001, "exynos-m1" },
+ { 0x002, "exynos-m3" },
+ { 0x003, "exynos-m4" },
+ { 0x004, "exynos-m5" },
{ -1, "unknown" },
};
@@ -141,12 +175,52 @@ static const struct id_part nvidia_part[] = {
};
static const struct id_part marvell_part[] = {
- { 0x131, "Feroceon 88FR131" },
+ { 0x131, "Feroceon-88FR131" },
{ 0x581, "PJ4/PJ4b" },
{ 0x584, "PJ4B-MP" },
{ -1, "unknown" },
};
+static const struct id_part apple_part[] = {
+ { 0x000, "Swift" },
+ { 0x001, "Cyclone" },
+ { 0x002, "Typhoon" },
+ { 0x003, "Typhoon/Capri" },
+ { 0x004, "Twister" },
+ { 0x005, "Twister/Elba/Malta" },
+ { 0x006, "Hurricane" },
+ { 0x007, "Hurricane/Myst" },
+ { 0x008, "Monsoon" },
+ { 0x009, "Mistral" },
+ { 0x00b, "Vortex" },
+ { 0x00c, "Tempest" },
+ { 0x00f, "Tempest-M9" },
+ { 0x010, "Vortex/Aruba" },
+ { 0x011, "Tempest/Aruba" },
+ { 0x012, "Lightning" },
+ { 0x013, "Thunder" },
+ { 0x020, "Icestorm-A14" },
+ { 0x021, "Firestorm-A14" },
+ { 0x022, "Icestorm-M1" },
+ { 0x023, "Firestorm-M1" },
+ { 0x024, "Icestorm-M1-Pro" },
+ { 0x025, "Firestorm-M1-Pro" },
+ { 0x026, "Thunder-M10" },
+ { 0x028, "Icestorm-M1-Max" },
+ { 0x029, "Firestorm-M1-Max" },
+ { 0x030, "Blizzard-A15" },
+ { 0x031, "Avalanche-A15" },
+ { 0x032, "Blizzard-M2" },
+ { 0x033, "Avalanche-M2" },
+ { 0x034, "Blizzard-M2-Pro" },
+ { 0x035, "Avalanche-M2-Pro" },
+ { 0x036, "Sawtooth-A16" },
+ { 0x037, "Everest-A16" },
+ { 0x038, "Blizzard-M2-Max" },
+ { 0x039, "Avalanche-M2-Max" },
+ { -1, "unknown" },
+};
+
static const struct id_part faraday_part[] = {
{ 0x526, "FA526" },
{ 0x626, "FA626" },
@@ -185,12 +259,21 @@ static const struct id_part fujitsu_part[] = {
static const struct id_part hisi_part[] = {
{ 0xd01, "Kunpeng-920" }, /* aka tsv110 */
+ { 0xd40, "Cortex-A76" }, /* HiSilicon uses this ID though advertises A76 */
+ { -1, "unknown" },
+};
+
+static const struct id_part ampere_part[] = {
+ { 0xac3, "Ampere-1" },
+ { 0xac4, "Ampere-1a" },
{ -1, "unknown" },
};
static const struct id_part ft_part[] = {
- { 0x662, "FT-2000+" },
- { 0x663, "S2500" },
+ { 0x660, "FTC660" },
+ { 0x661, "FTC661" },
+ { 0x662, "FTC662" },
+ { 0x663, "FTC663" },
{ -1, "unknown" },
};
@@ -218,11 +301,11 @@ static const struct hw_impl hw_implementer[] = {
{ 0x51, qcom_part, "Qualcomm" },
{ 0x53, samsung_part, "Samsung" },
{ 0x56, marvell_part, "Marvell" },
- { 0x61, unknown_part, "Apple" },
+ { 0x61, apple_part, "Apple" },
{ 0x66, faraday_part, "Faraday" },
{ 0x69, intel_part, "Intel" },
{ 0x70, ft_part, "Phytium" },
- { 0xc0, unknown_part, "Ampere" },
+ { 0xc0, ampere_part, "Ampere" },
{ -1, unknown_part, "unknown" },
};
--
2.40.1

@ -0,0 +1,84 @@
From 6275861012e63828a3c43b3acacb4dd623af848d Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Wed, 9 Aug 2023 13:30:49 +0200
Subject: libuuid: backport cache handling from upstream
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2189947
Upstream: http://github.com/util-linux/util-linux/commit/104dc2e092058489a4be17d5b15902e58ca56804
Upstream: http://github.com/util-linux/util-linux/commit/2fa4168c8bc9d5438bc1dfadda293c7c21b6fa59
Signed-off-by: Karel Zak <kzak@redhat.com>
---
libuuid/src/gen_uuid.c | 33 ++++++++++++++++++++++++++++-----
1 file changed, 28 insertions(+), 5 deletions(-)
diff --git a/libuuid/src/gen_uuid.c b/libuuid/src/gen_uuid.c
index f05db467e..619ef0131 100644
--- a/libuuid/src/gen_uuid.c
+++ b/libuuid/src/gen_uuid.c
@@ -528,18 +528,37 @@ int __uuid_generate_time_cont(uuid_t out, int *num, uint32_t cont_offset)
*/
static int uuid_generate_time_generic(uuid_t out) {
#ifdef HAVE_TLS
+ /* thread local cache for uuidd based requests */
+ const int cs_min = (1<<6);
+ const int cs_max = (1<<18);
+ const int cs_factor = 2;
THREAD_LOCAL int num = 0;
+ THREAD_LOCAL int cache_size = cs_min;
+ THREAD_LOCAL int last_used = 0;
THREAD_LOCAL struct uuid uu;
THREAD_LOCAL time_t last_time = 0;
time_t now;
- if (num > 0) {
+ if (num > 0) { /* expire cache */
now = time(NULL);
- if (now > last_time+1)
+ if (now > last_time+1) {
+ last_used = cache_size - num;
num = 0;
+ }
}
- if (num <= 0) {
- num = 1000;
+ if (num <= 0) { /* fill cache */
+ /*
+ * num + OP_BULK provides a local cache in each application.
+ * Start with a small cache size to cover short running applications
+ * and adjust the cache size over the runntime.
+ */
+ if ((last_used == cache_size) && (cache_size < cs_max))
+ cache_size *= cs_factor;
+ else if ((last_used < (cache_size / cs_factor)) && (cache_size > cs_min))
+ cache_size /= cs_factor;
+
+ num = cache_size;
+
if (get_uuid_via_daemon(UUIDD_OP_BULK_TIME_UUID,
out, &num) == 0) {
last_time = time(NULL);
@@ -547,9 +566,11 @@ static int uuid_generate_time_generic(uuid_t out) {
num--;
return 0;
}
+ /* request to daemon failed, reset cache */
num = 0;
+ cache_size = cs_min;
}
- if (num > 0) {
+ if (num > 0) { /* serve uuid from cache */
uu.time_low++;
if (uu.time_low == 0) {
uu.time_mid++;
@@ -558,6 +579,8 @@ static int uuid_generate_time_generic(uuid_t out) {
}
num--;
uuid_pack(&uu, out);
+ if (num == 0)
+ last_used = cache_size;
return 0;
}
#else
--
2.40.1

@ -0,0 +1,60 @@
From 3c494ecb0ed4c49b5843d458c0b487aee5d25963 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Wed, 9 Aug 2023 13:39:32 +0200
Subject: zramctl: add hint about supported algorithms
It seems the current list of the algorithms is confusing for
end-users, because it's inaccurate in many cases. Let's explain why
the list cannot be "perfect".
Upstream: http://github.com/util-linux/util-linux/commit/2d7549b79f2b32f33cec3a5b518cddfe9a63506b
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2203324
Signed-off-by: Karel Zak <kzak@redhat.com>
---
sys-utils/zramctl.8.adoc | 4 +++-
sys-utils/zramctl.c | 6 +++++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/sys-utils/zramctl.8.adoc b/sys-utils/zramctl.8.adoc
index 7b684ed44..ff83b6ec9 100644
--- a/sys-utils/zramctl.8.adoc
+++ b/sys-utils/zramctl.8.adoc
@@ -38,8 +38,10 @@ Note that _zramdev_ node specified on command line has to already exist. The com
== OPTIONS
-*-a*, **--algorithm lzo**|**lz4**|**lz4hc**|**deflate**|*842*::
+*-a*, **--algorithm lzo**|**lz4**|**lz4hc**|**deflate**|**842**|**zstd**::
Set the compression algorithm to be used for compressing data in the zram device.
++
+The *list of supported algorithms could be inaccurate* as it depends on the current kernel configuration. A basic overview can be obtained by using the command "cat /sys/block/zram0/comp_algorithm"; however, please note that this list might also be incomplete. This is due to the fact that ZRAM utilizes the Crypto API, and if certain algorithms were built as modules, it becomes impossible to enumerate all of them.
*-f*, *--find*::
Find the first unused zram device. If a *--size* argument is present, then initialize the device.
diff --git a/sys-utils/zramctl.c b/sys-utils/zramctl.c
index 64d5fcd81..a84ce665b 100644
--- a/sys-utils/zramctl.c
+++ b/sys-utils/zramctl.c
@@ -547,7 +547,7 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_("Set up and control zram devices.\n"), out);
fputs(USAGE_OPTIONS, out);
- fputs(_(" -a, --algorithm lzo|lz4|lz4hc|deflate|842 compression algorithm to use\n"), out);
+ fputs(_(" -a, --algorithm <alg> compression algorithm to use\n"), out);
fputs(_(" -b, --bytes print sizes in bytes rather than in human readable format\n"), out);
fputs(_(" -f, --find find a free device\n"), out);
fputs(_(" -n, --noheadings don't print headings\n"), out);
@@ -564,6 +564,10 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(USAGE_ARGUMENTS, out);
printf(USAGE_ARG_SIZE(_("<size>")));
+ fputs(_(" <alg> specify algorithm, supported are:\n"), out);
+ fputs(_(" lzo, lz4, lz4hc, deflate, 842 and zstd\n"), out);
+ fputs(_(" (List may be inaccurate, consult man page.)\n"), out);
+
fputs(USAGE_COLUMNS, out);
for (i = 0; i < ARRAY_SIZE(infos); i++)
fprintf(out, " %11s %s\n", infos[i].name, _(infos[i].help));
--
2.40.1

@ -0,0 +1,28 @@
From 71e5eb4208ff6692e6bf93c74f1737ce26ea9ef0 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 23 May 2023 11:34:19 +0200
Subject: fstab: add hint about systemd reload
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2209267
Upstream: http://github.com/util-linux/util-linux/commit/9105d3cdd819a499f5029d1009952acf6f51b7d9
Signed-off-by: Karel Zak <kzak@redhat.com>
---
sys-utils/fstab.5.adoc | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sys-utils/fstab.5.adoc b/sys-utils/fstab.5.adoc
index 332d74611..f3647fc6e 100644
--- a/sys-utils/fstab.5.adoc
+++ b/sys-utils/fstab.5.adoc
@@ -52,6 +52,8 @@ _/etc/fstab_
The file *fstab* contains descriptive information about the filesystems the system can mount. *fstab* is only read by programs, and not written; it is the duty of the system administrator to properly create and maintain this file. The order of records in *fstab* is important because *fsck*(8), *mount*(8), and *umount*(8) sequentially iterate through *fstab* doing their thing.
+The file is not read by *mount*(8) only but often is used by many other tools and daemons, and proper functionality may require additional steps. For example, on systemd-based systems, it's recommended to use 'systemctl daemon-reload' after *fstab* modification.
+
Each filesystem is described on a separate line. Fields on each line are separated by tabs or spaces. Lines starting with '#' are comments. Blank lines are ignored.
The following is a typical example of an *fstab* entry:
--
2.40.1

@ -0,0 +1,39 @@
From 2ab525d0cf6f4043e49e070040ec2fb67274ffe8 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Wed, 9 Aug 2023 13:51:03 +0200
Subject: sfdisk: add hint about duplicate UUIDs when use dump
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2215082
Upstream: http://github.com/util-linux/util-linux/commit/60c81b3272d03959dfee465f1ecaf40ba3e70cb3
Signed-off-by: Karel Zak <kzak@redhat.com>
---
disk-utils/sfdisk.8.adoc | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/disk-utils/sfdisk.8.adoc b/disk-utils/sfdisk.8.adoc
index 091e59120..8a457c969 100644
--- a/disk-utils/sfdisk.8.adoc
+++ b/disk-utils/sfdisk.8.adoc
@@ -342,6 +342,8 @@ creates empty GPT partition table. Note that the *--append* disables this featur
It is recommended to save the layout of your devices. *sfdisk* supports two ways.
+=== Dump in sfdisk compatible format
+
Use the *--dump* option to save a description of the device layout to a text file. The dump format is suitable for later *sfdisk* input. For example:
____
@@ -354,6 +356,10 @@ ____
*sfdisk /dev/sda < sda.dump*
____
+Note that sfdisk completely restores partition types and partition UUIDs. This could potentially become problematic if you duplicate the same layout to different disks, as it may result in duplicate UUIDs within your system.
+
+=== Full binary backup
+
If you want to do a full (binary) backup of all sectors where the partition table is stored, then use the *--backup* option. It writes the sectors to _~/sfdisk-<device>-<offset>.bak_ files. The default name of the backup file can be changed with the *--backup-file* option. The backup files contain only raw data from the _device_. Note that the same concept of backup files is used by *wipefs*(8). For example:
____
--
2.40.1

@ -0,0 +1,162 @@
From fe0b5c21d440ec00c5cba9b1c862aa189edc4446 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Thu, 10 Aug 2023 11:15:29 +0200
Subject: tests: don't write mount hint to terminal
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2180414
Upstream: http://github.com/util-linux/util-linux/commit/4b9e3937966f7ddf90e6013c87f73c260963b0ea
Upstream: http://github.com/util-linux/util-linux/commit/ebbb108c5d1cb7c6a28671f2973fb706a35eacae
Signed-off-by: Karel Zak <kzak@redhat.com>
---
tests/ts/eject/umount | 10 +++++-----
tests/ts/mount/fstab-btrfs | 2 +-
tests/ts/mount/move | 2 +-
tests/ts/mount/remount | 9 +++++----
tests/ts/mount/shared-subtree | 2 +-
tests/ts/mount/umount-alltargets | 6 +++---
tests/ts/mount/umount-recursive | 4 ++--
7 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/tests/ts/eject/umount b/tests/ts/eject/umount
index 04f53ed99..6cbf12671 100755
--- a/tests/ts/eject/umount
+++ b/tests/ts/eject/umount
@@ -82,7 +82,7 @@ init_device
mkfs.ext2 -q -F $TS_DEVICE
udevadm settle
mkdir -p $TS_MOUNTPOINT
-$TS_CMD_MOUNT $TS_DEVICE $TS_MOUNTPOINT
+$TS_CMD_MOUNT $TS_DEVICE $TS_MOUNTPOINT &> /dev/null
udevadm settle
$TS_CMD_EJECT --force $TS_DEVICE && ts_log "Success"
deinit_device
@@ -94,8 +94,8 @@ init_device
init_partitions $TS_DEVICE
mkdir -p ${TS_MOUNTPOINT}1
mkdir -p ${TS_MOUNTPOINT}2
-$TS_CMD_MOUNT ${TS_DEVICE}1 ${TS_MOUNTPOINT}1
-$TS_CMD_MOUNT ${TS_DEVICE}2 ${TS_MOUNTPOINT}2
+$TS_CMD_MOUNT ${TS_DEVICE}1 ${TS_MOUNTPOINT}1 &> /dev/null
+$TS_CMD_MOUNT ${TS_DEVICE}2 ${TS_MOUNTPOINT}2 &> /dev/null
udevadm settle
$TS_CMD_EJECT --force $TS_DEVICE && ts_log "Success"
deinit_device
@@ -115,8 +115,8 @@ init_device
init_partitions $TS_DEVICE
mkdir -p ${TS_MOUNTPOINT}1
mkdir -p ${TS_MOUNTPOINT}2
-$TS_CMD_MOUNT ${TS_DEVICE}1 ${TS_MOUNTPOINT}1
-$TS_CMD_MOUNT ${TS_DEVICE}2 ${TS_MOUNTPOINT}2
+$TS_CMD_MOUNT ${TS_DEVICE}1 ${TS_MOUNTPOINT}1 &> /dev/null
+$TS_CMD_MOUNT ${TS_DEVICE}2 ${TS_MOUNTPOINT}2 &> /dev/null
udevadm settle
$TS_CMD_EJECT --force ${TS_DEVICE}1 && ts_log "Success"
deinit_device
diff --git a/tests/ts/mount/fstab-btrfs b/tests/ts/mount/fstab-btrfs
index 0003b5d65..dff707047 100755
--- a/tests/ts/mount/fstab-btrfs
+++ b/tests/ts/mount/fstab-btrfs
@@ -51,7 +51,7 @@ DEVICE=$TS_LODEV
[ -d "$TS_MOUNTPOINT_BIND" ] || mkdir -p "$TS_MOUNTPOINT_BIND"
mkfs.btrfs -d single -m single $DEVICE &> /dev/null || ts_die "Cannot make btrfs on $DEVICE"
-$TS_CMD_MOUNT -o loop "$DEVICE" "$TS_MOUNTPOINT_CREATE"
+$TS_CMD_MOUNT -o loop "$DEVICE" "$TS_MOUNTPOINT_CREATE" &> /dev/null
pushd . >/dev/null
cd "$TS_MOUNTPOINT_CREATE"
mkdir -p d0/dd0/ddd0
diff --git a/tests/ts/mount/move b/tests/ts/mount/move
index 9d2723a75..198732c4e 100755
--- a/tests/ts/mount/move
+++ b/tests/ts/mount/move
@@ -32,7 +32,7 @@ function mount_and_check {
# last arg must be an existing or to-be-mounted mountpoint
local mountpoint="${@: -1}"
- $TS_CMD_MOUNT "$@" \
+ $TS_CMD_MOUNT "$@" &> /dev/null \
|| ts_die "error: mount $*"
$TS_CMD_MOUNTPOINT -q "$mountpoint" \
diff --git a/tests/ts/mount/remount b/tests/ts/mount/remount
index 38db9bf9f..69fbf1815 100755
--- a/tests/ts/mount/remount
+++ b/tests/ts/mount/remount
@@ -43,15 +43,16 @@ fi
mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE"
# mount read-write
-$TS_CMD_MOUNT $DEVICE $TS_MOUNTPOINT || ts_die "Cannot mount $TS_MOUNTPOINT"
+$TS_CMD_MOUNT $DEVICE $TS_MOUNTPOINT &> /dev/null \
+ || ts_die "Cannot mount $TS_MOUNTPOINT"
# check the mount
egrep -q "^$DEVICE $TS_MOUNTPOINT" $MTAB_FILE \
- || ts_die "Cannot find $TS_MOUNTPOINT in $MTAB_FILE"
+ || ts_die "Cannot find $TS_MOUNTPOINT in $MTAB_FILE"
# remount
-$TS_CMD_MOUNT -o remount,ro $TS_MOUNTPOINT \
- || ts_die "Cannot remount $TS_MOUNTPOINT"
+$TS_CMD_MOUNT -o remount,ro $TS_MOUNTPOINT &> /dev/null \
+ || ts_die "Cannot remount $TS_MOUNTPOINT"
# check the remount
$TS_CMD_FINDMNT --kernel --mountpoint "$TS_MOUNTPOINT" --options "ro" &> /dev/null
diff --git a/tests/ts/mount/shared-subtree b/tests/ts/mount/shared-subtree
index 44b460b57..cb43ade57 100755
--- a/tests/ts/mount/shared-subtree
+++ b/tests/ts/mount/shared-subtree
@@ -17,7 +17,7 @@ ts_check_prog "mkfs.ext2"
[ -d $TS_MOUNTPOINT ] || mkdir -p $TS_MOUNTPOINT
# bind
-$TS_CMD_MOUNT --bind $TS_MOUNTPOINT $TS_MOUNTPOINT
+$TS_CMD_MOUNT --bind $TS_MOUNTPOINT $TS_MOUNTPOINT &> /dev/null
[ "$?" = "0" ] || ts_die "error: mount --bind"
# check the bind
diff --git a/tests/ts/mount/umount-alltargets b/tests/ts/mount/umount-alltargets
index 37a163d87..83a04bafe 100755
--- a/tests/ts/mount/umount-alltargets
+++ b/tests/ts/mount/umount-alltargets
@@ -112,11 +112,11 @@ ts_finalize_subtest
ts_init_subtest "all-targets-recursive"
multi_mount ${TS_DEVICE}1 $MOUNTPOINT
[ -d "${MOUNTPOINT}1/subA" ] || mkdir -p ${MOUNTPOINT}1/subA
-$TS_CMD_MOUNT ${TS_DEVICE}2 ${MOUNTPOINT}1/subA
+$TS_CMD_MOUNT ${TS_DEVICE}2 ${MOUNTPOINT}1/subA &> /dev/null
[ -d "${MOUNTPOINT}1/subA/subAB" ] || mkdir -p ${MOUNTPOINT}1/subA/subAB
-$TS_CMD_MOUNT ${TS_DEVICE}3 ${MOUNTPOINT}1/subA/subAB
+$TS_CMD_MOUNT ${TS_DEVICE}3 ${MOUNTPOINT}1/subA/subAB &> /dev/null
[ -d "${MOUNTPOINT}1/subB" ] || mkdir -p ${MOUNTPOINT}1/subB
-$TS_CMD_MOUNT ${TS_DEVICE}4 ${MOUNTPOINT}1/subB
+$TS_CMD_MOUNT ${TS_DEVICE}4 ${MOUNTPOINT}1/subB &> /dev/null
$TS_CMD_UMOUNT --recursive --all-targets ${TS_DEVICE}1 >> $TS_OUTPUT 2>> $TS_ERRLOG
[ $? == 0 ] || ts_log "umount failed"
ts_finalize_subtest
diff --git a/tests/ts/mount/umount-recursive b/tests/ts/mount/umount-recursive
index 700c58c12..3e1d66327 100755
--- a/tests/ts/mount/umount-recursive
+++ b/tests/ts/mount/umount-recursive
@@ -67,7 +67,7 @@ ts_log "Do tests..."
ts_log "A) Mount root"
$TS_CMD_MOUNT ${TS_DEVICE}1 $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
-$TS_CMD_MOUNT --make-shared $TS_MOUNTPOINT
+$TS_CMD_MOUNT --make-shared $TS_MOUNTPOINT &> /dev/null
ts_log "B) Mount child"
mkdir -p $TS_MOUNTPOINT/mntB
@@ -86,7 +86,7 @@ $TS_CMD_MOUNT ${TS_DEVICE}4 $TS_MOUNTPOINT/mntB/mntD >> $TS_OUTPUT 2>> $TS_ERRLO
ts_log "E) Mount child-bind"
mkdir -p $TS_MOUNTPOINT/bindC
-$TS_CMD_MOUNT --bind $TS_MOUNTPOINT/mntB/mntC $TS_MOUNTPOINT/bindC
+$TS_CMD_MOUNT --bind $TS_MOUNTPOINT/mntB/mntC $TS_MOUNTPOINT/bindC &> /dev/null
udevadm settle
$TS_CMD_UMOUNT --recursive $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
--
2.40.1

@ -1,4 +1,5 @@
#%PAM-1.0 #%PAM-1.0
auth required pam_env.so
auth sufficient pam_rootok.so auth sufficient pam_rootok.so
# Uncomment the following line to implicitly trust users in the "wheel" group. # Uncomment the following line to implicitly trust users in the "wheel" group.
#auth sufficient pam_wheel.so trust use_uid #auth sufficient pam_wheel.so trust use_uid

@ -0,0 +1 @@
d /run/uuidd 2775 uuidd uuidd

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save