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

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