2.35-0.1: upgrade to usptream release
This commit is contained in:
parent
707076abd5
commit
42ab31a080
1
.gitignore
vendored
1
.gitignore
vendored
@ -71,3 +71,4 @@
|
||||
/util-linux-2.34-rc1.tar.xz
|
||||
/util-linux-2.34-rc2.tar.xz
|
||||
/util-linux-2.34.tar.xz
|
||||
/util-linux-2.35-rc1.tar.xz
|
||||
|
@ -1,383 +0,0 @@
|
||||
From 32fe4f1dd8fbc104bd848e24de613122947f095a Mon Sep 17 00:00:00 2001
|
||||
From: Karel Zak <kzak@redhat.com>
|
||||
Date: Wed, 28 Aug 2019 15:47:16 +0200
|
||||
Subject: [PATCH] libmount: improve mountinfo reliability
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The standard way how we read mount table is not reliable because
|
||||
during the read() syscalls the table may be modified by some another
|
||||
process. The changes in the table is possible to detect by poll()
|
||||
event, and in this case it seems better to lseek to the begin of the file
|
||||
and read it again. It's expensive, but better than races...
|
||||
|
||||
This patch does not modify mountinfo parser, but it reads all file to
|
||||
memory (by read()+poll()) and than it creates memory stream
|
||||
from the buffer and use it rather than a regular file stream.
|
||||
|
||||
It means the parser is still possible to use for normal files
|
||||
(e.g. fstab) as well as for mountinfo and it's also portable to
|
||||
systems where for some reason is no fmemopen().
|
||||
|
||||
Addresses: https://github.com/systemd/systemd/issues/10872
|
||||
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1751447
|
||||
Upstream: http://github.com/karelzak/util-linux/commit/e4925f591c1bfb83719418b56b952830d15b77eb
|
||||
Upstream: http://github.com/karelzak/util-linux/commit/ee551c909f95437fd9fcd162f398c069d0ce9720
|
||||
Reported-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
|
||||
Signed-off-by: Karel Zak <kzak@redhat.com>
|
||||
---
|
||||
diff -up util-linux-2.34/configure.ac.kzak util-linux-2.34/configure.ac
|
||||
--- util-linux-2.34/configure.ac.kzak 2019-06-14 12:34:02.892209368 +0200
|
||||
+++ util-linux-2.34/configure.ac 2019-09-13 09:19:54.155419473 +0200
|
||||
@@ -466,6 +466,7 @@ AC_CHECK_FUNCS([ \
|
||||
err \
|
||||
errx \
|
||||
explicit_bzero \
|
||||
+ fmemopen \
|
||||
fsync \
|
||||
utimensat \
|
||||
getdomainname \
|
||||
diff -up util-linux-2.34/libmount/src/mountP.h.kzak util-linux-2.34/libmount/src/mountP.h
|
||||
--- util-linux-2.34/libmount/src/mountP.h.kzak 2019-05-09 14:15:40.637552762 +0200
|
||||
+++ util-linux-2.34/libmount/src/mountP.h 2019-09-13 09:19:54.155419473 +0200
|
||||
@@ -97,6 +97,7 @@ extern int mnt_valid_tagname(const char
|
||||
extern int append_string(char **a, const char *b);
|
||||
|
||||
extern const char *mnt_statfs_get_fstype(struct statfs *vfs);
|
||||
+extern int is_procfs_fd(int fd);
|
||||
extern int is_file_empty(const char *name);
|
||||
|
||||
extern int mnt_is_readonly(const char *path)
|
||||
@@ -121,6 +122,7 @@ extern void mnt_free_filesystems(char **
|
||||
|
||||
extern char *mnt_get_kernel_cmdline_option(const char *name);
|
||||
extern int mnt_stat_mountpoint(const char *target, struct stat *st);
|
||||
+extern FILE *mnt_get_procfs_memstream(int fd, char **membuf);
|
||||
|
||||
/* tab.c */
|
||||
extern int is_mountinfo(struct libmnt_table *tb);
|
||||
diff -up util-linux-2.34/libmount/src/tab_parse.c.kzak util-linux-2.34/libmount/src/tab_parse.c
|
||||
--- util-linux-2.34/libmount/src/tab_parse.c.kzak 2019-05-09 14:15:40.638552755 +0200
|
||||
+++ util-linux-2.34/libmount/src/tab_parse.c 2019-09-13 09:19:54.156419468 +0200
|
||||
@@ -698,15 +698,7 @@ static int kernel_fs_postparse(struct li
|
||||
return rc;
|
||||
}
|
||||
|
||||
-/**
|
||||
- * mnt_table_parse_stream:
|
||||
- * @tb: tab pointer
|
||||
- * @f: file stream
|
||||
- * @filename: filename used for debug and error messages
|
||||
- *
|
||||
- * Returns: 0 on success, negative number in case of error.
|
||||
- */
|
||||
-int mnt_table_parse_stream(struct libmnt_table *tb, FILE *f, const char *filename)
|
||||
+static int __table_parse_stream(struct libmnt_table *tb, FILE *f, const char *filename)
|
||||
{
|
||||
int rc = -1;
|
||||
int flags = 0;
|
||||
@@ -781,6 +773,40 @@ err:
|
||||
}
|
||||
|
||||
/**
|
||||
+ * mnt_table_parse_stream:
|
||||
+ * @tb: tab pointer
|
||||
+ * @f: file stream
|
||||
+ * @filename: filename used for debug and error messages
|
||||
+ *
|
||||
+ * Returns: 0 on success, negative number in case of error.
|
||||
+ */
|
||||
+int mnt_table_parse_stream(struct libmnt_table *tb, FILE *f, const char *filename)
|
||||
+{
|
||||
+ int fd, rc;
|
||||
+ FILE *memf = NULL;
|
||||
+ char *membuf = NULL;
|
||||
+
|
||||
+ /*
|
||||
+ * For /proc/#/{mountinfo,mount} we read all file to memory and use it
|
||||
+ * as memory stream. For more details see mnt_read_procfs_file().
|
||||
+ */
|
||||
+ if ((fd = fileno(f)) >= 0
|
||||
+ && (tb->fmt == MNT_FMT_GUESS ||
|
||||
+ tb->fmt == MNT_FMT_MOUNTINFO ||
|
||||
+ tb->fmt == MNT_FMT_MTAB)
|
||||
+ && is_procfs_fd(fd)
|
||||
+ && (memf = mnt_get_procfs_memstream(fd, &membuf))) {
|
||||
+
|
||||
+ rc = __table_parse_stream(tb, memf, filename);
|
||||
+ fclose(memf);
|
||||
+ free(membuf);
|
||||
+ } else
|
||||
+ rc = __table_parse_stream(tb, f, filename);
|
||||
+
|
||||
+ return rc;
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
* mnt_table_parse_file:
|
||||
* @tb: tab pointer
|
||||
* @filename: file
|
||||
@@ -795,18 +821,49 @@ err:
|
||||
int mnt_table_parse_file(struct libmnt_table *tb, const char *filename)
|
||||
{
|
||||
FILE *f;
|
||||
- int rc;
|
||||
+ int rc, fd = -1;
|
||||
|
||||
if (!filename || !tb)
|
||||
return -EINVAL;
|
||||
|
||||
- f = fopen(filename, "r" UL_CLOEXECSTR);
|
||||
+ /*
|
||||
+ * Try to use read()+poll() to realiably read all
|
||||
+ * /proc/#/{mount,mountinfo} file to memory
|
||||
+ */
|
||||
+ if (tb->fmt != MNT_FMT_SWAPS
|
||||
+ && strncmp(filename, "/proc/", 6) == 0) {
|
||||
+
|
||||
+ FILE *memf;
|
||||
+ char *membuf = NULL;
|
||||
+
|
||||
+ fd = open(filename, O_RDONLY|O_CLOEXEC);
|
||||
+ if (fd < 0) {
|
||||
+ rc = -errno;
|
||||
+ goto done;
|
||||
+ }
|
||||
+ memf = mnt_get_procfs_memstream(fd, &membuf);
|
||||
+ if (memf) {
|
||||
+ rc = __table_parse_stream(tb, memf, filename);
|
||||
+
|
||||
+ fclose(memf);
|
||||
+ free(membuf);
|
||||
+ close(fd);
|
||||
+ goto done;
|
||||
+ }
|
||||
+ /* else fallback to fopen/fdopen() */
|
||||
+ }
|
||||
+
|
||||
+ if (fd >= 0)
|
||||
+ f = fdopen(fd, "r" UL_CLOEXECSTR);
|
||||
+ else
|
||||
+ f = fopen(filename, "r" UL_CLOEXECSTR);
|
||||
+
|
||||
if (f) {
|
||||
- rc = mnt_table_parse_stream(tb, f, filename);
|
||||
+ rc = __table_parse_stream(tb, f, filename);
|
||||
fclose(f);
|
||||
} else
|
||||
rc = -errno;
|
||||
-
|
||||
+done:
|
||||
DBG(TAB, ul_debugobj(tb, "parsing done [filename=%s, rc=%d]", filename, rc));
|
||||
return rc;
|
||||
}
|
||||
@@ -863,7 +920,7 @@ static int __mnt_table_parse_dir(struct
|
||||
|
||||
f = fopen_at(dd, d->d_name, O_RDONLY|O_CLOEXEC, "r" UL_CLOEXECSTR);
|
||||
if (f) {
|
||||
- mnt_table_parse_stream(tb, f, d->d_name);
|
||||
+ __table_parse_stream(tb, f, d->d_name);
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
@@ -904,7 +961,7 @@ static int __mnt_table_parse_dir(struct
|
||||
f = fopen_at(dirfd(dir), d->d_name,
|
||||
O_RDONLY|O_CLOEXEC, "r" UL_CLOEXECSTR);
|
||||
if (f) {
|
||||
- mnt_table_parse_stream(tb, f, d->d_name);
|
||||
+ __table_parse_stream(tb, f, d->d_name);
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
diff -up util-linux-2.34/libmount/src/utils.c.kzak util-linux-2.34/libmount/src/utils.c
|
||||
--- util-linux-2.34/libmount/src/utils.c.kzak 2019-06-13 13:26:04.946525187 +0200
|
||||
+++ util-linux-2.34/libmount/src/utils.c 2019-09-13 09:19:54.157419462 +0200
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
+#include <poll.h>
|
||||
#include <blkid.h>
|
||||
|
||||
#include "strutils.h"
|
||||
@@ -424,6 +425,12 @@ const char *mnt_statfs_get_fstype(struct
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+int is_procfs_fd(int fd)
|
||||
+{
|
||||
+ struct statfs sfs;
|
||||
+
|
||||
+ return fstatfs(fd, &sfs) == 0 && sfs.f_type == STATFS_PROC_MAGIC;
|
||||
+}
|
||||
|
||||
/**
|
||||
* mnt_match_fstype:
|
||||
@@ -1140,8 +1147,158 @@ done:
|
||||
return 1;
|
||||
}
|
||||
|
||||
+#if defined(HAVE_FMEMOPEN) || defined(TEST_PROGRAM)
|
||||
+
|
||||
+/*
|
||||
+ * This function tries to minimize possible races when we read
|
||||
+ * /proc/#/{mountinfo,mount} files.
|
||||
+ *
|
||||
+ * The idea is to minimize number of read()s and check by poll() that during
|
||||
+ * the read the mount table has not been modified. If yes, than re-read it
|
||||
+ * (with some limitations to avoid never ending loop).
|
||||
+ *
|
||||
+ * Returns: <0 error, 0 success, 1 too many attempts
|
||||
+ */
|
||||
+static int read_procfs_file(int fd, char **buf, size_t *bufsiz)
|
||||
+{
|
||||
+ size_t bufmax = 0;
|
||||
+ int rc = 0, tries = 0, ninters = 0;
|
||||
+ char *bufptr = NULL;;
|
||||
+
|
||||
+ assert(buf);
|
||||
+ assert(bufsiz);
|
||||
+
|
||||
+ *bufsiz = 0;
|
||||
+ *buf = NULL;
|
||||
+
|
||||
+ do {
|
||||
+ ssize_t ret;
|
||||
+
|
||||
+ if (!bufptr || bufmax == *bufsiz) {
|
||||
+ char *tmp;
|
||||
+
|
||||
+ bufmax = bufmax ? bufmax * 2 : (16 * 1024);
|
||||
+ tmp = realloc(*buf, bufmax);
|
||||
+ if (!tmp)
|
||||
+ break;
|
||||
+ *buf = tmp;
|
||||
+ bufptr = tmp + *bufsiz;
|
||||
+ }
|
||||
+
|
||||
+ errno = 0;
|
||||
+ ret = read(fd, bufptr, bufmax - *bufsiz);
|
||||
+
|
||||
+ if (ret < 0) {
|
||||
+ /* error */
|
||||
+ if ((errno == EAGAIN || errno == EINTR) && (ninters++ < 5)) {
|
||||
+ xusleep(200000);
|
||||
+ continue;
|
||||
+ }
|
||||
+ break;
|
||||
+
|
||||
+ } else if (ret > 0) {
|
||||
+ /* success -- verify no event during read */
|
||||
+ struct pollfd fds[] = {
|
||||
+ { .fd = fd, .events = POLLPRI }
|
||||
+ };
|
||||
+
|
||||
+ rc = poll(fds, 1, 0);
|
||||
+ if (rc < 0)
|
||||
+ break; /* poll() error */
|
||||
+ if (rc > 0) {
|
||||
+ /* event -- read all again */
|
||||
+ if (lseek(fd, 0, SEEK_SET) != 0)
|
||||
+ break;
|
||||
+ *bufsiz = 0;
|
||||
+ bufptr = *buf;
|
||||
+ tries++;
|
||||
+
|
||||
+ if (tries > 10)
|
||||
+ /* busy system? -- wait */
|
||||
+ xusleep(10000);
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ /* successful read() without active poll() */
|
||||
+ (*bufsiz) += (size_t) ret;
|
||||
+ bufptr += ret;
|
||||
+ tries = ninters = 0;
|
||||
+ } else {
|
||||
+ /* end-of-file */
|
||||
+ goto success;
|
||||
+ }
|
||||
+ } while (tries <= 100);
|
||||
+
|
||||
+ rc = errno ? -errno : 1;
|
||||
+ free(*buf);
|
||||
+ return rc;
|
||||
+
|
||||
+success:
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * Create FILE stream for data from read_procfs_file()
|
||||
+ */
|
||||
+FILE *mnt_get_procfs_memstream(int fd, char **membuf)
|
||||
+{
|
||||
+ FILE *memf;
|
||||
+ size_t sz = 0;
|
||||
+ off_t cur;
|
||||
+
|
||||
+ /* in case of error, rewind to the original position */
|
||||
+ cur = lseek(fd, 0, SEEK_CUR);
|
||||
+
|
||||
+ if (read_procfs_file(fd, membuf, &sz) == 0
|
||||
+ && sz > 0
|
||||
+ && (memf = fmemopen(*membuf, sz, "r")))
|
||||
+ return memf;
|
||||
+
|
||||
+ /* error */
|
||||
+ lseek(fd, cur, SEEK_SET);
|
||||
+ return NULL;
|
||||
+}
|
||||
+#else
|
||||
+FILE *mnt_get_procfs_memstream(int fd __attribute((__unused__)),
|
||||
+ char **membuf __attribute((__unused__)))
|
||||
+{
|
||||
+ return NULL;
|
||||
+}
|
||||
+#endif /* HAVE_FMEMOPEN */
|
||||
+
|
||||
|
||||
#ifdef TEST_PROGRAM
|
||||
+static int test_proc_read(struct libmnt_test *ts, int argc, char *argv[])
|
||||
+{
|
||||
+ char *buf = NULL;
|
||||
+ char *filename = argv[1];
|
||||
+ size_t bufsiz = 0;
|
||||
+ int rc = 0, fd = open(filename, O_RDONLY);
|
||||
+
|
||||
+ if (fd <= 0) {
|
||||
+ warn("%s: cannot open", filename);
|
||||
+ return -errno;
|
||||
+ }
|
||||
+
|
||||
+ rc = read_procfs_file(fd, &buf, &bufsiz);
|
||||
+ close(fd);
|
||||
+
|
||||
+ switch (rc) {
|
||||
+ case 0:
|
||||
+ fwrite(buf, 1, bufsiz, stdout);
|
||||
+ free(buf);
|
||||
+ break;
|
||||
+ case 1:
|
||||
+ warnx("too many attempts");
|
||||
+ break;
|
||||
+ default:
|
||||
+ warn("%s: cannot read", filename);
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ return rc;
|
||||
+}
|
||||
+
|
||||
static int test_match_fstype(struct libmnt_test *ts, int argc, char *argv[])
|
||||
{
|
||||
char *type = argv[1];
|
||||
@@ -1323,6 +1480,7 @@ int main(int argc, char *argv[])
|
||||
{ "--guess-root", test_guess_root, "[<maj:min>]" },
|
||||
{ "--mkdir", test_mkdir, "<path>" },
|
||||
{ "--statfs-type", test_statfs_type, "<path>" },
|
||||
+ { "--read-procfs", test_proc_read, "<path>" },
|
||||
|
||||
{ NULL }
|
||||
};
|
@ -1,33 +0,0 @@
|
||||
From e3bb9bfb76c17b1d05814436ced62c05c4011f48 Mon Sep 17 00:00:00 2001
|
||||
From: Karel Zak <kzak@redhat.com>
|
||||
Date: Thu, 27 Jun 2019 09:22:18 +0200
|
||||
Subject: [PATCH] lsblk: force to print PKNAME for partition
|
||||
|
||||
PKNAME (parent kernel device name) is based on printed tree according
|
||||
to parent -> child relationship. The tree is optional and not printed
|
||||
if partition specified (.e.g "lsblk -o+PKNAME /dev/sda1"), but old
|
||||
versions print the PKNAME also in this case.
|
||||
|
||||
Addresses: https://github.com/karelzak/util-linux/issues/813
|
||||
Signed-off-by: Karel Zak <kzak@redhat.com>
|
||||
---
|
||||
misc-utils/lsblk.c | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c
|
||||
index e95af7af0..3ce6da730 100644
|
||||
--- a/misc-utils/lsblk.c
|
||||
+++ b/misc-utils/lsblk.c
|
||||
@@ -1019,6 +1019,9 @@ static void device_to_scols(
|
||||
DBG(DEV, ul_debugobj(dev, "add '%s' to scols", dev->name));
|
||||
ON_DBG(DEV, if (ul_path_isopen_dirfd(dev->sysfs)) ul_debugobj(dev, " %s ---> is open!", dev->name));
|
||||
|
||||
+ if (!parent && dev->wholedisk)
|
||||
+ parent = dev->wholedisk;
|
||||
+
|
||||
/* Do not print device more than one in --list mode */
|
||||
if (!(lsblk->flags & LSBLK_TREE) && dev->is_printed)
|
||||
return;
|
||||
--
|
||||
2.21.0
|
||||
|
2
sources
2
sources
@ -1 +1 @@
|
||||
SHA512 (util-linux-2.34.tar.xz) = 2d0b76f63d32e7afb7acf61a83fabbfd58baa34ab78b3a331ce87f9c676a5fd71c56a493ded95039540d2c46b6048caaa38d7fb4491eb3d52d7b09dc54655cd7
|
||||
SHA512 (util-linux-2.35-rc1.tar.xz) = 1ecf0b6868409dad4a2cc6e7fda708b8bea939f0c2a02b97068d114dac316a3d27c27542e2b220fc4ebef307d6c78b4f318685c1b7877429689f794cb2d4dc7a
|
||||
|
@ -1,13 +1,13 @@
|
||||
### Header
|
||||
Summary: A collection of basic system utilities
|
||||
Name: util-linux
|
||||
Version: 2.34
|
||||
Release: 6%{?dist}
|
||||
Version: 2.35
|
||||
Release: 0.1%{?dist}
|
||||
License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain
|
||||
URL: http://en.wikipedia.org/wiki/Util-linux
|
||||
|
||||
### Macros
|
||||
%define upstream_version %{version}
|
||||
%define upstream_version %{version}-rc1
|
||||
%define upstream_major %(eval echo %{version} | %{__sed} -e 's/\([[:digit:]]*\)\.\([[:digit:]]*\)\.[[:digit:]]*$/\1.\2/')
|
||||
|
||||
%define compldir %{_datadir}/bash-completion/completions/
|
||||
@ -106,11 +106,6 @@ Requires: libfdisk = %{version}-%{release}
|
||||
# 151635 - makeing /var/log/lastlog
|
||||
Patch0: 2.28-login-lastlog-create.patch
|
||||
|
||||
# 1751290 - regression: lsblk not showing PKNAME in f31+
|
||||
Patch1: lsblk-force-to-print-PKNAME-for-partition.patch
|
||||
# https://github.com/systemd/systemd/issues/10872
|
||||
Patch2: libmount-improve-mountinfo-reliability.patch
|
||||
|
||||
%description
|
||||
The util-linux package contains a large variety of low-level system
|
||||
utilities that are necessary for a Linux system to function. Among
|
||||
@ -564,6 +559,7 @@ fi
|
||||
%{_bindir}/rev
|
||||
%{_bindir}/script
|
||||
%{_bindir}/scriptreplay
|
||||
%{_bindir}/scriptlive
|
||||
%{_bindir}/setarch
|
||||
%{_bindir}/setpriv
|
||||
%{_bindir}/setsid
|
||||
@ -619,6 +615,7 @@ fi
|
||||
%{_mandir}/man1/runuser.1*
|
||||
%{_mandir}/man1/script.1*
|
||||
%{_mandir}/man1/scriptreplay.1*
|
||||
%{_mandir}/man1/scriptlive.1*
|
||||
%{_mandir}/man1/setpriv.1*
|
||||
%{_mandir}/man1/setsid.1*
|
||||
%{_mandir}/man1/setterm.1*
|
||||
@ -791,6 +788,7 @@ fi
|
||||
%{compldir}/runuser
|
||||
%{compldir}/script
|
||||
%{compldir}/scriptreplay
|
||||
%{compldir}/scriptlive
|
||||
%{compldir}/setarch
|
||||
%{compldir}/setpriv
|
||||
%{compldir}/setsid
|
||||
@ -934,6 +932,10 @@ fi
|
||||
%{_libdir}/python*/site-packages/libmount/
|
||||
|
||||
%changelog
|
||||
* Wed Dec 11 2019 Karel Zak <kzak@redhat.com> - 2.35-0.1
|
||||
- upgrade to v2.35-rc1
|
||||
https://www.kernel.org/pub/linux/utils/util-linux/v2.35/v2.35-ReleaseNotes
|
||||
|
||||
* Fri Sep 13 2019 Karel Zak <kzak@redhat.com> - 2.34-6
|
||||
- fix https://github.com/systemd/systemd/issues/10872
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user