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

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