Blame SOURCES/autofs-5.1.5-refactor-unlink_active_mounts-in-direct_c.patch

c8d72b
autofs-5.1.5 - refactor unlink_active_mounts() in direct_c
c8d72b
c8d72b
From: Ian Kent <raven@themaw.net>
c8d72b
c8d72b
In daemon/direct.c:unlink_active_mounts() the tree_get_mnt_list() call
c8d72b
returns 1 for a non-empty list which amounts to a mounted check and then
c8d72b
handles the case where the map is being read.
c8d72b
c8d72b
But the check that's carried out is to distinguish between a readmap
c8d72b
and a mount activity which should be handled by the caller instead of
c8d72b
burying the check away in the unlink_active_mounts() function.
c8d72b
c8d72b
Signed-off-by: Ian Kent <raven@themaw.net>
c8d72b
---
c8d72b
 CHANGELOG       |    1 
c8d72b
 daemon/direct.c |   63 +++++++++++++++++++++++++++-----------------------------
c8d72b
 2 files changed, 32 insertions(+), 32 deletions(-)
c8d72b
c8d72b
--- autofs-5.0.7.orig/CHANGELOG
c8d72b
+++ autofs-5.0.7/CHANGELOG
c8d72b
@@ -342,6 +342,7 @@
c8d72b
 - always use PROC_MOUNTS to make mount lists.
c8d72b
 - add glibc getmntent_r().
c8d72b
 - use local getmntent_r in table_is_mounted().
c8d72b
+- refactor unlink_active_mounts() in direct.c.
c8d72b
 
c8d72b
 25/07/2012 autofs-5.0.7
c8d72b
 =======================
c8d72b
--- autofs-5.0.7.orig/daemon/direct.c
c8d72b
+++ autofs-5.0.7/daemon/direct.c
c8d72b
@@ -298,37 +298,12 @@ static int unlink_mount_tree(struct auto
c8d72b
 
c8d72b
 static int unlink_active_mounts(struct autofs_point *ap, struct mnt_list *mnts, struct mapent *me)
c8d72b
 {
c8d72b
-	struct ioctl_ops *ops = get_ioctl_ops();
c8d72b
 	struct list_head list;
c8d72b
 
c8d72b
 	INIT_LIST_HEAD(&list);
c8d72b
 
c8d72b
-	if (tree_get_mnt_list(mnts, &list, me->key, 1)) {
c8d72b
-		if (ap->state == ST_READMAP) {
c8d72b
-			time_t tout = get_exp_timeout(ap, me->source);
c8d72b
-			int save_ioctlfd, ioctlfd;
c8d72b
-
c8d72b
-			save_ioctlfd = ioctlfd = me->ioctlfd;
c8d72b
-
c8d72b
-			if (ioctlfd == -1)
c8d72b
-				ops->open(ap->logopt,
c8d72b
-					  &ioctlfd, me->dev, me->key);
c8d72b
-
c8d72b
-			if (ioctlfd < 0) {
c8d72b
-				error(ap->logopt,
c8d72b
-				     "failed to create ioctl fd for %s",
c8d72b
-				     me->key);
c8d72b
-				return 0;
c8d72b
-			}
c8d72b
-
c8d72b
-			ops->timeout(ap->logopt, ioctlfd, tout);
c8d72b
-
c8d72b
-			if (save_ioctlfd == -1)
c8d72b
-				ops->close(ap->logopt, ioctlfd);
c8d72b
-
c8d72b
-			return 0;
c8d72b
-		}
c8d72b
-	}
c8d72b
+	if (!tree_get_mnt_list(mnts, &list, me->key, 1))
c8d72b
+		return 1;
c8d72b
 
c8d72b
 	if (!unlink_mount_tree(ap, &list)) {
c8d72b
 		debug(ap->logopt,
c8d72b
@@ -370,16 +345,40 @@ int do_mount_autofs_direct(struct autofs
c8d72b
 		if (ret == 0)
c8d72b
 			return -1;
c8d72b
 	} else {
c8d72b
+		if (ap->state == ST_READMAP && is_mounted(me->key, MNTS_ALL)) {
c8d72b
+			time_t tout = get_exp_timeout(ap, me->source);
c8d72b
+			int save_ioctlfd, ioctlfd;
c8d72b
+
c8d72b
+			save_ioctlfd = ioctlfd = me->ioctlfd;
c8d72b
+
c8d72b
+			if (ioctlfd == -1)
c8d72b
+				ops->open(ap->logopt,
c8d72b
+					  &ioctlfd, me->dev, me->key);
c8d72b
+
c8d72b
+			if (ioctlfd < 0) {
c8d72b
+				error(ap->logopt,
c8d72b
+				     "failed to create ioctl fd for %s",
c8d72b
+				     me->key);
c8d72b
+				return 0;
c8d72b
+			}
c8d72b
+
c8d72b
+			ops->timeout(ap->logopt, ioctlfd, tout);
c8d72b
+
c8d72b
+			if (save_ioctlfd == -1)
c8d72b
+				ops->close(ap->logopt, ioctlfd);
c8d72b
+
c8d72b
+			return 0;
c8d72b
+		}
c8d72b
+
c8d72b
 		/*
c8d72b
-		 * A return of 0 indicates we're re-reading the map.
c8d72b
 		 * A return of 1 indicates we successfully unlinked
c8d72b
-		 * the mount tree if there was one. A return of -1
c8d72b
-		 * inducates we failed to unlink the mount tree so
c8d72b
+		 * the mount tree if there was one. A return of 0
c8d72b
+		 * indicates we failed to unlink the mount tree so
c8d72b
 		 * we have to return a failure.
c8d72b
 		 */
c8d72b
 		ret = unlink_active_mounts(ap, mnts, me);
c8d72b
-		if (ret == -1 || ret == 0)
c8d72b
-			return ret;
c8d72b
+		if (!ret)
c8d72b
+			return -1;
c8d72b
 
c8d72b
 		if (me->ioctlfd != -1) {
c8d72b
 			error(ap->logopt, "active direct mount %s", me->key);