[util-linux-ng] - fix #618957 - ISO images listed in fstab are mounted twice at boot
kzak
kzak at fedoraproject.org
Thu Aug 5 09:48:59 UTC 2010
commit f5b82120dc1743e2b446dd2934b20f4b4fdcab9d
Author: Karel Zak <kzak at redhat.com>
Date: Mon Aug 2 10:52:05 2010 +0200
- fix #618957 - ISO images listed in fstab are mounted twice at boot
Signed-off-by: Karel Zak <kzak at redhat.com>
util-linux-ng-2.17-mount-loopdev.patch | 83 ++++++++++++++++++++++++++++++++
util-linux-ng.spec | 4 ++
2 files changed, 87 insertions(+), 0 deletions(-)
---
diff --git a/util-linux-ng-2.17-mount-loopdev.patch b/util-linux-ng-2.17-mount-loopdev.patch
new file mode 100644
index 0000000..e898b3e
--- /dev/null
+++ b/util-linux-ng-2.17-mount-loopdev.patch
@@ -0,0 +1,83 @@
+diff -up util-linux-ng-2.17.2/mount/mount.c.kzak util-linux-ng-2.17.2/mount/mount.c
+--- util-linux-ng-2.17.2/mount/mount.c.kzak 2010-03-22 09:10:56.000000000 +0100
++++ util-linux-ng-2.17.2/mount/mount.c 2010-07-29 16:15:28.000000000 +0200
+@@ -1090,7 +1090,8 @@ loop_check(const char **spec, const char
+ if (verbose)
+ printf(_("mount: skipping the setup of a loop device\n"));
+ } else {
+- int loop_opts = SETLOOP_AUTOCLEAR; /* always attempt autoclear */
++ /* use autoclear loopdev on system without regular mtab only */
++ int loop_opts = mtab_is_writable() ? 0 : SETLOOP_AUTOCLEAR;
+ int res;
+
+ if (*flags & MS_RDONLY)
+@@ -1759,6 +1760,50 @@ mounted (const char *spec0, const char *
+ return ret;
+ }
+
++/* returns 0 if not mounted, 1 if mounted and -1 in case of error */
++static int
++is_fstab_entry_mounted(struct mntentchn *mc, int verbose)
++{
++ struct stat st;
++
++ if (mounted(mc->m.mnt_fsname, mc->m.mnt_dir))
++ goto yes;
++
++ /* extra care for loop devices */
++ if ((strstr(mc->m.mnt_opts, "loop=") ||
++ (stat(mc->m.mnt_fsname, &st) == 0 && S_ISREG(st.st_mode)))) {
++
++ char *p = strstr(mc->m.mnt_opts, "offset=");
++ uintmax_t offset = 0;
++
++ if (p && *(p + 7)) {
++ char *end = NULL;
++
++ p += 7;
++ errno = 0;
++ offset = strtoumax(p, &end, 0);
++
++ if (end == p || (errno != 0 &&
++ (offset == UINTMAX_MAX || offset == 0))) {
++ if (verbose)
++ printf(_("mount: ignore %s "
++ "(unparsable offset= option)\n"),
++ mc->m.mnt_fsname);
++ return -1;
++ }
++ }
++ if (is_mounted_same_loopfile(mc->m.mnt_dir, mc->m.mnt_fsname, offset))
++ goto yes;
++ }
++
++ return 0;
++yes:
++ if (verbose)
++ printf(_("mount: %s already mounted on %s\n"),
++ mc->m.mnt_fsname, mc->m.mnt_dir);
++ return 1;
++}
++
+ /* avoid using stat() on things we are not going to mount anyway.. */
+ static int
+ has_noauto (const char *opts) {
+@@ -1804,16 +1849,8 @@ do_mount_all (char *types, char *options
+ if (matching_type (mc->m.mnt_type, types)
+ && matching_opts (mc->m.mnt_opts, test_opts)
+ && !streq (mc->m.mnt_dir, "/")
+- && !streq (mc->m.mnt_dir, "root")) {
+-
+- if (mounted (mc->m.mnt_fsname, mc->m.mnt_dir)) {
+- if (verbose)
+- printf(_("mount: %s already mounted "
+- "on %s\n"),
+- mc->m.mnt_fsname,
+- mc->m.mnt_dir);
+- continue;
+- }
++ && !streq (mc->m.mnt_dir, "root")
++ && !is_fstab_entry_mounted(mc, verbose)) {
+
+ mtmp = (struct mntentchn *) xmalloc(sizeof(*mtmp));
+ *mtmp = *mc;
diff --git a/util-linux-ng.spec b/util-linux-ng.spec
index ed242b1..eb112ea 100644
--- a/util-linux-ng.spec
+++ b/util-linux-ng.spec
@@ -111,6 +111,8 @@ Patch8: util-linux-ng-2.15-ipcs-32bit.patch
###
# 598631 - shutdown, reboot, halt and C-A-D don't work
Patch9: util-linux-ng-2.17-agetty-clocal.patch
+# 618957 - ISO images listed in fstab are mounted twice at boot
+Patch10: util-linux-ng-2.17-mount-loopdev.patch
%description
The util-linux-ng package contains a large variety of low-level system
@@ -226,6 +228,7 @@ cp %{SOURCE8} %{SOURCE9} .
%patch7 -p1
%patch8 -p1
%patch9 -p1
+%patch10 -p1
%build
unset LINGUAS || :
@@ -765,6 +768,7 @@ fi
* Mon Aug 2 2010 Karel Zak <kzak at redhat.com> 2.18-2
- fix #615719 - tmpfs mount fails with 'user' option.
- fix #598631 - shutdown, reboot, halt and C-A-D don't work
+- fix #618957 - ISO images listed in fstab are mounted twice at boot
* Wed Jun 30 2010 Karel Zak <kzak at redhat.com> 2.18-1
- upgrade to the final 2.18
More information about the scm-commits
mailing list