Skip to content

Commit

Permalink
Handle duplicate mount points.
Browse files Browse the repository at this point in the history
When mountall is iterating in try_mounts() on new mount point, change
is_parent() to return false when a record is tested against itself
because a mount point cannot be a root of itself.

Mountall does not preserve the behavior of `mount -a` if more than
one device shares a mountpoint in the /etc/fstab file.  Suppose:

	/var/tmp/alfa   /mnt/charlie  ext2  loop  0  0
	/var/tmp/bravo  /mnt/charlie  ext2  loop  0  0

Both filesystems are mounted on /mnt/charlie by `mount -a`, but
bravo is ignored by `mountall`. This seems to be an artifact of the fix for
LP #443035 in eca315d.

Furthermore, mountall hangs if such mounts are ZFS datasets or other
virtual filesystems that are not backed by a real device node.

Supercedes: solves-dependencies-problem-endless-loop.patch

Closes: #5 for Quantal
  • Loading branch information
dajhorn committed Apr 1, 2013
1 parent dd61af1 commit 863c561
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ Subject: readonly and atime options reflected during mount
src/mountall.c | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/src/mountall.c b/src/mountall.c
index 5fee9a6..6944ee9 100644
Index: b/src/mountall.c
===================================================================
--- a/src/mountall.c
+++ b/src/mountall.c
@@ -774,7 +774,7 @@ parse_zfs_list (void)
@@ -774,7 +774,7 @@
size_t bufsz = 4096;
FILE *zfs_stream;
const char zfs_command[] =
- "/sbin/zfs list -H -t filesystem -s mountpoint -o name,mountpoint,canmount";
+ "/sbin/zfs list -H -t filesystem -s mountpoint -o name,mountpoint,canmount,readonly,atime";
- "/sbin/zfs list -H -t filesystem -o name,mountpoint,canmount";
+ "/sbin/zfs list -H -t filesystem -o name,mountpoint,canmount,readonly,atime";
int zfs_result;

nih_debug ("parsing ZFS list");
@@ -793,7 +793,8 @@ parse_zfs_list (void)
@@ -793,7 +793,8 @@
/* Read one line from the pipe into the buffer. */
while (fgets (buf, bufsz, zfs_stream) != NULL) {
char *saveptr;
Expand All @@ -29,7 +29,7 @@ index 5fee9a6..6944ee9 100644

/* If the line didn't fit, then enlarge the buffer and retry. */
while ((! strchr (buf, '\n')) && (! feof (zfs_stream))) {
@@ -816,12 +817,26 @@ parse_zfs_list (void)
@@ -816,12 +817,26 @@
}

/* ASSERT: canmount = on | off | noauto */
Expand Down Expand Up @@ -58,4 +58,3 @@ index 5fee9a6..6944ee9 100644
}

zfs_result = pclose (zfs_stream);
--
36 changes: 0 additions & 36 deletions debian/patches/0003-solves-dependencies-problem-endless-loop.patch

This file was deleted.

47 changes: 47 additions & 0 deletions debian/patches/0005-Handle-duplicate-mountpoints.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
From: Darik Horn <[email protected]>
Date: Fri, 27 Mar 2013 22:29:47 -0600
Subject: Handle duplicate mountpoints.

When mountall is iterating in try_mounts() on new mount point, change
is_parent() to return false when a record is tested against itself
because a mount point cannot be a root of itself.

Mountall does not preserve the behavior of `mount -a` if more than
one device shares a mountpoint in the /etc/fstab file. Suppose:

/var/tmp/alfa /mnt/charlie ext2 loop 0 0
/var/tmp/bravo /mnt/charlie ext2 loop 0 0

Both filesystems are mounted on /mnt/charlie by `mount -a`, but
bravo is ignored by `mountall`. This seems to be an artifact of the fix for
LP ##443035 in zfsonlinux/mountall@eca315d06ae4a2913f9b2ec994c68c45fead912f.

Furthermore, mountall hangs if such mounts are ZFS datasets or other
virtual filesystems that are not backed by a real device node.

Closes: zfsonlinux/mountall#5
---

Index: b/src/mountall.c
===================================================================
--- a/src/mountall.c
+++ b/src/mountall.c
@@ -146,6 +146,7 @@
};

#define MOUNT_NAME(_mnt) (strcmp ((_mnt)->type, "swap") \
+ && strcmp ((_mnt)->type, "zfs") \
&& strcmp ((_mnt)->mountpoint, "none") \
? (_mnt)->mountpoint : (_mnt)->device)

@@ -1133,9 +1134,7 @@

len = strlen (root);
if ((! strncmp (path, root, len))
- && ((path[len] == '\0')
- || (path[len] == '/')
- || (len && path[len-1] == '/')))
+ && ((path[len] == '/') || (len && path[len-1] == '/')))
return TRUE;

return FALSE;
6 changes: 3 additions & 3 deletions debian/patches/series
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
0001-Add-ZFS-support.patch
0002-Disregard-the-mounted-dataset-property.patch
0003-solves-dependencies-problem-endless-loop.patch
0004-readonly-and-atime-options-reflected-during-mount.patch
0005-no-filesystem-should-depend-on-mounting-swap-first.patch
0003-readonly-and-atime-options-reflected-during-mount.patch
0004-no-filesystem-should-depend-on-mounting-swap-first.patch
0005-Handle-duplicate-mountpoints.patch

0 comments on commit 863c561

Please sign in to comment.