Blame SOURCES/autofs-5.1.7-remove-obsolete-functions.patch

49b67f
autofs-5.1.7 - remove obsolete functions
49b67f
49b67f
From: Ian Kent <raven@themaw.net>
49b67f
49b67f
Remove the code that's no longer used due to the tree mapent
49b67f
implementation.
49b67f
49b67f
Signed-off-by: Ian Kent <raven@themaw.net>
49b67f
---
49b67f
 CHANGELOG           |    1 
49b67f
 include/automount.h |   10 -
49b67f
 include/mounts.h    |    2 
49b67f
 lib/cache.c         |  227 -------------------------------------
49b67f
 lib/mounts.c        |  311 ----------------------------------------------------
49b67f
 modules/parse_sun.c |   56 ---------
49b67f
 6 files changed, 2 insertions(+), 605 deletions(-)
49b67f
49b67f
--- autofs-5.1.4.orig/CHANGELOG
49b67f
+++ autofs-5.1.4/CHANGELOG
49b67f
@@ -41,6 +41,7 @@
49b67f
 - add set_offset_tree_catatonic().
49b67f
 - add mount and umount offsets functions.
49b67f
 - switch to use tree implementation for offsets.
49b67f
+- remove obsolete functions.
49b67f
 
49b67f
 xx/xx/2018 autofs-5.1.5
49b67f
 - fix flag file permission.
49b67f
--- autofs-5.1.4.orig/include/automount.h
49b67f
+++ autofs-5.1.4/include/automount.h
49b67f
@@ -162,16 +162,13 @@ struct stack {
49b67f
 struct mapent {
49b67f
 	struct mapent *next;
49b67f
 	struct list_head ino_index;
49b67f
-	struct list_head multi_list;
49b67f
 	struct mapent_cache *mc;
49b67f
 	struct map_source *source;
49b67f
 	/* Need to know owner if we're a multi-mount */
49b67f
 	struct tree_node *mm_root;
49b67f
+	/* Parent nesting point within multi-mount */
49b67f
 	struct tree_node *mm_parent;
49b67f
 	struct tree_node node;
49b67f
-	struct mapent *multi;
49b67f
-	/* Parent nesting point within multi-mount */
49b67f
-	struct mapent *parent;
49b67f
 	char *key;
49b67f
 	size_t len;
49b67f
 	char *mapent;
49b67f
@@ -209,23 +206,18 @@ struct mapent *cache_lookup_next(struct
49b67f
 struct mapent *cache_lookup_key_next(struct mapent *me);
49b67f
 struct mapent *cache_lookup(struct mapent_cache *mc, const char *key);
49b67f
 struct mapent *cache_lookup_distinct(struct mapent_cache *mc, const char *key);
49b67f
-struct mapent *cache_lookup_offset(const char *prefix, const char *offset, int start, struct list_head *head);
49b67f
 struct mapent *cache_partial_match(struct mapent_cache *mc, const char *prefix);
49b67f
 struct mapent *cache_partial_match_wild(struct mapent_cache *mc, const char *prefix);
49b67f
 int cache_add(struct mapent_cache *mc, struct map_source *ms, const char *key, const char *mapent, time_t age);
49b67f
 int cache_update_offset(struct mapent_cache *mc, const char *mkey, const char *key, const char *mapent, time_t age);
49b67f
 void cache_update_negative(struct mapent_cache *mc, struct map_source *ms, const char *key, time_t timeout);
49b67f
 struct mapent *cache_get_offset_parent(struct mapent_cache *mc, const char *key);
49b67f
-int cache_set_offset_parent(struct mapent_cache *mc, const char *offset);
49b67f
 int cache_update(struct mapent_cache *mc, struct map_source *ms, const char *key, const char *mapent, time_t age);
49b67f
 int cache_delete(struct mapent_cache *mc, const char *key);
49b67f
-int cache_delete_offset(struct mapent_cache *mc, const char *key);
49b67f
-int cache_delete_offset_list(struct mapent_cache *mc, const char *key);
49b67f
 void cache_release(struct map_source *map);
49b67f
 void cache_clean_null_cache(struct mapent_cache *mc);
49b67f
 void cache_release_null_cache(struct master *master);
49b67f
 struct mapent *cache_enumerate(struct mapent_cache *mc, struct mapent *me);
49b67f
-char *cache_get_offset(const char *prefix, char *offset, int start, struct list_head *head, struct list_head **pos);
49b67f
 
49b67f
 /* Utility functions */
49b67f
 
49b67f
--- autofs-5.1.4.orig/include/mounts.h
49b67f
+++ autofs-5.1.4/include/mounts.h
49b67f
@@ -187,8 +187,6 @@ void set_indirect_mount_tree_catatonic(s
49b67f
 void set_direct_mount_tree_catatonic(struct autofs_point *, struct mapent *);
49b67f
 int umount_ent(struct autofs_point *, const char *);
49b67f
 int umount_amd_ext_mount(struct autofs_point *, const char *);
49b67f
-int mount_multi_triggers(struct autofs_point *, struct mapent *, const char *, unsigned int, const char *);
49b67f
-int umount_multi_triggers(struct autofs_point *, struct mapent *, char *, const char *);
49b67f
 int clean_stale_multi_triggers(struct autofs_point *, struct mapent *, char *, const char *);
49b67f
 
49b67f
 #endif
49b67f
--- autofs-5.1.4.orig/lib/cache.c
49b67f
+++ autofs-5.1.4/lib/cache.c
49b67f
@@ -461,30 +461,6 @@ struct mapent *cache_lookup_distinct(str
49b67f
 	return NULL;
49b67f
 }
49b67f
 
49b67f
-/* Lookup an offset within a multi-mount entry */
49b67f
-struct mapent *cache_lookup_offset(const char *prefix, const char *offset, int start, struct list_head *head)
49b67f
-{
49b67f
-	struct list_head *p;
49b67f
-	struct mapent *this;
49b67f
-	/* Keys for direct maps may be as long as a path name */
49b67f
-	char o_key[PATH_MAX];
49b67f
-	/* Avoid "//" at the beginning of paths */
49b67f
-	const char *path_prefix = strlen(prefix) > 1 ? prefix : "";
49b67f
-	size_t size;
49b67f
-
49b67f
-	/* root offset duplicates "/" */
49b67f
-	size = snprintf(o_key, sizeof(o_key), "%s%s", path_prefix, offset);
49b67f
-	if (size >= sizeof(o_key))
49b67f
-		return NULL;
49b67f
-
49b67f
-	list_for_each(p, head) {
49b67f
-		this = list_entry(p, struct mapent, multi_list);
49b67f
-		if (!strcmp(&this->key[start], o_key))
49b67f
-			return this;
49b67f
-	}
49b67f
-	return NULL;
49b67f
-}
49b67f
-
49b67f
 /* cache must be read locked by caller */
49b67f
 static struct mapent *__cache_partial_match(struct mapent_cache *mc,
49b67f
 					    const char *prefix,
49b67f
@@ -583,9 +559,6 @@ int cache_add(struct mapent_cache *mc, s
49b67f
 	me->mm_parent = NULL;
49b67f
 	INIT_TREE_NODE(&me->node);
49b67f
 	INIT_LIST_HEAD(&me->ino_index);
49b67f
-	INIT_LIST_HEAD(&me->multi_list);
49b67f
-	me->multi = NULL;
49b67f
-	me->parent = NULL;
49b67f
 	me->ioctlfd = -1;
49b67f
 	me->dev = (dev_t) -1;
49b67f
 	me->ino = (ino_t) -1;
49b67f
@@ -616,33 +589,6 @@ int cache_add(struct mapent_cache *mc, s
49b67f
 }
49b67f
 
49b67f
 /* cache must be write locked by caller */
49b67f
-static void cache_add_ordered_offset(struct mapent *me, struct list_head *head)
49b67f
-{
49b67f
-	struct list_head *p;
49b67f
-	struct mapent *this;
49b67f
-
49b67f
-	list_for_each(p, head) {
49b67f
-		size_t tlen;
49b67f
-		int eq;
49b67f
-
49b67f
-		this = list_entry(p, struct mapent, multi_list);
49b67f
-		tlen = strlen(this->key);
49b67f
-
49b67f
-		eq = strncmp(this->key, me->key, tlen);
49b67f
-		if (!eq && tlen == strlen(me->key))
49b67f
-			return;
49b67f
-
49b67f
-		if (eq > 0) {
49b67f
-			list_add_tail(&me->multi_list, p);
49b67f
-			return;
49b67f
-		}
49b67f
-	}
49b67f
-	list_add_tail(&me->multi_list, p);
49b67f
-
49b67f
-	return;
49b67f
-}
49b67f
-
49b67f
-/* cache must be write locked by caller */
49b67f
 int cache_update_offset(struct mapent_cache *mc, const char *mkey, const char *key, const char *mapent, time_t age)
49b67f
 {
49b67f
 	unsigned logopt = mc->ap ? mc->ap->logopt : master_get_logopt();
49b67f
@@ -747,25 +693,6 @@ struct mapent *cache_get_offset_parent(s
49b67f
 	return NULL;
49b67f
 }
49b67f
 
49b67f
-int cache_set_offset_parent(struct mapent_cache *mc, const char *offset)
49b67f
-{
49b67f
-	struct mapent *this, *parent;
49b67f
-
49b67f
-	this = cache_lookup_distinct(mc, offset);
49b67f
-	if (!this)
49b67f
-		return 0;
49b67f
-	if (!IS_MM(this))
49b67f
-		return 0;
49b67f
-
49b67f
-	parent = cache_get_offset_parent(mc, offset);
49b67f
-	if (parent)
49b67f
-		this->parent = parent;
49b67f
-	else
49b67f
-		this->parent = MM_ROOT(this);
49b67f
-
49b67f
-	return 1;
49b67f
-}
49b67f
-
49b67f
 /* cache must be write locked by caller */
49b67f
 int cache_update(struct mapent_cache *mc, struct map_source *ms, const char *key, const char *mapent, time_t age)
49b67f
 {
49b67f
@@ -807,50 +734,6 @@ int cache_update(struct mapent_cache *mc
49b67f
 	return ret;
49b67f
 }
49b67f
 
49b67f
-/* cache write lock of the multi mount owner must be held by caller */
49b67f
-int cache_delete_offset(struct mapent_cache *mc, const char *key)
49b67f
-{
49b67f
-	u_int32_t hashval = hash(key, mc->size);
49b67f
-	struct mapent *me = NULL, *pred;
49b67f
-	int status;
49b67f
-
49b67f
-	me = mc->hash[hashval];
49b67f
-	if (!me)
49b67f
-		return CHE_FAIL;
49b67f
-
49b67f
-	if (strcmp(key, me->key) == 0) {
49b67f
-		if (IS_MM(me) && IS_MM_ROOT(me))
49b67f
-			return CHE_FAIL;
49b67f
-		mc->hash[hashval] = me->next;
49b67f
-		goto delete;
49b67f
-	}
49b67f
-
49b67f
-	while (me->next != NULL) {
49b67f
-		pred = me;
49b67f
-		me = me->next;
49b67f
-		if (strcmp(key, me->key) == 0) {
49b67f
-			if (IS_MM(me) && IS_MM_ROOT(me))
49b67f
-				return CHE_FAIL;
49b67f
-			pred->next = me->next;
49b67f
-			goto delete;
49b67f
-		}
49b67f
-	}
49b67f
-
49b67f
-	return CHE_FAIL;
49b67f
-
49b67f
-delete:
49b67f
-	list_del(&me->multi_list);
49b67f
-	ino_index_lock(mc);
49b67f
-	list_del(&me->ino_index);
49b67f
-	ino_index_unlock(mc);
49b67f
-	free(me->key);
49b67f
-	if (me->mapent)
49b67f
-		free(me->mapent);
49b67f
-	free(me);
49b67f
-
49b67f
-	return CHE_OK;
49b67f
-}
49b67f
-
49b67f
 /* cache must be write locked by caller */
49b67f
 int cache_delete(struct mapent_cache *mc, const char *key)
49b67f
 {
49b67f
@@ -1024,113 +907,3 @@ struct mapent *cache_enumerate(struct ma
49b67f
 
49b67f
 	return cache_lookup_next(mc, me);
49b67f
 }
49b67f
-
49b67f
-/*
49b67f
- * Get each offset from list head under prefix.
49b67f
- * Maintain traversal current position in pos for subsequent calls. 
49b67f
- * Return each offset into offset.
49b67f
- */
49b67f
-/* cache must be read locked by caller */
49b67f
-char *cache_get_offset(const char *prefix, char *offset, int start,
49b67f
-			struct list_head *head, struct list_head **pos)
49b67f
-{
49b67f
-	struct list_head *next;
49b67f
-	struct mapent *this;
49b67f
-	size_t plen = strlen(prefix);
49b67f
-	size_t len = 0;
49b67f
-
49b67f
-	if (*pos == head)
49b67f
-		return NULL;
49b67f
-
49b67f
-	/* Find an offset */
49b67f
-	*offset = '\0';
49b67f
-	next = *pos ? (*pos)->next : head->next;
49b67f
-	while (next != head) {
49b67f
-		char *offset_start, *pstart, *pend;
49b67f
-
49b67f
-		this = list_entry(next, struct mapent, multi_list);
49b67f
-		*pos = next;
49b67f
-		next = next->next;
49b67f
-
49b67f
-		offset_start = &this->key[start];
49b67f
-		if (strlen(offset_start) <= plen)
49b67f
-			continue;
49b67f
-
49b67f
-		if (!strncmp(prefix, offset_start, plen)) {
49b67f
-			struct mapent *np = NULL;
49b67f
-			char pe[PATH_MAX + 1];
49b67f
-
49b67f
-			/* "/" doesn't count for root offset */
49b67f
-			if (plen == 1)
49b67f
-				pstart = &offset_start[plen - 1];
49b67f
-			else
49b67f
-				pstart = &offset_start[plen];
49b67f
-
49b67f
-			/* not part of this sub-tree */
49b67f
-			if (*pstart != '/')
49b67f
-				continue;
49b67f
-
49b67f
-			/* get next offset */
49b67f
-			pend = pstart;
49b67f
-			while (*pend++) {
49b67f
-				size_t nest_pt_offset;
49b67f
-
49b67f
-				if (*pend != '/')
49b67f
-					continue;
49b67f
-
49b67f
-				nest_pt_offset = start + pend - pstart;
49b67f
-				if (plen > 1)
49b67f
-					nest_pt_offset += plen;
49b67f
-				strcpy(pe, this->key);
49b67f
-				pe[nest_pt_offset] = '\0';
49b67f
-
49b67f
-				np = cache_lookup_distinct(this->mc, pe);
49b67f
-				if (np)
49b67f
-					break;
49b67f
-			}
49b67f
-			if (np)
49b67f
-				continue;
49b67f
-			len = pend - pstart - 1;
49b67f
-			strncpy(offset, pstart, len);
49b67f
-			offset[len] ='\0';
49b67f
-			break;
49b67f
-		}
49b67f
-	}
49b67f
-
49b67f
-	/* Seek to next offset */
49b67f
-	while (next != head) {
49b67f
-		char *offset_start, *pstart;
49b67f
-
49b67f
-		this = list_entry(next, struct mapent, multi_list);
49b67f
-
49b67f
-		offset_start = &this->key[start];
49b67f
-		if (strlen(offset_start) <= plen + len)
49b67f
-			break;
49b67f
-
49b67f
-		/* "/" doesn't count for root offset */
49b67f
-		if (plen == 1)
49b67f
-			pstart = &offset_start[plen - 1];
49b67f
-		else
49b67f
-			pstart = &offset_start[plen];
49b67f
-
49b67f
-		/* not part of this sub-tree */
49b67f
-		if (*pstart != '/')
49b67f
-			break;
49b67f
-
49b67f
-		/* new offset */
49b67f
-		if (!*(pstart + len + 1))
49b67f
-			break;
49b67f
-
49b67f
-		/* compare offset */
49b67f
-		if (pstart[len] != '/' ||
49b67f
-		    strlen(pstart) != len ||
49b67f
-		    strncmp(offset, pstart, len))
49b67f
-			break;
49b67f
-
49b67f
-		*pos = next;
49b67f
-		next = next->next;
49b67f
-	}
49b67f
-
49b67f
-	return *offset ? offset : NULL;
49b67f
-}
49b67f
-
49b67f
--- autofs-5.1.4.orig/lib/mounts.c
49b67f
+++ autofs-5.1.4/lib/mounts.c
49b67f
@@ -2849,21 +2849,6 @@ static void set_offset_tree_catatonic(st
49b67f
 	tree_traverse_inorder(MAPENT_ROOT(me), set_offset_tree_catatonic_work, NULL);
49b67f
 }
49b67f
 
49b67f
-static void set_multi_mount_tree_catatonic(struct autofs_point *ap, struct mapent *me)
49b67f
-{
49b67f
-	if (!list_empty(&me->multi_list)) {
49b67f
-		struct list_head *head = &me->multi_list;
49b67f
-		struct list_head *p;
49b67f
-
49b67f
-		list_for_each(p, head) {
49b67f
-			struct mapent *this;
49b67f
-
49b67f
-			this = list_entry(p, struct mapent, multi_list);
49b67f
-			set_mount_catatonic(ap, this, this->ioctlfd);
49b67f
-		}
49b67f
-	}
49b67f
-}
49b67f
-
49b67f
 void set_indirect_mount_tree_catatonic(struct autofs_point *ap)
49b67f
 {
49b67f
 	struct master_mapent *entry = ap->entry;
49b67f
@@ -3028,299 +3013,3 @@ done:
49b67f
 out:
49b67f
 	return rv;
49b67f
 }
49b67f
-
49b67f
-static int do_mount_autofs_offset(struct autofs_point *ap, struct mapent *oe)
49b67f
-{
49b67f
-	int mounted = 0;
49b67f
-	int ret;
49b67f
-
49b67f
-	debug(ap->logopt, "mount offset %s", oe->key);
49b67f
-
49b67f
-	ret = mount_autofs_offset(ap, oe);
49b67f
-	if (ret >= MOUNT_OFFSET_OK)
49b67f
-		mounted++;
49b67f
-	else {
49b67f
-		if (ret != MOUNT_OFFSET_IGNORE)
49b67f
-			warn(ap->logopt, "failed to mount offset");
49b67f
-		else {
49b67f
-			debug(ap->logopt, "ignoring \"nohide\" trigger %s",
49b67f
-			      oe->key);
49b67f
-			/*
49b67f
-			 * Ok, so we shouldn't modify the mapent but
49b67f
-			 * mount requests are blocked at a point above
49b67f
-			 * this and expire only uses the mapent key or
49b67f
-			 * holds the cache write lock.
49b67f
-			 */
49b67f
-			free(oe->mapent);
49b67f
-			oe->mapent = NULL;
49b67f
-		}
49b67f
-	}
49b67f
-
49b67f
-	return mounted;
49b67f
-}
49b67f
-
49b67f
-static int rmdir_path_offset(struct autofs_point *ap, struct mapent *oe)
49b67f
-{
49b67f
-	char *dir, *path;
49b67f
-	unsigned int split;
49b67f
-	int ret;
49b67f
-
49b67f
-	if (ap->type == LKP_DIRECT)
49b67f
-		return rmdir_path(ap, oe->key, MM_ROOT(oe)->dev);
49b67f
-
49b67f
-	dir = strdup(oe->key);
49b67f
-
49b67f
-	if (ap->flags & MOUNT_FLAG_GHOST)
49b67f
-		split = ap->len + strlen(MM_ROOT(oe)->key) + 1;
49b67f
-	else
49b67f
-		split = ap->len;
49b67f
-
49b67f
-	dir[split] = '\0';
49b67f
-	path = &dir[split + 1];
49b67f
-
49b67f
-	if (chdir(dir) == -1) {
49b67f
-		error(ap->logopt, "failed to chdir to %s", dir);
49b67f
-		free(dir);
49b67f
-		return -1;
49b67f
-	}
49b67f
-
49b67f
-	ret = rmdir_path(ap, path, ap->dev);
49b67f
-
49b67f
-	free(dir);
49b67f
-
49b67f
-	if (chdir("/") == -1)
49b67f
-		error(ap->logopt, "failed to chdir to /");
49b67f
-
49b67f
-	return ret;
49b67f
-}
49b67f
-
49b67f
-static int do_umount_offset(struct autofs_point *ap,
49b67f
-			    struct mapent *oe, const char *root, int start);
49b67f
-
49b67f
-static int do_umount_multi_triggers(struct autofs_point *ap,
49b67f
-				    struct mapent *me, const char *root,
49b67f
-				    int start, const char *base)
49b67f
-{
49b67f
-	char path[PATH_MAX + 1];
49b67f
-	char *offset;
49b67f
-	struct mapent *oe;
49b67f
-	struct list_head *mm_root, *pos;
49b67f
-	const char o_root[] = "/";
49b67f
-	const char *mm_base;
49b67f
-	int left;
49b67f
-	unsigned int root_len;
49b67f
-	unsigned int mm_base_len;
49b67f
-
49b67f
-	left = 0;
49b67f
-
49b67f
-	mm_root = &me->multi->multi_list;
49b67f
-
49b67f
-	if (!base)
49b67f
-		mm_base = o_root;
49b67f
-	else
49b67f
-		mm_base = base;
49b67f
-
49b67f
-	pos = NULL;
49b67f
-	offset = path;
49b67f
-	root_len = start;
49b67f
-	mm_base_len = strlen(mm_base);
49b67f
-
49b67f
-	while ((offset = cache_get_offset(mm_base, offset, start, mm_root, &pos))) {
49b67f
-		char key[PATH_MAX + 1];
49b67f
-		int key_len = root_len + strlen(offset);
49b67f
-
49b67f
-		if (mm_base_len > 1)
49b67f
-			key_len += mm_base_len;
49b67f
-
49b67f
-		if (key_len > PATH_MAX) {
49b67f
-			warn(ap->logopt, "path loo long");
49b67f
-			continue;
49b67f
-		}
49b67f
-
49b67f
-		strcpy(key, root);
49b67f
-		if (mm_base_len > 1)
49b67f
-			strcat(key, mm_base);
49b67f
-		strcat(key, offset);
49b67f
-
49b67f
-		oe = cache_lookup_distinct(me->mc, key);
49b67f
-		/* root offset is a special case */
49b67f
-		if (!oe || (strlen(oe->key) - start) == 1)
49b67f
-			continue;
49b67f
-
49b67f
-		left += do_umount_offset(ap, oe, root, start);
49b67f
-	}
49b67f
-
49b67f
-	return left;
49b67f
-}
49b67f
-
49b67f
-static int do_umount_offset(struct autofs_point *ap,
49b67f
-			    struct mapent *oe, const char *root, int start)
49b67f
-{
49b67f
-	char *oe_base;
49b67f
-	int left = 0;
49b67f
-
49b67f
-	/*
49b67f
-	 * Check for and umount subtree offsets resulting from
49b67f
-	 * nonstrict mount fail.
49b67f
-	 */
49b67f
-	oe_base = oe->key + start;
49b67f
-	left += do_umount_multi_triggers(ap, oe, root, start, oe_base);
49b67f
-
49b67f
-	/*
49b67f
-	 * If an offset that has an active mount has been removed
49b67f
-	 * from the multi-mount we don't want to attempt to trigger
49b67f
-	 * mounts for it. Obviously this is because it has been
49b67f
-	 * removed, but less obvious is the potential strange
49b67f
-	 * behaviour that can result if we do try and mount it
49b67f
-	 * again after it's been expired. For example, if an NFS
49b67f
-	 * file system is no longer exported and is later umounted
49b67f
-	 * it can be mounted again without any error message but
49b67f
-	 * shows as an empty directory. That's going to confuse
49b67f
-	 * people for sure.
49b67f
-	 *
49b67f
-	 * If the mount cannot be umounted (the process is now
49b67f
-	 * using a stale mount) the offset needs to be invalidated
49b67f
-	 * so no further mounts will be attempted but the offset
49b67f
-	 * cache entry must remain so expires can continue to
49b67f
-	 * attempt to umount it. If the mount can be umounted and
49b67f
-	 * the offset is removed, at least for NFS we will get
49b67f
-	 * ESTALE errors when attempting list the directory.
49b67f
-	 */
49b67f
-	if (oe->ioctlfd != -1 ||
49b67f
-	    is_mounted(oe->key, MNTS_REAL)) {
49b67f
-		if (umount_ent(ap, oe->key) &&
49b67f
-		    is_mounted(oe->key, MNTS_REAL)) {
49b67f
-			debug(ap->logopt,
49b67f
-			      "offset %s has active mount, invalidate",
49b67f
-			      oe->key);
49b67f
-			/*
49b67f
-			 * Ok, so we shouldn't modify the mapent but
49b67f
-			 * mount requests are blocked at a point above
49b67f
-			 * this and expire only uses the mapent key or
49b67f
-			 * holds the cache write lock.
49b67f
-			 */
49b67f
-			if (oe->mapent) {
49b67f
-				free(oe->mapent);
49b67f
-				oe->mapent = NULL;
49b67f
-			}
49b67f
-			return ++left;
49b67f
-		}
49b67f
-	}
49b67f
-
49b67f
-	debug(ap->logopt, "umount offset %s", oe->key);
49b67f
-
49b67f
-	if (umount_autofs_offset(ap, oe)) {
49b67f
-		warn(ap->logopt, "failed to umount offset");
49b67f
-		left++;
49b67f
-	} else {
49b67f
-		struct stat st;
49b67f
-		int ret;
49b67f
-
49b67f
-		if (!(oe->flags & MOUNT_FLAG_DIR_CREATED))
49b67f
-			return left;
49b67f
-
49b67f
-		/*
49b67f
-		 * An error due to partial directory removal is
49b67f
-		 * ok so only try and remount the offset if the
49b67f
-		 * actual mount point still exists.
49b67f
-		 */
49b67f
-		ret = rmdir_path_offset(ap, oe);
49b67f
-		if (ret == -1 && !stat(oe->key, &st)) {
49b67f
-			ret = do_mount_autofs_offset(ap, oe);
49b67f
-			if (ret)
49b67f
-				left++;
49b67f
-			/* But we did origianlly create this */
49b67f
-			oe->flags |= MOUNT_FLAG_DIR_CREATED;
49b67f
-		}
49b67f
-	}
49b67f
-	return left;
49b67f
-}
49b67f
-
49b67f
-int mount_multi_triggers(struct autofs_point *ap, struct mapent *me,
49b67f
-			 const char *root, unsigned int start, const char *base)
49b67f
-{
49b67f
-	char path[PATH_MAX + 1];
49b67f
-	char *offset = path;
49b67f
-	struct mapent *oe;
49b67f
-	struct list_head *pos = NULL;
49b67f
-	unsigned int root_len = strlen(root);
49b67f
-	int mounted;
49b67f
-
49b67f
-	mounted = 0;
49b67f
-	offset = cache_get_offset(base, offset, start, &me->multi_list, &pos;;
49b67f
-	while (offset) {
49b67f
-		char key[PATH_MAX + 1];
49b67f
-		int key_len = root_len + strlen(offset);
49b67f
-
49b67f
-		if (key_len > PATH_MAX) {
49b67f
-			warn(ap->logopt, "path loo long");
49b67f
-			goto cont;
49b67f
-		}
49b67f
-
49b67f
-		/* The root offset is always mounted seperately so the
49b67f
-		 * offset path will always be root + offset.
49b67f
-		 */
49b67f
-		strcpy(key, root);
49b67f
-		strcat(key, offset);
49b67f
-
49b67f
-		oe = cache_lookup_distinct(me->mc, key);
49b67f
-		if (!oe || !oe->mapent)
49b67f
-			goto cont;
49b67f
-		if (oe->age != MM_ROOT(me)->age) {
49b67f
-			/* Best effort */
49b67f
-			do_umount_offset(ap, oe, root, start);
49b67f
-			goto cont;
49b67f
-		}
49b67f
-
49b67f
-		mounted += do_mount_autofs_offset(ap, oe);
49b67f
-
49b67f
-		/*
49b67f
-		 * If re-constructing a multi-mount it's necessary to walk
49b67f
-		 * into nested mounts, unlike the usual "mount only what's
49b67f
-		 * needed as you go" behavior.
49b67f
-		 */
49b67f
-		if (ap->state == ST_READMAP && ap->flags & MOUNT_FLAG_REMOUNT) {
49b67f
-			if (oe->ioctlfd != -1 ||
49b67f
-			    is_mounted(oe->key, MNTS_REAL))
49b67f
-				mount_multi_triggers(ap, oe, key, key_len, base);
49b67f
-		}
49b67f
-cont:
49b67f
-		offset = cache_get_offset(base,
49b67f
-				offset, start, &me->multi_list, &pos;;
49b67f
-	}
49b67f
-
49b67f
-	return mounted;
49b67f
-}
49b67f
-
49b67f
-int umount_multi_triggers(struct autofs_point *ap, struct mapent *me, char *root, const char *base)
49b67f
-{
49b67f
-	int left, start;
49b67f
-
49b67f
-	start = strlen(root);
49b67f
-
49b67f
-	left = do_umount_multi_triggers(ap, me, root, start, base);
49b67f
-
49b67f
-	if (!left && IS_MM_ROOT(me)) {
49b67f
-		/*
49b67f
-		 * Special case.
49b67f
-		 * If we can't umount the root container then we can't
49b67f
-		 * delete the offsets from the cache and we need to put
49b67f
-		 * the offset triggers back.
49b67f
-		 */
49b67f
-		if (is_mounted(root, MNTS_REAL)) {
49b67f
-			info(ap->logopt, "unmounting dir = %s", root);
49b67f
-			if (umount_ent(ap, root) &&
49b67f
-			    is_mounted(root, MNTS_REAL)) {
49b67f
-				if (mount_multi_triggers(ap, me, root, start, "/") < 0)
49b67f
-					warn(ap->logopt,
49b67f
-					     "failed to remount offset triggers");
49b67f
-				return ++left;
49b67f
-			}
49b67f
-		}
49b67f
-
49b67f
-	       /* check for mounted mount entry and remove it if found */
49b67f
-               mnts_remove_mount(root, MNTS_MOUNTED);
49b67f
-	}
49b67f
-
49b67f
-	return left;
49b67f
-}
49b67f
--- autofs-5.1.4.orig/modules/parse_sun.c
49b67f
+++ autofs-5.1.4/modules/parse_sun.c
49b67f
@@ -1076,62 +1076,6 @@ next:
49b67f
 	return (p - ent);
49b67f
 }
49b67f
 
49b67f
-static void cleanup_multi_triggers(struct autofs_point *ap,
49b67f
-			    struct mapent *me, const char *root, int start,
49b67f
-			    const char *base)
49b67f
-{
49b67f
-	char path[PATH_MAX + 1];
49b67f
-	char offset[PATH_MAX + 1];
49b67f
-	char *poffset = offset;
49b67f
-	struct mapent *oe;
49b67f
-	struct list_head *mm_root, *pos;
49b67f
-	const char o_root[] = "/";
49b67f
-	const char *mm_base;
49b67f
-	unsigned int root_len;
49b67f
-	unsigned int mm_base_len;
49b67f
-
49b67f
-	mm_root = &me->multi->multi_list;
49b67f
-
49b67f
-	if (!base)
49b67f
-		mm_base = o_root;
49b67f
-	else
49b67f
-		mm_base = base;
49b67f
-
49b67f
-	pos = NULL;
49b67f
-	root_len = strlen(root);
49b67f
-	mm_base_len = strlen(mm_base);
49b67f
-
49b67f
-	/* Make sure "none" of the offsets have an active mount. */
49b67f
-	while ((poffset = cache_get_offset(mm_base, poffset, start, mm_root, &pos))) {
49b67f
-		unsigned int path_len = root_len + strlen(poffset);
49b67f
-
49b67f
-		if (mm_base_len > 1)
49b67f
-			path_len += mm_base_len;
49b67f
-
49b67f
-		if (path_len > PATH_MAX) {
49b67f
-			warn(ap->logopt, "path loo long");
49b67f
-			continue;
49b67f
-		}
49b67f
-
49b67f
-		strcpy(path, root);
49b67f
-		if (mm_base_len > 1)
49b67f
-			strcat(path, mm_base);
49b67f
-		strcat(path, poffset);
49b67f
-
49b67f
-		oe = cache_lookup_distinct(me->mc, path);
49b67f
-		/* root offset is a special case */
49b67f
-		if (!oe || !oe->mapent || (strlen(oe->key) - start) == 1)
49b67f
-			continue;
49b67f
-
49b67f
-		if (umount(path)) {
49b67f
-			error(ap->logopt, "error recovering from mount fail");
49b67f
-			error(ap->logopt, "cannot umount offset %s", path);
49b67f
-		}
49b67f
-	}
49b67f
-
49b67f
-	return;
49b67f
-}
49b67f
-
49b67f
 static int mount_subtree(struct autofs_point *ap, struct mapent_cache *mc,
49b67f
 			 const char *name, char *loc, char *options, void *ctxt)
49b67f
 {