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

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