Blame SOURCES/autofs-5.1.6-remove-unused-function-tree_get_mnt_list.patch

beb904
autofs-5.1.6 - remove unused function tree_get_mnt_list()
beb904
beb904
From: Ian Kent <raven@themaw.net>
beb904
beb904
Remove the now unused function tree_get_mnt_list() and friends.
beb904
beb904
Signed-off-by: Ian Kent <raven@themaw.net>
beb904
---
beb904
 CHANGELOG        |    1 
beb904
 include/mounts.h |   17 ---
beb904
 lib/mounts.c     |  299 -------------------------------------------------------
beb904
 3 files changed, 1 insertion(+), 316 deletions(-)
beb904
beb904
--- autofs-5.1.4.orig/CHANGELOG
beb904
+++ autofs-5.1.4/CHANGELOG
beb904
@@ -130,6 +130,7 @@ xx/xx/2018 autofs-5.1.5
beb904
 - fix stale offset directories disable mount.
beb904
 - use struct mnt_list to track mounted mounts.
beb904
 - use struct mnt_list mounted list for expire.
beb904
+- remove unused function tree_get_mnt_list().
beb904
 
beb904
 19/12/2017 autofs-5.1.4
beb904
 - fix spec file url.
beb904
--- autofs-5.1.4.orig/include/mounts.h
beb904
+++ autofs-5.1.4/include/mounts.h
beb904
@@ -83,20 +83,8 @@ struct mnt_list {
beb904
 	 * List operations ie. get_mnt_list.
beb904
 	 */
beb904
 	struct mnt_list *next;
beb904
-
beb904
-	/*
beb904
-	 * Tree operations ie. tree_make_tree,
beb904
-	 * tree_get_mnt_list etc.
beb904
-	 */
beb904
-	struct mnt_list *left;
beb904
-	struct mnt_list *right;
beb904
-	struct list_head self;
beb904
-	struct list_head list;
beb904
-	struct list_head entries;
beb904
-	struct list_head sublist;
beb904
 };
beb904
 
beb904
-
beb904
 struct nfs_mount_vers {
beb904
 	unsigned int major;
beb904
 	unsigned int minor;
beb904
@@ -143,11 +131,6 @@ void mnts_set_mounted_mount(struct autof
beb904
 int unlink_mount_tree(struct autofs_point *ap, const char *mp);
beb904
 void free_mnt_list(struct mnt_list *list);
beb904
 int is_mounted(const char *mp, unsigned int type);
beb904
-void tree_free_mnt_tree(struct mnt_list *tree);
beb904
-struct mnt_list *tree_make_mnt_tree(const char *path);
beb904
-int tree_get_mnt_list(struct mnt_list *mnts, struct list_head *list, const char *path, int include);
beb904
-int tree_get_mnt_sublist(struct mnt_list *mnts, struct list_head *list, const char *path, int include);
beb904
-int tree_find_mnt_ents(struct mnt_list *mnts, struct list_head *list, const char *path);
beb904
 void set_tsd_user_vars(unsigned int, uid_t, gid_t);
beb904
 const char *mount_type_str(unsigned int);
beb904
 void set_exp_timeout(struct autofs_point *ap, struct map_source *source, time_t timeout);
beb904
--- autofs-5.1.4.orig/lib/mounts.c
beb904
+++ autofs-5.1.4/lib/mounts.c
beb904
@@ -1685,305 +1685,6 @@ int is_mounted(const char *mp, unsigned
beb904
 		return table_is_mounted(mp, type);
beb904
 }
beb904
 
beb904
-/*
beb904
- * Since we have to look at the entire mount tree for direct
beb904
- * mounts (all mounts under "/") and we may have a large number
beb904
- * of entries to traverse again and again we need to
beb904
- * use a more efficient method than the routines above.
beb904
- *
beb904
- * Thre tree_... routines allow us to read the mount tree
beb904
- * once and pass it to subsequent functions for use. Since
beb904
- * it's a tree structure searching should be a low overhead
beb904
- * operation.
beb904
- */
beb904
-void tree_free_mnt_tree(struct mnt_list *tree)
beb904
-{
beb904
-	struct list_head *head, *p;
beb904
-
beb904
-	if (!tree)
beb904
-		return;
beb904
-
beb904
-	tree_free_mnt_tree(tree->left);
beb904
-	tree_free_mnt_tree(tree->right);
beb904
-
beb904
-	head = &tree->self;
beb904
-	p = head->next;
beb904
-	while (p != head) {
beb904
-		struct mnt_list *this;
beb904
-
beb904
-		this = list_entry(p, struct mnt_list, self);
beb904
-
beb904
-		p = p->next;
beb904
-
beb904
-		list_del(&this->self);
beb904
-
beb904
-		free(this->mp);
beb904
-
beb904
-		free(this);
beb904
-	}
beb904
-
beb904
-	free(tree->mp);
beb904
-	free(tree);
beb904
-}
beb904
-
beb904
-/*
beb904
- * Make tree of system mounts in /proc/mounts.
beb904
- */
beb904
-struct mnt_list *tree_make_mnt_tree(const char *path)
beb904
-{
beb904
-	FILE *tab;
beb904
-	struct mntent mnt_wrk;
beb904
-	char buf[PATH_MAX * 3];
beb904
-	struct mntent *mnt;
beb904
-	struct mnt_list *ent, *mptr;
beb904
-	struct mnt_list *tree = NULL;
beb904
-	size_t plen;
beb904
-	int eq;
beb904
-
beb904
-	tab = open_fopen_r(_PROC_MOUNTS);
beb904
-	if (!tab) {
beb904
-		char *estr = strerror_r(errno, buf, PATH_MAX - 1);
beb904
-		logerr("fopen: %s", estr);
beb904
-		return NULL;
beb904
-	}
beb904
-
beb904
-	plen = strlen(path);
beb904
-
beb904
-	while ((mnt = local_getmntent_r(tab, &mnt_wrk, buf, PATH_MAX * 3))) {
beb904
-		size_t len = strlen(mnt->mnt_dir);
beb904
-
beb904
-		/* Not matching path */
beb904
-		if (strncmp(mnt->mnt_dir, path, plen))
beb904
-			continue;
beb904
-
beb904
-		/* Not a subdirectory of requested path */
beb904
-		if (plen > 1 && len > plen && mnt->mnt_dir[plen] != '/')
beb904
-			continue;
beb904
-
beb904
-		ent = malloc(sizeof(*ent));
beb904
-		if (!ent) {
beb904
-			endmntent(tab);
beb904
-			tree_free_mnt_tree(tree);
beb904
-			return NULL;
beb904
-		}
beb904
-		memset(ent, 0, sizeof(*ent));
beb904
-
beb904
-		INIT_LIST_HEAD(&ent->self);
beb904
-		INIT_LIST_HEAD(&ent->list);
beb904
-		INIT_LIST_HEAD(&ent->entries);
beb904
-		INIT_LIST_HEAD(&ent->sublist);
beb904
-
beb904
-		ent->mp = malloc(len + 1);
beb904
-		if (!ent->mp) {
beb904
-			endmntent(tab);
beb904
-			free(ent);
beb904
-			tree_free_mnt_tree(tree);
beb904
-			return NULL;
beb904
-		}
beb904
-		strcpy(ent->mp, mnt->mnt_dir);
beb904
-
beb904
-		if (!strcmp(mnt->mnt_type, "autofs"))
beb904
-			ent->flags |= MNTS_AUTOFS;
beb904
-
beb904
-		if (ent->flags & MNTS_AUTOFS) {
beb904
-			if (strstr(mnt->mnt_opts, "indirect"))
beb904
-				ent->flags |= MNTS_INDIRECT;
beb904
-			else if (strstr(mnt->mnt_opts, "direct"))
beb904
-				ent->flags |= MNTS_DIRECT;
beb904
-			else if (strstr(mnt->mnt_opts, "offset"))
beb904
-				ent->flags |= MNTS_OFFSET;
beb904
-		}
beb904
-
beb904
-		mptr = tree;
beb904
-		while (mptr) {
beb904
-			int elen = strlen(ent->mp);
beb904
-			int mlen = strlen(mptr->mp);
beb904
-
beb904
-			if (elen < mlen) {
beb904
-				if (mptr->left) {
beb904
-					mptr = mptr->left;
beb904
-					continue;
beb904
-				} else {
beb904
-					mptr->left = ent;
beb904
-					break;
beb904
-				}
beb904
-			} else if (elen > mlen) {
beb904
-				if (mptr->right) {
beb904
-					mptr = mptr->right;
beb904
-					continue;
beb904
-				} else {
beb904
-					mptr->right = ent;
beb904
-					break;
beb904
-				}
beb904
-			}
beb904
-
beb904
-			eq = strcmp(ent->mp, mptr->mp);
beb904
-			if (eq < 0) {
beb904
-				if (mptr->left)
beb904
-					mptr = mptr->left;
beb904
-				else {
beb904
-					mptr->left = ent;
beb904
-					break;
beb904
-				}
beb904
-			} else if (eq > 0) {
beb904
-				if (mptr->right)
beb904
-					mptr = mptr->right;
beb904
-				else {
beb904
-					mptr->right = ent;
beb904
-					break;
beb904
-				}
beb904
-			} else {
beb904
-				list_add_tail(&ent->self, &mptr->self);
beb904
-				break;
beb904
-			}
beb904
-		}
beb904
-
beb904
-		if (!tree)
beb904
-			tree = ent;
beb904
-	}
beb904
-	fclose(tab);
beb904
-
beb904
-	return tree;
beb904
-}
beb904
-
beb904
-/*
beb904
- * Get list of mounts under "path" in longest->shortest order
beb904
- */
beb904
-int tree_get_mnt_list(struct mnt_list *mnts, struct list_head *list, const char *path, int include)
beb904
-{
beb904
-	size_t mlen, plen;
beb904
-
beb904
-	if (!mnts)
beb904
-		return 0;
beb904
-
beb904
-	plen = strlen(path);
beb904
-	mlen = strlen(mnts->mp);
beb904
-	if (mlen < plen)
beb904
-		return tree_get_mnt_list(mnts->right, list, path, include);
beb904
-	else {
beb904
-		struct list_head *self, *p;
beb904
-
beb904
-		tree_get_mnt_list(mnts->left, list, path, include);
beb904
-
beb904
-		if ((!include && mlen <= plen) ||
beb904
-				strncmp(mnts->mp, path, plen))
beb904
-			goto skip;
beb904
-
beb904
-		if (plen > 1 && mlen > plen && mnts->mp[plen] != '/')
beb904
-			goto skip;
beb904
-
beb904
-		INIT_LIST_HEAD(&mnts->list);
beb904
-		list_add(&mnts->list, list);
beb904
-
beb904
-		self = &mnts->self;
beb904
-		list_for_each(p, self) {
beb904
-			struct mnt_list *this;
beb904
-
beb904
-			this = list_entry(p, struct mnt_list, self);
beb904
-			INIT_LIST_HEAD(&this->list);
beb904
-			list_add(&this->list, list);
beb904
-		}
beb904
-skip:
beb904
-		tree_get_mnt_list(mnts->right, list, path, include);
beb904
-	}
beb904
-
beb904
-	if (list_empty(list))
beb904
-		return 0;
beb904
-
beb904
-	return 1;
beb904
-}
beb904
-
beb904
-/*
beb904
- * Get list of mounts under "path" in longest->shortest order
beb904
- */
beb904
-int tree_get_mnt_sublist(struct mnt_list *mnts, struct list_head *list, const char *path, int include)
beb904
-{
beb904
-	size_t mlen, plen;
beb904
-
beb904
-	if (!mnts)
beb904
-		return 0;
beb904
-
beb904
-	plen = strlen(path);
beb904
-	mlen = strlen(mnts->mp);
beb904
-	if (mlen < plen)
beb904
-		return tree_get_mnt_sublist(mnts->right, list, path, include);
beb904
-	else {
beb904
-		struct list_head *self, *p;
beb904
-
beb904
-		tree_get_mnt_sublist(mnts->left, list, path, include);
beb904
-
beb904
-		if ((!include && mlen <= plen) ||
beb904
-				strncmp(mnts->mp, path, plen))
beb904
-			goto skip;
beb904
-
beb904
-		if (plen > 1 && mlen > plen && mnts->mp[plen] != '/')
beb904
-			goto skip;
beb904
-
beb904
-		INIT_LIST_HEAD(&mnts->sublist);
beb904
-		list_add(&mnts->sublist, list);
beb904
-
beb904
-		self = &mnts->self;
beb904
-		list_for_each(p, self) {
beb904
-			struct mnt_list *this;
beb904
-
beb904
-			this = list_entry(p, struct mnt_list, self);
beb904
-			INIT_LIST_HEAD(&this->sublist);
beb904
-			list_add(&this->sublist, list);
beb904
-		}
beb904
-skip:
beb904
-		tree_get_mnt_sublist(mnts->right, list, path, include);
beb904
-	}
beb904
-
beb904
-	if (list_empty(list))
beb904
-		return 0;
beb904
-
beb904
-	return 1;
beb904
-}
beb904
-
beb904
-int tree_find_mnt_ents(struct mnt_list *mnts, struct list_head *list, const char *path)
beb904
-{
beb904
-	int mlen, plen;
beb904
-
beb904
-	if (!mnts)
beb904
-		return 0;
beb904
-
beb904
-	plen = strlen(path);
beb904
-	mlen = strlen(mnts->mp);
beb904
-	if (mlen < plen)
beb904
-		return tree_find_mnt_ents(mnts->right, list, path);
beb904
-	else if (mlen > plen)
beb904
-		return tree_find_mnt_ents(mnts->left, list, path);
beb904
-	else {
beb904
-		struct list_head *self, *p;
beb904
-
beb904
-		tree_find_mnt_ents(mnts->left, list, path);
beb904
-
beb904
-		if (!strcmp(mnts->mp, path)) {
beb904
-			INIT_LIST_HEAD(&mnts->entries);
beb904
-			list_add(&mnts->entries, list);
beb904
-		}
beb904
-
beb904
-		self = &mnts->self;
beb904
-		list_for_each(p, self) {
beb904
-			struct mnt_list *this;
beb904
-
beb904
-			this = list_entry(p, struct mnt_list, self);
beb904
-
beb904
-			if (!strcmp(this->mp, path)) {
beb904
-				INIT_LIST_HEAD(&this->entries);
beb904
-				list_add(&this->entries, list);
beb904
-			}
beb904
-		}
beb904
-
beb904
-		tree_find_mnt_ents(mnts->right, list, path);
beb904
-
beb904
-		if (!list_empty(list))
beb904
-			return 1;
beb904
-	}
beb904
-
beb904
-	return 0;
beb904
-}
beb904
-
beb904
 void set_tsd_user_vars(unsigned int logopt, uid_t uid, gid_t gid)
beb904
 {
beb904
 	struct thread_stdenv_vars *tsv;