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

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