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

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