From 79e40e68edffb375d12392d1e172c1bf7e45f3d4 Mon Sep 17 00:00:00 2001 From: basebuilder_pel7ppc64bebuilder0 Date: Thu, 17 May 2018 19:13:29 +0200 Subject: [PATCH] util linux patches Signed-off-by: basebuilder_pel7ppc64bebuilder0 --- ...mount-cleanup-fs-root-detection-code.patch | 200 ++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100644 SOURCES/0072-libmount-cleanup-fs-root-detection-code.patch diff --git a/SOURCES/0072-libmount-cleanup-fs-root-detection-code.patch b/SOURCES/0072-libmount-cleanup-fs-root-detection-code.patch new file mode 100644 index 00000000..3df456d1 --- /dev/null +++ b/SOURCES/0072-libmount-cleanup-fs-root-detection-code.patch @@ -0,0 +1,200 @@ +From bb3483bf21b9cbe462caaa74fbc03d2eb7845d74 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Tue, 10 Mar 2015 13:35:56 +0100 +Subject: [PATCH 72/84] libmount: cleanup fs root detection code + +Upstream: http://github.com/karelzak/util-linux/commit/cc06a01ec551ed2bcd397a5097165b4434179b34 +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=587393 +Signed-off-by: Karel Zak +--- + libmount/src/tab.c | 32 ++++++++++++++++++++----- + libmount/src/utils.c | 34 --------------------------- + tests/expected/libmount/utils-fs-root | 1 - + tests/expected/libmount/utils-fs-root-subdir | 1 - + tests/expected/libmount/utils-fs-root-subdir2 | 1 - + tests/ts/libmount/utils | 12 ---------- + 6 files changed, 26 insertions(+), 55 deletions(-) + delete mode 100644 tests/expected/libmount/utils-fs-root + delete mode 100644 tests/expected/libmount/utils-fs-root-subdir + delete mode 100644 tests/expected/libmount/utils-fs-root-subdir2 + +diff --git a/libmount/src/tab.c b/libmount/src/tab.c +index 1ba1eec..10ee7ce 100644 +--- a/libmount/src/tab.c ++++ b/libmount/src/tab.c +@@ -46,6 +46,8 @@ + #include "mountP.h" + #include "strutils.h" + #include "loopdev.h" ++#include "fileutils.h" ++#include "canonicalize.h" + + static int is_mountinfo(struct libmnt_table *tb); + +@@ -900,6 +902,20 @@ struct libmnt_fs *mnt_table_find_devno(struct libmnt_table *tb, + return NULL; + } + ++static char *remove_mountpoint_from_path(const char *path, const char *mnt) ++{ ++ char *res; ++ const char *p; ++ size_t sz; ++ ++ sz = strlen(mnt); ++ p = sz > 1 ? path + sz : path; ++ ++ res = *p ? strdup(p) : strdup("/"); ++ DBG(UTILS, mnt_debug("%s fs-root is %s", path, res)); ++ return res; ++} ++ + /* + * tb: /proc/self/mountinfo + * fs: filesystem +@@ -919,7 +935,8 @@ struct libmnt_fs *mnt_table_get_fs_root(struct libmnt_table *tb, + unsigned long mountflags, + char **fsroot) + { +- char *root = NULL, *mnt = NULL; ++ char *root = NULL; ++ const char *mnt = NULL; + const char *fstype; + struct libmnt_fs *src_fs = NULL; + +@@ -937,10 +954,15 @@ struct libmnt_fs *mnt_table_get_fs_root(struct libmnt_table *tb, + DBG(TAB, mnt_debug("fs-root for bind")); + + src = xsrc = mnt_resolve_spec(mnt_fs_get_source(fs), tb->cache); +- if (src) +- mnt = mnt_get_mountpoint(src); ++ if (src) { ++ struct libmnt_fs *fs = mnt_table_find_mountpoint(tb, ++ src, MNT_ITER_BACKWARD); ++ if (fs) ++ mnt = mnt_fs_get_target(fs); ++ } ++ + if (mnt) +- root = mnt_get_fs_root(src, mnt); ++ root = remove_mountpoint_from_path(src, mnt); + + if (xsrc && !tb->cache) { + free(xsrc); +@@ -1007,11 +1029,9 @@ dflt: + + DBG(TAB, mnt_debug("FS root result: %s", root)); + +- free(mnt); + return src_fs; + err: + free(root); +- free(mnt); + return NULL; + } + +diff --git a/libmount/src/utils.c b/libmount/src/utils.c +index 5783d88..2151ff9 100644 +--- a/libmount/src/utils.c ++++ b/libmount/src/utils.c +@@ -908,28 +908,6 @@ err: + return NULL; + } + +-char *mnt_get_fs_root(const char *path, const char *mnt) +-{ +- char *m = (char *) mnt, *res; +- const char *p; +- size_t sz; +- +- if (!m) +- m = mnt_get_mountpoint(path); +- if (!m) +- return NULL; +- +- sz = strlen(m); +- p = sz > 1 ? path + sz : path; +- +- if (m != mnt) +- free(m); +- +- res = *p ? strdup(p) : strdup("/"); +- DBG(UTILS, mnt_debug("%s fs-root is %s", path, res)); +- return res; +-} +- + /* + * Search for @name kernel command parametr. + * +@@ -1085,17 +1063,6 @@ int test_mountpoint(struct libmnt_test *ts, int argc, char *argv[]) + return 0; + } + +-int test_fsroot(struct libmnt_test *ts, int argc, char *argv[]) +-{ +- char *path = canonicalize_path(argv[1]), +- *mnt = path ? mnt_get_fs_root(path, NULL) : NULL; +- +- printf("%s: %s\n", argv[1], mnt ? : "unknown"); +- free(mnt); +- free(path); +- return 0; +-} +- + int test_filesystems(struct libmnt_test *ts, int argc, char *argv[]) + { + char **filesystems = NULL; +@@ -1170,7 +1137,6 @@ int main(int argc, char *argv[]) + { "--starts-with", test_startswith, " " }, + { "--ends-with", test_endswith, " " }, + { "--mountpoint", test_mountpoint, "" }, +- { "--fs-root", test_fsroot, "" }, + { "--cd-parent", test_chdir, "" }, + { "--kernel-cmdline",test_kernel_cmdline, "