From e4a5730eb358cb0d78bc022204ddccac068c2bf2 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 25 Feb 2012 23:15:06 +0000 Subject: Sat Feb 25 23:15:06 UTC 2012 --- testing/util-linux/PKGBUILD | 61 +++++++++++++ ...-canonicalize-always-remove-tailing-slash.patch | 37 ++++++++ ...bmount-canonicalize-all-paths-from-fs-tab.patch | 27 ++++++ ...anonicalize-targets-from-fstab-on-mount-a.patch | 55 +++++++++++ .../mount-new-cleanup-mount-a-return-codes.patch | 101 +++++++++++++++++++++ 5 files changed, 281 insertions(+) create mode 100644 testing/util-linux/PKGBUILD create mode 100644 testing/util-linux/lib-canonicalize-always-remove-tailing-slash.patch create mode 100644 testing/util-linux/libmount-canonicalize-all-paths-from-fs-tab.patch create mode 100644 testing/util-linux/libmount-canonicalize-targets-from-fstab-on-mount-a.patch create mode 100644 testing/util-linux/mount-new-cleanup-mount-a-return-codes.patch (limited to 'testing/util-linux') diff --git a/testing/util-linux/PKGBUILD b/testing/util-linux/PKGBUILD new file mode 100644 index 000000000..db0001a93 --- /dev/null +++ b/testing/util-linux/PKGBUILD @@ -0,0 +1,61 @@ +# $Id: PKGBUILD 151117 2012-02-25 00:42:27Z tomegun $ +# Maintainer: Tom Gundersen +# Contributor: judd + +pkgname=util-linux +pkgver=2.21 +pkgrel=2 +pkgdesc="Miscellaneous system utilities for Linux" +url="http://www.kernel.org/pub/linux/utils/util-linux/" +arch=('i686' 'x86_64') +groups=('base') +depends=('udev') +conflicts=('util-linux-ng') +provides=("util-linux-ng=${pkgver}") +license=('GPL2') +options=('!libtool') +source=(ftp://ftp.kernel.org/pub/linux/utils/${pkgname}/v${pkgver}/${pkgname}-${pkgver}.tar.xz + libmount-canonicalize-all-paths-from-fs-tab.patch + lib-canonicalize-always-remove-tailing-slash.patch + libmount-canonicalize-targets-from-fstab-on-mount-a.patch + mount-new-cleanup-mount-a-return-codes.patch) +optdepends=('perl: for chkdupexe support') + +build() { + cd "${srcdir}/${pkgname}-${pkgver}" + + # hardware clock + sed -e 's%etc/adjtime%var/lib/hwclock/adjtime%' -i include/pathnames.h + + patch -p1 -i ../libmount-canonicalize-all-paths-from-fs-tab.patch + patch -p1 -i ../lib-canonicalize-always-remove-tailing-slash.patch + patch -p1 -i ../libmount-canonicalize-targets-from-fstab-on-mount-a.patch + patch -p1 -i ../mount-new-cleanup-mount-a-return-codes.patch + + ./configure --prefix=/usr \ + --libdir=/usr/lib \ + --enable-write \ + --enable-raw \ + --disable-wall \ + --enable-new-mount + + make +} + +package() { + cd "${srcdir}/${pkgname}-${pkgver}" + + make DESTDIR="${pkgdir}" install + + cd "${pkgdir}" + + install -dm755 var/lib/hwclock + + # delete stray empty dir, fixed upstream + rm -r usr/share/man/ru +} +md5sums=('208aa058f4117759d2939d1be7d662fc' + 'c4011222a19b020d9b8465c3c7e443f6' + '8c1bf7b10e22e2b835441e6ae2d804d6' + '7b92423c588ed35229a9a166349c29a9' + 'c483ab2d52609b5857d096b256a5075c') diff --git a/testing/util-linux/lib-canonicalize-always-remove-tailing-slash.patch b/testing/util-linux/lib-canonicalize-always-remove-tailing-slash.patch new file mode 100644 index 000000000..3b830a2ad --- /dev/null +++ b/testing/util-linux/lib-canonicalize-always-remove-tailing-slash.patch @@ -0,0 +1,37 @@ +From 28074a0952469aebf021821d95238cfb964d13ff Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Fri, 24 Feb 2012 21:26:11 +0100 +Subject: [PATCH 09/12] lib/canonicalize: always remove tailing slash + +Signed-off-by: Karel Zak +--- + lib/canonicalize.c | 13 ++++++++++--- + 1 file changed, 10 insertions(+), 3 deletions(-) + +diff --git a/lib/canonicalize.c b/lib/canonicalize.c +index ab32c10..fd18af4 100644 +--- a/lib/canonicalize.c ++++ b/lib/canonicalize.c +@@ -174,9 +174,16 @@ canonicalize_path(const char *path) + if (path == NULL) + return NULL; + +- if (!myrealpath(path, canonical, PATH_MAX+1)) +- return strdup(path); +- ++ if (!myrealpath(path, canonical, PATH_MAX+1)) { ++ char *res = strdup(path); ++ if (res) { ++ p = strrchr(res, '/'); ++ /* delete trailing slash */ ++ if (p && p > res && *(p + 1) == '\0') ++ *p = '\0'; ++ } ++ return res; ++ } + + p = strrchr(canonical, '/'); + if (p && strncmp(p, "/dm-", 4) == 0 && isdigit(*(p + 4))) { +-- +1.7.9.2 + diff --git a/testing/util-linux/libmount-canonicalize-all-paths-from-fs-tab.patch b/testing/util-linux/libmount-canonicalize-all-paths-from-fs-tab.patch new file mode 100644 index 000000000..05961aa35 --- /dev/null +++ b/testing/util-linux/libmount-canonicalize-all-paths-from-fs-tab.patch @@ -0,0 +1,27 @@ +From 59e32a1f240c5f6a1d64d5e71a4a357245c34eaf Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Fri, 24 Feb 2012 20:25:43 +0100 +Subject: [PATCH 07/12] libmount: canonicalize all paths from (fs)tab + +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=797216 +Signed-off-by: Karel Zak +--- + libmount/src/tab.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libmount/src/tab.c b/libmount/src/tab.c +index 37f47bd..f10c1de 100644 +--- a/libmount/src/tab.c ++++ b/libmount/src/tab.c +@@ -456,7 +456,7 @@ struct libmnt_fs *mnt_table_find_target(struct libmnt_table *tb, const char *pat + while(mnt_table_next_fs(tb, &itr, &fs) == 0) { + char *p; + +- if (!fs->target || !mnt_fs_is_swaparea(fs) || ++ if (!fs->target || mnt_fs_is_swaparea(fs) || + (*fs->target == '/' && *(fs->target + 1) == '\0')) + continue; + +-- +1.7.9.2 + diff --git a/testing/util-linux/libmount-canonicalize-targets-from-fstab-on-mount-a.patch b/testing/util-linux/libmount-canonicalize-targets-from-fstab-on-mount-a.patch new file mode 100644 index 000000000..46ff55260 --- /dev/null +++ b/testing/util-linux/libmount-canonicalize-targets-from-fstab-on-mount-a.patch @@ -0,0 +1,55 @@ +From 6eba938376c2c870d9258ef9d7b6a3690cfa78dd Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Fri, 24 Feb 2012 22:52:45 +0100 +Subject: [PATCH 11/12] libmount: canonicalize targets from fstab on mount -a + +Signed-off-by: Karel Zak +--- + libmount/src/tab.c | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +diff --git a/libmount/src/tab.c b/libmount/src/tab.c +index 66a9e4d..21b05c7 100644 +--- a/libmount/src/tab.c ++++ b/libmount/src/tab.c +@@ -830,8 +830,8 @@ int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs) + { + char *root = NULL; + struct libmnt_fs *src_fs; +- const char *src, *tgt; +- char *xsrc = NULL; ++ const char *src; ++ char *xsrc = NULL, *tgt; + int flags = 0, rc = 0; + + assert(tb); +@@ -852,7 +852,7 @@ int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs) + src = xsrc = mnt_resolve_spec(mnt_fs_get_source(fstab_fs), + tb->cache); + +- tgt = mnt_fs_get_target(fstab_fs); ++ tgt = mnt_resolve_path(mnt_fs_get_target(fstab_fs), tb->cache); + + if (tgt && src && root) { + struct libmnt_iter itr; +@@ -870,7 +870,7 @@ int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs) + * network filesystem source paths. + */ + if (t && s && r && +- strcmp(t, tgt) == 0 && ++ streq_except_trailing_slash(t, tgt) && + streq_except_trailing_slash(s, src) && + strcmp(r, root) == 0) + break; +@@ -881,6 +881,8 @@ int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs) + + if (xsrc && !tb->cache) + free(xsrc); ++ if (!tb->cache) ++ free(tgt); + + free(root); + return rc; +-- +1.7.9.2 + diff --git a/testing/util-linux/mount-new-cleanup-mount-a-return-codes.patch b/testing/util-linux/mount-new-cleanup-mount-a-return-codes.patch new file mode 100644 index 000000000..274246416 --- /dev/null +++ b/testing/util-linux/mount-new-cleanup-mount-a-return-codes.patch @@ -0,0 +1,101 @@ +From 16b73aae8cb73df2974fd75c2a42ec3b92535851 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Fri, 24 Feb 2012 23:03:22 +0100 +Subject: [PATCH 12/12] mount: (new) cleanup mount -a return codes + +New return codes: + + 0 : all mounted (or all ignored) + 64 : some mounted, some failed + 32 : all failed + +Note that already mounted or ignored (filtered out by -t or -O) +filesystems don't affect the final return code. + +The original mount(8) returns 0 instead of 64, so the situation +"some mounted, some failed" cannot be detected. + +Signed-off-by: Karel Zak +--- + sys-utils/mount.8 | 4 ++++ + sys-utils/mount.c | 23 +++++++++++++++++------ + 2 files changed, 21 insertions(+), 6 deletions(-) + +diff --git a/sys-utils/mount.8 b/sys-utils/mount.8 +index f1cff74..d18881b 100644 +--- a/sys-utils/mount.8 ++++ b/sys-utils/mount.8 +@@ -2759,6 +2759,10 @@ mount failure + .TP + .BR 64 + some mount succeeded ++.RE ++ ++The command mount -a returns 0 (all success), 32 (all failed) or 64 (some ++failed, some success). + + .SH NOTES + The syntax of external mount helpers is: +diff --git a/sys-utils/mount.c b/sys-utils/mount.c +index 17991b0..3fbac04 100644 +--- a/sys-utils/mount.c ++++ b/sys-utils/mount.c +@@ -182,6 +182,8 @@ static int mount_all(struct libmnt_context *cxt) + struct libmnt_fs *fs; + int mntrc, ignored, rc = MOUNT_EX_SUCCESS; + ++ int nsucc = 0, nerrs = 0; ++ + itr = mnt_new_iter(MNT_ITER_FORWARD); + if (!itr) { + warn(_("failed to initialize libmount iterator")); +@@ -197,31 +199,40 @@ static int mount_all(struct libmnt_context *cxt) + printf(ignored == 1 ? _("%-25s: ignored\n") : + _("%-25s: already mounted\n"), + tgt); +- + } else if (mnt_context_is_fork(cxt)) { + if (mnt_context_is_verbose(cxt)) + printf("%-25s: mount successfully forked\n", tgt); + } else { +- rc |= mk_exit_code(cxt, mntrc); ++ mk_exit_code(cxt, mntrc); /* to print warnings */ + + if (mnt_context_get_status(cxt)) { +- rc |= MOUNT_EX_SOMEOK; ++ nsucc++; + + if (mnt_context_is_verbose(cxt)) + printf("%-25s: successfully mounted\n", tgt); +- } ++ } else ++ nerrs++; + } + } + + if (mnt_context_is_parent(cxt)) { + /* wait for mount --fork children */ +- int nerrs = 0, nchildren = 0; ++ int nchildren = 0; ++ ++ nerrs = 0, nsucc = 0; + + rc = mnt_context_wait_for_children(cxt, &nchildren, &nerrs); + if (!rc && nchildren) +- rc = nchildren == nerrs ? MOUNT_EX_FAIL : MOUNT_EX_SOMEOK; ++ nsucc = nchildren - nerrs; + } + ++ if (nerrs == 0) ++ rc = MOUNT_EX_SUCCESS; /* all success */ ++ else if (nsucc == 0) ++ rc = MOUNT_EX_FAIL; /* all failed */ ++ else ++ rc = MOUNT_EX_SOMEOK; /* some success, some failed */ ++ + mnt_free_iter(itr); + return rc; + } +-- +1.7.9.2 + -- cgit v1.2.3-54-g00ecf