Blame SOURCES/autofs-5.1.7-add-some-multi-mount-macros.patch

29d2b9
autofs-5.1.7 - add some multi-mount macros
29d2b9
29d2b9
From: Ian Kent <raven@themaw.net>
29d2b9
29d2b9
Add convienience macros IS_MM() to check is a mapent is part of a
29d2b9
multi-mount, IS_MM_ROOT() to check if a mapent is the root of a
29d2b9
multi-mount tree and MM_ROOT() to return the multi-mount root mapent.
29d2b9
29d2b9
Signed-off-by: Ian Kent <raven@themaw.net>
29d2b9
---
29d2b9
 CHANGELOG                |    1 +
29d2b9
 daemon/automount.c       |   14 +++++++-------
29d2b9
 daemon/direct.c          |    6 +++---
29d2b9
 daemon/lookup.c          |   10 +++++-----
29d2b9
 include/automount.h      |    5 +++++
29d2b9
 lib/cache.c              |   30 +++++++++++++++---------------
29d2b9
 lib/mounts.c             |   14 +++++++-------
29d2b9
 modules/lookup_file.c    |    4 ++--
29d2b9
 modules/lookup_hosts.c   |    4 ++--
29d2b9
 modules/lookup_ldap.c    |    4 ++--
29d2b9
 modules/lookup_nisplus.c |    4 ++--
29d2b9
 modules/lookup_program.c |    4 ++--
29d2b9
 modules/lookup_sss.c     |    4 ++--
29d2b9
 modules/lookup_yp.c      |    4 ++--
29d2b9
 modules/parse_sun.c      |   12 ++++++------
29d2b9
 15 files changed, 63 insertions(+), 57 deletions(-)
29d2b9
29d2b9
diff --git a/CHANGELOG b/CHANGELOG
29d2b9
index 1bf20699..3ba748d7 100644
29d2b9
--- a/CHANGELOG
29d2b9
+++ b/CHANGELOG
29d2b9
@@ -28,6 +28,7 @@
29d2b9
 - rename path to m_offset in update_offset_entry().
29d2b9
 - don't pass root to do_mount_autofs_offset().
29d2b9
 - rename tree implementation functions.
29d2b9
+- add some multi-mount macros.
29d2b9
 
29d2b9
 25/01/2021 autofs-5.1.7
29d2b9
 - make bind mounts propagation slave by default.
29d2b9
diff --git a/daemon/automount.c b/daemon/automount.c
29d2b9
index 62530b6b..f4608fc9 100644
29d2b9
--- a/daemon/automount.c
29d2b9
+++ b/daemon/automount.c
29d2b9
@@ -545,27 +545,27 @@ static int umount_subtree_mounts(struct autofs_point *ap, const char *path, unsi
29d2b9
 
29d2b9
 	if (me) {
29d2b9
 		mc = me->mc;
29d2b9
-		is_mm_root = (me->multi == me);
29d2b9
+		is_mm_root = IS_MM_ROOT(me);
29d2b9
 	}
29d2b9
 
29d2b9
 	left = 0;
29d2b9
 
29d2b9
-	if (me && me->multi) {
29d2b9
+	if (me && IS_MM(me)) {
29d2b9
 		char root[PATH_MAX + 1];
29d2b9
 		char key[PATH_MAX + 1];
29d2b9
 		struct mapent *tmp;
29d2b9
 		int status;
29d2b9
 		char *base;
29d2b9
 
29d2b9
-		if (!strchr(me->multi->key, '/'))
29d2b9
+		if (!strchr(MM_ROOT(me)->key, '/'))
29d2b9
 			/* Indirect multi-mount root */
29d2b9
 			/* sprintf okay - if it's mounted, it's
29d2b9
 			 * PATH_MAX or less bytes */
29d2b9
-			sprintf(root, "%s/%s", ap->path, me->multi->key);
29d2b9
+			sprintf(root, "%s/%s", ap->path, MM_ROOT(me)->key);
29d2b9
 		else
29d2b9
-			strcpy(root, me->multi->key);
29d2b9
+			strcpy(root, MM_ROOT(me)->key);
29d2b9
 
29d2b9
-		if (is_mm_root)
29d2b9
+		if (IS_MM_ROOT(me))
29d2b9
 			base = NULL;
29d2b9
 		else
29d2b9
 			base = me->key + strlen(root);
29d2b9
@@ -588,7 +588,7 @@ static int umount_subtree_mounts(struct autofs_point *ap, const char *path, unsi
29d2b9
 			return 0;
29d2b9
 		}
29d2b9
 
29d2b9
-		if (!left && is_mm_root) {
29d2b9
+		if (!left && IS_MM_ROOT(me)) {
29d2b9
 			status = cache_delete_offset_list(mc, me->key);
29d2b9
 			if (status != CHE_OK) {
29d2b9
 				warn(ap->logopt, "couldn't delete offset list");
29d2b9
diff --git a/daemon/direct.c b/daemon/direct.c
29d2b9
index 5c1146a7..3f4f5704 100644
29d2b9
--- a/daemon/direct.c
29d2b9
+++ b/daemon/direct.c
29d2b9
@@ -686,7 +686,7 @@ int mount_autofs_offset(struct autofs_point *ap, struct mapent *me)
29d2b9
 			 * a mount that has been automatically mounted by
29d2b9
 			 * the kernel NFS client.
29d2b9
 			 */
29d2b9
-			if (me->multi != me &&
29d2b9
+			if (!IS_MM_ROOT(me) &&
29d2b9
 			    is_mounted(me->key, MNTS_REAL))
29d2b9
 				return MOUNT_OFFSET_IGNORE;
29d2b9
 
29d2b9
@@ -1220,11 +1220,11 @@ static void *do_mount_direct(void *arg)
29d2b9
 			 * for direct mount multi-mounts with no real mount at
29d2b9
 			 * their base so they will be expired.
29d2b9
 			 */
29d2b9
-			if (close_fd && me == me->multi)
29d2b9
+			if (close_fd && IS_MM_ROOT(me))
29d2b9
 				close_fd = 0;
29d2b9
 			if (!close_fd)
29d2b9
 				me->ioctlfd = mt.ioctlfd;
29d2b9
-			if (me->multi && me->multi != me)
29d2b9
+			if (IS_MM(me) && !IS_MM_ROOT(me))
29d2b9
 				flags |= MNTS_OFFSET;
29d2b9
 		}
29d2b9
 		ops->send_ready(ap->logopt, mt.ioctlfd, mt.wait_queue_token);
29d2b9
diff --git a/daemon/lookup.c b/daemon/lookup.c
29d2b9
index 2fea0c0b..8c9a82b5 100644
29d2b9
--- a/daemon/lookup.c
29d2b9
+++ b/daemon/lookup.c
29d2b9
@@ -748,7 +748,7 @@ int lookup_ghost(struct autofs_point *ap, const char *root)
29d2b9
 					goto next;
29d2b9
 
29d2b9
 				/* It's a busy multi-mount - leave till next time */
29d2b9
-				if (list_empty(&me->multi_list))
29d2b9
+				if (IS_MM(me))
29d2b9
 					error(ap->logopt,
29d2b9
 					      "invalid key %s", me->key);
29d2b9
 				goto next;
29d2b9
@@ -838,12 +838,12 @@ static int lookup_amd_instance(struct autofs_point *ap,
29d2b9
 	char *m_key;
29d2b9
 
29d2b9
 	me = cache_lookup_distinct(map->mc, name);
29d2b9
-	if (!me || !me->multi) {
29d2b9
+	if (!me || !IS_MM(me)) {
29d2b9
 		error(ap->logopt, "expected multi mount entry not found");
29d2b9
 		return NSS_STATUS_UNKNOWN;
29d2b9
 	}
29d2b9
 
29d2b9
-	m_key = malloc(strlen(ap->path) + strlen(me->multi->key) + 2);
29d2b9
+	m_key = malloc(strlen(ap->path) + strlen(MM_ROOT(me)->key) + 2);
29d2b9
 	if (!m_key) {
29d2b9
 		error(ap->logopt,
29d2b9
 		     "failed to allocate storage for search key");
29d2b9
@@ -852,7 +852,7 @@ static int lookup_amd_instance(struct autofs_point *ap,
29d2b9
 
29d2b9
 	strcpy(m_key, ap->path);
29d2b9
 	strcat(m_key, "/");
29d2b9
-	strcat(m_key, me->multi->key);
29d2b9
+	strcat(m_key, MM_ROOT(me)->key);
29d2b9
 
29d2b9
 	mnt = mnts_find_amdmount(m_key);
29d2b9
 	free(m_key);
29d2b9
@@ -1355,7 +1355,7 @@ void lookup_prune_one_cache(struct autofs_point *ap, struct mapent_cache *mc, ti
29d2b9
 			 * created on demand and managed by expire and don't
29d2b9
 			 * prune the multi-map owner map entry.
29d2b9
 			 */
29d2b9
-			if (*me->key == '/' || me->multi == me) {
29d2b9
+			if (*me->key == '/' || IS_MM_ROOT(me)) {
29d2b9
 				me = cache_enumerate(mc, me);
29d2b9
 				continue;
29d2b9
 			}
29d2b9
diff --git a/include/automount.h b/include/automount.h
29d2b9
index fa6f5d63..e917515b 100644
29d2b9
--- a/include/automount.h
29d2b9
+++ b/include/automount.h
29d2b9
@@ -183,6 +183,11 @@ struct mapent {
29d2b9
 	ino_t ino;
29d2b9
 };
29d2b9
 
29d2b9
+#define IS_MM(me)	(me->multi)
29d2b9
+#define IS_MM_ROOT(me)	(me->multi == me)
29d2b9
+#define MM_ROOT(me)	(me->multi)
29d2b9
+#define MM_PARENT(me)	(me->parent)
29d2b9
+
29d2b9
 void cache_lock_cleanup(void *arg);
29d2b9
 void cache_readlock(struct mapent_cache *mc);
29d2b9
 void cache_writelock(struct mapent_cache *mc);
29d2b9
diff --git a/lib/cache.c b/lib/cache.c
29d2b9
index a90bbb1d..1d9f5cc7 100644
29d2b9
--- a/lib/cache.c
29d2b9
+++ b/lib/cache.c
29d2b9
@@ -374,7 +374,7 @@ struct mapent *cache_lookup_first(struct mapent_cache *mc)
29d2b9
 
29d2b9
 		while (me) {
29d2b9
 			/* Multi mount entries are not primary */
29d2b9
-			if (me->multi && me->multi != me) {
29d2b9
+			if (IS_MM(me) && !IS_MM_ROOT(me)) {
29d2b9
 				me = me->next;
29d2b9
 				continue;
29d2b9
 			}
29d2b9
@@ -397,7 +397,7 @@ struct mapent *cache_lookup_next(struct mapent_cache *mc, struct mapent *me)
29d2b9
 	this = me->next;
29d2b9
 	while (this) {
29d2b9
 		/* Multi mount entries are not primary */
29d2b9
-		if (this->multi && this->multi != this) {
29d2b9
+		if (IS_MM(this) && !IS_MM_ROOT(this)) {
29d2b9
 			this = this->next;
29d2b9
 			continue;
29d2b9
 		}
29d2b9
@@ -413,7 +413,7 @@ struct mapent *cache_lookup_next(struct mapent_cache *mc, struct mapent *me)
29d2b9
 
29d2b9
 			while (this) {
29d2b9
 				/* Multi mount entries are not primary */
29d2b9
-				if (this->multi && this->multi != this) {
29d2b9
+				if (IS_MM(this) && !IS_MM_ROOT(this)) {
29d2b9
 					this = this->next;
29d2b9
 					continue;
29d2b9
 				}
29d2b9
@@ -435,7 +435,7 @@ struct mapent *cache_lookup_key_next(struct mapent *me)
29d2b9
 	next = me->next;
29d2b9
 	while (next) {
29d2b9
 		/* Multi mount entries are not primary */
29d2b9
-		if (me->multi && me->multi != me)
29d2b9
+		if (IS_MM(me) && !IS_MM_ROOT(me))
29d2b9
 			continue;
29d2b9
 		if (!strcmp(me->key, next->key))
29d2b9
 			return next;
29d2b9
@@ -706,7 +706,7 @@ int cache_update_offset(struct mapent_cache *mc, const char *mkey, const char *k
29d2b9
 	me = cache_lookup_distinct(mc, key);
29d2b9
 	if (me) {
29d2b9
 		cache_add_ordered_offset(me, &owner->multi_list);
29d2b9
-		me->multi = owner;
29d2b9
+		MM_ROOT(me) = owner;
29d2b9
 		goto done;
29d2b9
 	}
29d2b9
 	ret = CHE_FAIL;
29d2b9
@@ -814,14 +814,14 @@ int cache_set_offset_parent(struct mapent_cache *mc, const char *offset)
29d2b9
 	this = cache_lookup_distinct(mc, offset);
29d2b9
 	if (!this)
29d2b9
 		return 0;
29d2b9
-	if (!this->multi)
29d2b9
+	if (!IS_MM(this))
29d2b9
 		return 0;
29d2b9
 
29d2b9
 	parent = get_offset_parent(mc, offset);
29d2b9
 	if (parent)
29d2b9
 		this->parent = parent;
29d2b9
 	else
29d2b9
-		this->parent = this->multi;
29d2b9
+		this->parent = MM_ROOT(this);
29d2b9
 
29d2b9
 	return 1;
29d2b9
 }
29d2b9
@@ -879,7 +879,7 @@ int cache_delete_offset(struct mapent_cache *mc, const char *key)
29d2b9
 		return CHE_FAIL;
29d2b9
 
29d2b9
 	if (strcmp(key, me->key) == 0) {
29d2b9
-		if (me->multi && me->multi == me)
29d2b9
+		if (IS_MM(me) && IS_MM_ROOT(me))
29d2b9
 			return CHE_FAIL;
29d2b9
 		mc->hash[hashval] = me->next;
29d2b9
 		goto delete;
29d2b9
@@ -889,7 +889,7 @@ int cache_delete_offset(struct mapent_cache *mc, const char *key)
29d2b9
 		pred = me;
29d2b9
 		me = me->next;
29d2b9
 		if (strcmp(key, me->key) == 0) {
29d2b9
-			if (me->multi && me->multi == me)
29d2b9
+			if (IS_MM(me) && IS_MM_ROOT(me))
29d2b9
 				return CHE_FAIL;
29d2b9
 			pred->next = me->next;
29d2b9
 			goto delete;
29d2b9
@@ -927,7 +927,7 @@ int cache_delete(struct mapent_cache *mc, const char *key)
29d2b9
 		me = me->next;
29d2b9
 		if (strcmp(key, me->key) == 0) {
29d2b9
 			struct stack *s = me->stack;
29d2b9
-			if (me->multi && !list_empty(&me->multi_list)) {
29d2b9
+			if (IS_MM(me)) {
29d2b9
 				ret = CHE_FAIL;
29d2b9
 				goto done;
29d2b9
 			}
29d2b9
@@ -956,7 +956,7 @@ int cache_delete(struct mapent_cache *mc, const char *key)
29d2b9
 
29d2b9
 	if (strcmp(key, me->key) == 0) {
29d2b9
 		struct stack *s = me->stack;
29d2b9
-		if (me->multi && !list_empty(&me->multi_list)) {
29d2b9
+		if (IS_MM(me)) {
29d2b9
 			ret = CHE_FAIL;
29d2b9
 			goto done;
29d2b9
 		}
29d2b9
@@ -995,7 +995,7 @@ int cache_delete_offset_list(struct mapent_cache *mc, const char *key)
29d2b9
 		return CHE_FAIL;
29d2b9
 
29d2b9
 	/* Not offset list owner */
29d2b9
-	if (me->multi != me)
29d2b9
+	if (!IS_MM_ROOT(me))
29d2b9
 		return CHE_FAIL;
29d2b9
 
29d2b9
 	head = &me->multi_list;
29d2b9
@@ -1016,13 +1016,13 @@ int cache_delete_offset_list(struct mapent_cache *mc, const char *key)
29d2b9
 		this = list_entry(next, struct mapent, multi_list);
29d2b9
 		next = next->next;
29d2b9
 		list_del_init(&this->multi_list);
29d2b9
-		this->multi = NULL;
29d2b9
+		MM_ROOT(this) = NULL;
29d2b9
 		debug(logopt, "deleting offset key %s", this->key);
29d2b9
 		status = cache_delete(mc, this->key);
29d2b9
 		if (status == CHE_FAIL) {
29d2b9
 			warn(logopt,
29d2b9
 			     "failed to delete offset %s", this->key);
29d2b9
-			this->multi = me;
29d2b9
+			MM_ROOT(this) = me;
29d2b9
 			/* TODO: add list back in */
29d2b9
 			remain++;
29d2b9
 		}
29d2b9
@@ -1030,7 +1030,7 @@ int cache_delete_offset_list(struct mapent_cache *mc, const char *key)
29d2b9
 
29d2b9
 	if (!remain) {
29d2b9
 		list_del_init(&me->multi_list);
29d2b9
-		me->multi = NULL;
29d2b9
+		MM_ROOT(me) = NULL;
29d2b9
 	}
29d2b9
 
29d2b9
 	if (remain)
29d2b9
diff --git a/lib/mounts.c b/lib/mounts.c
29d2b9
index f5b905a6..f6f20fc0 100644
29d2b9
--- a/lib/mounts.c
29d2b9
+++ b/lib/mounts.c
29d2b9
@@ -2163,7 +2163,7 @@ int try_remount(struct autofs_point *ap, struct mapent *me, unsigned int type)
29d2b9
 	} else {
29d2b9
 		me->flags &= ~MOUNT_FLAG_DIR_CREATED;
29d2b9
 		if (type == t_offset) {
29d2b9
-			if (!is_mounted(me->parent->key, MNTS_REAL))
29d2b9
+			if (!is_mounted(MM_PARENT(me)->key, MNTS_REAL))
29d2b9
 				me->flags |= MOUNT_FLAG_DIR_CREATED;
29d2b9
 		}
29d2b9
 	}
29d2b9
@@ -2310,7 +2310,7 @@ void set_indirect_mount_tree_catatonic(struct autofs_point *ap)
29d2b9
 				goto next;
29d2b9
 
29d2b9
 			/* Only need to set offset mounts catatonic */
29d2b9
-			if (me->multi && me->multi == me)
29d2b9
+			if (IS_MM(me) && IS_MM_ROOT(me))
29d2b9
 				set_multi_mount_tree_catatonic(ap, me);
29d2b9
 next:
29d2b9
 			me = cache_enumerate(mc, me);
29d2b9
@@ -2330,7 +2330,7 @@ next:
29d2b9
 void set_direct_mount_tree_catatonic(struct autofs_point *ap, struct mapent *me)
29d2b9
 {
29d2b9
 	/* Set offset mounts catatonic for this mapent */
29d2b9
-	if (me->multi && me->multi == me)
29d2b9
+	if (IS_MM(me) && IS_MM_ROOT(me))
29d2b9
 		set_multi_mount_tree_catatonic(ap, me);
29d2b9
 	set_mount_catatonic(ap, me, me->ioctlfd);
29d2b9
 }
29d2b9
@@ -2490,12 +2490,12 @@ static int rmdir_path_offset(struct autofs_point *ap, struct mapent *oe)
29d2b9
 	int ret;
29d2b9
 
29d2b9
 	if (ap->type == LKP_DIRECT)
29d2b9
-		return rmdir_path(ap, oe->key, oe->multi->dev);
29d2b9
+		return rmdir_path(ap, oe->key, MM_ROOT(oe)->dev);
29d2b9
 
29d2b9
 	dir = strdup(oe->key);
29d2b9
 
29d2b9
 	if (ap->flags & MOUNT_FLAG_GHOST)
29d2b9
-		split = strlen(ap->path) + strlen(oe->multi->key) + 1;
29d2b9
+		split = strlen(ap->path) + strlen(MM_ROOT(oe)->key) + 1;
29d2b9
 	else
29d2b9
 		split = strlen(ap->path);
29d2b9
 
29d2b9
@@ -2690,7 +2690,7 @@ int mount_multi_triggers(struct autofs_point *ap, struct mapent *me,
29d2b9
 		oe = cache_lookup_distinct(me->mc, key);
29d2b9
 		if (!oe || !oe->mapent)
29d2b9
 			goto cont;
29d2b9
-		if (oe->age != me->multi->age) {
29d2b9
+		if (oe->age != MM_ROOT(me)->age) {
29d2b9
 			/* Best effort */
29d2b9
 			do_umount_offset(ap, oe, root, start);
29d2b9
 			goto cont;
29d2b9
@@ -2724,7 +2724,7 @@ int umount_multi_triggers(struct autofs_point *ap, struct mapent *me, char *root
29d2b9
 
29d2b9
 	left = do_umount_multi_triggers(ap, me, root, start, base);
29d2b9
 
29d2b9
-	if (!left && me->multi == me) {
29d2b9
+	if (!left && IS_MM_ROOT(me)) {
29d2b9
 		/*
29d2b9
 		 * Special case.
29d2b9
 		 * If we can't umount the root container then we can't
29d2b9
diff --git a/modules/lookup_file.c b/modules/lookup_file.c
29d2b9
index f46a04f0..6afc5587 100644
29d2b9
--- a/modules/lookup_file.c
29d2b9
+++ b/modules/lookup_file.c
29d2b9
@@ -1199,8 +1199,8 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
29d2b9
 
29d2b9
 		cache_readlock(mc);
29d2b9
 		me = cache_lookup_distinct(mc, key);
29d2b9
-		if (me && me->multi)
29d2b9
-			lkp_key = strdup(me->multi->key);
29d2b9
+		if (me && IS_MM(me))
29d2b9
+			lkp_key = strdup(MM_ROOT(me)->key);
29d2b9
 		else if (!ap->pref)
29d2b9
 			lkp_key = strdup(key);
29d2b9
 		else {
29d2b9
diff --git a/modules/lookup_hosts.c b/modules/lookup_hosts.c
29d2b9
index c1ebb7f6..7e101ddb 100644
29d2b9
--- a/modules/lookup_hosts.c
29d2b9
+++ b/modules/lookup_hosts.c
29d2b9
@@ -177,7 +177,7 @@ static void update_hosts_mounts(struct autofs_point *ap,
29d2b9
 	me = cache_lookup_first(mc);
29d2b9
 	while (me) {
29d2b9
 		/* Hosts map entry not yet expanded or already expired */
29d2b9
-		if (!me->multi)
29d2b9
+		if (!IS_MM(me))
29d2b9
 			goto next;
29d2b9
 
29d2b9
 		debug(ap->logopt, MODPREFIX "get list of exports for %s", me->key);
29d2b9
@@ -200,7 +200,7 @@ next:
29d2b9
 		 * Hosts map entry not yet expanded, already expired
29d2b9
 		 * or not the base of the tree
29d2b9
 		 */
29d2b9
-		if (!me->multi || me->multi != me)
29d2b9
+		if (!IS_MM(me) || !IS_MM_ROOT(me))
29d2b9
 			goto cont;
29d2b9
 
29d2b9
 		debug(ap->logopt, MODPREFIX
29d2b9
diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c
29d2b9
index 3624dd86..3e43fc01 100644
29d2b9
--- a/modules/lookup_ldap.c
29d2b9
+++ b/modules/lookup_ldap.c
29d2b9
@@ -3700,8 +3700,8 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
29d2b9
 	if (ap->type == LKP_INDIRECT && *key != '/') {
29d2b9
 		cache_readlock(mc);
29d2b9
 		me = cache_lookup_distinct(mc, key);
29d2b9
-		if (me && me->multi)
29d2b9
-			lkp_key = strdup(me->multi->key);
29d2b9
+		if (me && IS_MM(me))
29d2b9
+			lkp_key = strdup(MM_ROOT(me)->key);
29d2b9
 		else if (!ap->pref)
29d2b9
 			lkp_key = strdup(key);
29d2b9
 		else {
29d2b9
diff --git a/modules/lookup_nisplus.c b/modules/lookup_nisplus.c
29d2b9
index cbd03cdb..6e9a85d1 100644
29d2b9
--- a/modules/lookup_nisplus.c
29d2b9
+++ b/modules/lookup_nisplus.c
29d2b9
@@ -722,8 +722,8 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
29d2b9
 	if (ap->type == LKP_INDIRECT && *key != '/') {
29d2b9
 		cache_readlock(mc);
29d2b9
 		me = cache_lookup_distinct(mc, key);
29d2b9
-		if (me && me->multi)
29d2b9
-			lkp_key = strdup(me->multi->key);
29d2b9
+		if (me && IS_MM(me))
29d2b9
+			lkp_key = strdup(MM_ROOT(me)->key);
29d2b9
 		else if (!ap->pref)
29d2b9
 			lkp_key = strdup(key);
29d2b9
 		else {
29d2b9
diff --git a/modules/lookup_program.c b/modules/lookup_program.c
29d2b9
index ca209488..70f27545 100644
29d2b9
--- a/modules/lookup_program.c
29d2b9
+++ b/modules/lookup_program.c
29d2b9
@@ -646,7 +646,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
29d2b9
 				 name_len, ent, ctxt->parse->context);
29d2b9
 			goto out_free;
29d2b9
 		} else {
29d2b9
-			if (me->multi && me->multi != me) {
29d2b9
+			if (IS_MM(me) && !IS_MM_ROOT(me)) {
29d2b9
 				cache_unlock(mc);
29d2b9
 				warn(ap->logopt, MODPREFIX
29d2b9
 				     "unexpected lookup for active multi-mount"
29d2b9
@@ -657,7 +657,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
29d2b9
 			cache_writelock(mc);
29d2b9
 			me = cache_lookup_distinct(mc, name);
29d2b9
 			if (me) {
29d2b9
-				if (me->multi)
29d2b9
+				if (IS_MM(me))
29d2b9
 					cache_delete_offset_list(mc, name);
29d2b9
 				cache_delete(mc, name);
29d2b9
 			}
29d2b9
diff --git a/modules/lookup_sss.c b/modules/lookup_sss.c
29d2b9
index ccd605af..ad834626 100644
29d2b9
--- a/modules/lookup_sss.c
29d2b9
+++ b/modules/lookup_sss.c
29d2b9
@@ -1055,8 +1055,8 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
29d2b9
 
29d2b9
 		cache_readlock(mc);
29d2b9
 		me = cache_lookup_distinct(mc, key);
29d2b9
-		if (me && me->multi)
29d2b9
-			lkp_key = strdup(me->multi->key);
29d2b9
+		if (me && IS_MM(me))
29d2b9
+			lkp_key = strdup(MM_ROOT(me)->key);
29d2b9
 		else
29d2b9
 			lkp_key = strdup(key);
29d2b9
 		cache_unlock(mc);
29d2b9
diff --git a/modules/lookup_yp.c b/modules/lookup_yp.c
29d2b9
index 38f75497..8bccb72f 100644
29d2b9
--- a/modules/lookup_yp.c
29d2b9
+++ b/modules/lookup_yp.c
29d2b9
@@ -826,8 +826,8 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
29d2b9
         if (ap->type == LKP_INDIRECT && *key != '/') {
29d2b9
 		cache_readlock(mc);
29d2b9
 		me = cache_lookup_distinct(mc, key);
29d2b9
-		if (me && me->multi)
29d2b9
-			lkp_key = strdup(me->multi->key);
29d2b9
+		if (me && IS_MM(me))
29d2b9
+			lkp_key = strdup(MM_ROOT(me)->key);
29d2b9
 		else if (!ap->pref)
29d2b9
 			lkp_key = strdup(key);
29d2b9
 		else {
29d2b9
diff --git a/modules/parse_sun.c b/modules/parse_sun.c
29d2b9
index 34d4441e..b11c6693 100644
29d2b9
--- a/modules/parse_sun.c
29d2b9
+++ b/modules/parse_sun.c
29d2b9
@@ -1148,7 +1148,7 @@ static int mount_subtree(struct autofs_point *ap, struct mapent_cache *mc,
29d2b9
 
29d2b9
 	rv = 0;
29d2b9
 
29d2b9
-	mm_key = me->multi->key;
29d2b9
+	mm_key = MM_ROOT(me)->key;
29d2b9
 
29d2b9
 	if (*mm_key == '/') {
29d2b9
 		mm_root = mm_key;
29d2b9
@@ -1162,7 +1162,7 @@ static int mount_subtree(struct autofs_point *ap, struct mapent_cache *mc,
29d2b9
 	}
29d2b9
 	mm_root_len = strlen(mm_root);
29d2b9
 
29d2b9
-	if (me == me->multi) {
29d2b9
+	if (IS_MM_ROOT(me)) {
29d2b9
 		char key[PATH_MAX + 1];
29d2b9
 
29d2b9
 		if (mm_root_len + 1 > PATH_MAX) {
29d2b9
@@ -1179,7 +1179,7 @@ static int mount_subtree(struct autofs_point *ap, struct mapent_cache *mc,
29d2b9
 
29d2b9
 		/* Mount root offset if it exists */
29d2b9
 		ro = cache_lookup_distinct(me->mc, key);
29d2b9
-		if (ro && ro->age == me->multi->age) {
29d2b9
+		if (ro && ro->age == MM_ROOT(me)->age) {
29d2b9
 			char *myoptions, *ro_loc;
29d2b9
 			int namelen = name ? strlen(name) : 0;
29d2b9
 			int ro_len;
29d2b9
@@ -1350,7 +1350,7 @@ int parse_mount(struct autofs_point *ap, const char *name,
29d2b9
 	if (*name == '/') {
29d2b9
 		cache_readlock(mc);
29d2b9
 		me = cache_lookup_distinct(mc, name);
29d2b9
-		if (me && me->multi && me->multi != me) {
29d2b9
+		if (me && IS_MM(me) && !IS_MM_ROOT(me)) {
29d2b9
 			cache_unlock(mc);
29d2b9
 			mapent_len = strlen(mapent) + 1;
29d2b9
 			pmapent = malloc(mapent_len + 1);
29d2b9
@@ -1505,7 +1505,7 @@ dont_expand:
29d2b9
 		}
29d2b9
 
29d2b9
 		/* So we know we're the multi-mount root */
29d2b9
-		if (!me->multi)
29d2b9
+		if (!IS_MM(me))
29d2b9
 			me->multi = me;
29d2b9
 		else {
29d2b9
 			/*
29d2b9
@@ -1630,7 +1630,7 @@ dont_expand:
29d2b9
 		 */
29d2b9
 		cache_readlock(mc);
29d2b9
 		if (*name == '/' &&
29d2b9
-		   (me = cache_lookup_distinct(mc, name)) && me->multi) {
29d2b9
+		   (me = cache_lookup_distinct(mc, name)) && IS_MM(me)) {
29d2b9
 			cache_unlock(mc);
29d2b9
 			loc = strdup(p);
29d2b9
 			if (!loc) {