Blame SOURCES/autofs-5.1.5-use-mp-instead-of-path-in-mnt_list-entries.patch

8fa62f
autofs-5.1.5 - use mp instead of path in mnt_list entries
8fa62f
8fa62f
From: Ian Kent <raven@themaw.net>
8fa62f
8fa62f
Use the simpler, more instructive mp instead of path in the
8fa62f
mnt_list structure.
8fa62f
8fa62f
Signed-off-by: Ian Kent <raven@themaw.net>
8fa62f
---
8fa62f
 CHANGELOG         |    1 
8fa62f
 daemon/direct.c   |   18 ++++++-------
8fa62f
 daemon/indirect.c |   22 ++++++++--------
8fa62f
 include/mounts.h  |    4 +--
8fa62f
 lib/mounts.c      |   70 +++++++++++++++++++++++++++---------------------------
8fa62f
 5 files changed, 58 insertions(+), 57 deletions(-)
8fa62f
8fa62f
--- autofs-5.1.4.orig/CHANGELOG
8fa62f
+++ autofs-5.1.4/CHANGELOG
8fa62f
@@ -64,6 +64,7 @@ xx/xx/2018 autofs-5.1.5
8fa62f
 - use ignore option for offset mounts as well.
8fa62f
 - add config option for "ignore" mount option
8fa62f
 - use bit flags for autofs mount types in mnt_list.
8fa62f
+- use mp instead of path in mnt_list entries.
8fa62f
 
8fa62f
 19/12/2017 autofs-5.1.4
8fa62f
 - fix spec file url.
8fa62f
--- autofs-5.1.4.orig/daemon/direct.c
8fa62f
+++ autofs-5.1.4/daemon/direct.c
8fa62f
@@ -272,12 +272,12 @@ static int unlink_mount_tree(struct auto
8fa62f
 		mnt = list_entry(p, struct mnt_list, list);
8fa62f
 
8fa62f
 		if (mnt->flags & MNTS_AUTOFS)
8fa62f
-			rv = umount2(mnt->path, MNT_DETACH);
8fa62f
+			rv = umount2(mnt->mp, MNT_DETACH);
8fa62f
 		else
8fa62f
-			rv = spawn_umount(ap->logopt, "-l", mnt->path, NULL);
8fa62f
+			rv = spawn_umount(ap->logopt, "-l", mnt->mp, NULL);
8fa62f
 		if (rv == -1) {
8fa62f
 			debug(ap->logopt,
8fa62f
-			      "can't unlink %s from mount tree", mnt->path);
8fa62f
+			      "can't unlink %s from mount tree", mnt->mp);
8fa62f
 
8fa62f
 			switch (errno) {
8fa62f
 			case EINVAL:
8fa62f
@@ -920,7 +920,7 @@ void *expire_proc_direct(void *arg)
8fa62f
 		 */
8fa62f
 		pthread_cleanup_push(master_source_lock_cleanup, ap->entry);
8fa62f
 		master_source_readlock(ap->entry);
8fa62f
-		me = lookup_source_mapent(ap, next->path, LKP_DISTINCT);
8fa62f
+		me = lookup_source_mapent(ap, next->mp, LKP_DISTINCT);
8fa62f
 		pthread_cleanup_pop(1);
8fa62f
 		if (!me)
8fa62f
 			continue;
8fa62f
@@ -937,7 +937,7 @@ void *expire_proc_direct(void *arg)
8fa62f
 			 */
8fa62f
 			pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state);
8fa62f
 			if (next->flags & MNTS_INDIRECT) {
8fa62f
-				master_notify_submount(ap, next->path, ap->state);
8fa62f
+				master_notify_submount(ap, next->mp, ap->state);
8fa62f
 				pthread_setcancelstate(cur_state, NULL);
8fa62f
 				continue;
8fa62f
 			}
8fa62f
@@ -968,7 +968,7 @@ void *expire_proc_direct(void *arg)
8fa62f
 			cache_writelock(me->mc);
8fa62f
 			if (me->ioctlfd != -1 && 
8fa62f
 			    fstat(me->ioctlfd, &st) != -1 &&
8fa62f
-			    !count_mounts(ap, next->path, st.st_dev)) {
8fa62f
+			    !count_mounts(ap, next->mp, st.st_dev)) {
8fa62f
 				ops->close(ap->logopt, me->ioctlfd);
8fa62f
 				me->ioctlfd = -1;
8fa62f
 				cache_unlock(me->mc);
8fa62f
@@ -979,7 +979,7 @@ void *expire_proc_direct(void *arg)
8fa62f
 
8fa62f
 			ioctlfd = me->ioctlfd;
8fa62f
 
8fa62f
-			ret = ops->expire(ap->logopt, ioctlfd, next->path, how);
8fa62f
+			ret = ops->expire(ap->logopt, ioctlfd, next->mp, how);
8fa62f
 			if (ret) {
8fa62f
 				left++;
8fa62f
 				pthread_setcancelstate(cur_state, NULL);
8fa62f
@@ -1002,10 +1002,10 @@ void *expire_proc_direct(void *arg)
8fa62f
 		if (ap->state == ST_EXPIRE || ap->state == ST_PRUNE)
8fa62f
 			pthread_testcancel();
8fa62f
 
8fa62f
-		debug(ap->logopt, "send expire to trigger %s", next->path);
8fa62f
+		debug(ap->logopt, "send expire to trigger %s", next->mp);
8fa62f
 
8fa62f
 		pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state);
8fa62f
-		ret = ops->expire(ap->logopt, ioctlfd, next->path, how);
8fa62f
+		ret = ops->expire(ap->logopt, ioctlfd, next->mp, how);
8fa62f
 		if (ret)
8fa62f
 			left++;
8fa62f
 		pthread_setcancelstate(cur_state, NULL);
8fa62f
--- autofs-5.1.4.orig/daemon/indirect.c
8fa62f
+++ autofs-5.1.4/daemon/indirect.c
8fa62f
@@ -49,12 +49,12 @@ static int unlink_mount_tree(struct auto
8fa62f
 	this = mnts;
8fa62f
 	while (this) {
8fa62f
 		if (this->flags & MNTS_AUTOFS)
8fa62f
-			rv = umount2(this->path, MNT_DETACH);
8fa62f
+			rv = umount2(this->mp, MNT_DETACH);
8fa62f
 		else
8fa62f
-			rv = spawn_umount(ap->logopt, "-l", this->path, NULL);
8fa62f
+			rv = spawn_umount(ap->logopt, "-l", this->mp, NULL);
8fa62f
 		if (rv == -1) {
8fa62f
 			debug(ap->logopt,
8fa62f
-			      "can't unlink %s from mount tree", this->path);
8fa62f
+			      "can't unlink %s from mount tree", this->mp);
8fa62f
 
8fa62f
 			switch (errno) {
8fa62f
 			case EINVAL:
8fa62f
@@ -446,7 +446,7 @@ void *expire_proc_indirect(void *arg)
8fa62f
 			 */
8fa62f
 			pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state);
8fa62f
 			if (next->flags & MNTS_INDIRECT)
8fa62f
-				master_notify_submount(ap, next->path, ap->state);
8fa62f
+				master_notify_submount(ap, next->mp, ap->state);
8fa62f
 			else if (next->flags & MNTS_OFFSET) {
8fa62f
 				struct map_source *map;
8fa62f
 				struct mapent_cache *mc = NULL;
8fa62f
@@ -454,13 +454,13 @@ void *expire_proc_indirect(void *arg)
8fa62f
 				struct stat st;
8fa62f
 
8fa62f
 				/* It's got a mount, deal with in the outer loop */
8fa62f
-				if (is_mounted(_PATH_MOUNTED, next->path, MNTS_REAL)) {
8fa62f
+				if (is_mounted(_PATH_MOUNTED, next->mp, MNTS_REAL)) {
8fa62f
 					pthread_setcancelstate(cur_state, NULL);
8fa62f
 					continue;
8fa62f
 				}
8fa62f
 
8fa62f
 				/* Don't touch submounts */
8fa62f
-				if (master_find_submount(ap, next->path)) {
8fa62f
+				if (master_find_submount(ap, next->mp)) {
8fa62f
 					pthread_setcancelstate(cur_state, NULL);
8fa62f
 					continue;
8fa62f
 				}
8fa62f
@@ -471,7 +471,7 @@ void *expire_proc_indirect(void *arg)
8fa62f
 				while (map) {
8fa62f
 					mc = map->mc;
8fa62f
 					cache_writelock(mc);
8fa62f
-					me = cache_lookup_distinct(mc, next->path);
8fa62f
+					me = cache_lookup_distinct(mc, next->mp);
8fa62f
 					if (me)
8fa62f
 						break;
8fa62f
 					cache_unlock(mc);
8fa62f
@@ -513,7 +513,7 @@ void *expire_proc_indirect(void *arg)
8fa62f
 		 * If the mount corresponds to an offset trigger then
8fa62f
 		 * the key is the path, otherwise it's the last component.
8fa62f
 		 */
8fa62f
-		ind_key = strrchr(next->path, '/');
8fa62f
+		ind_key = strrchr(next->mp, '/');
8fa62f
 		if (ind_key)
8fa62f
 			ind_key++;
8fa62f
 
8fa62f
@@ -526,7 +526,7 @@ void *expire_proc_indirect(void *arg)
8fa62f
 		 */
8fa62f
 		pthread_cleanup_push(master_source_lock_cleanup, ap->entry);
8fa62f
 		master_source_readlock(ap->entry);
8fa62f
-		me = lookup_source_mapent(ap, next->path, LKP_DISTINCT);
8fa62f
+		me = lookup_source_mapent(ap, next->mp, LKP_DISTINCT);
8fa62f
 		if (!me && ind_key)
8fa62f
 			me = lookup_source_mapent(ap, ind_key, LKP_NORMAL);
8fa62f
 		pthread_cleanup_pop(1);
8fa62f
@@ -538,10 +538,10 @@ void *expire_proc_indirect(void *arg)
8fa62f
 			cache_unlock(me->mc);
8fa62f
 		}
8fa62f
 
8fa62f
-		debug(ap->logopt, "expire %s", next->path);
8fa62f
+		debug(ap->logopt, "expire %s", next->mp);
8fa62f
 
8fa62f
 		pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state);
8fa62f
-		ret = ops->expire(ap->logopt, ioctlfd, next->path, how);
8fa62f
+		ret = ops->expire(ap->logopt, ioctlfd, next->mp, how);
8fa62f
 		if (ret)
8fa62f
 			left++;
8fa62f
 		pthread_setcancelstate(cur_state, NULL);
8fa62f
--- autofs-5.1.4.orig/include/mounts.h
8fa62f
+++ autofs-5.1.4/include/mounts.h
8fa62f
@@ -52,7 +52,7 @@ extern const unsigned int t_offset;
8fa62f
 struct mapent;
8fa62f
 
8fa62f
 struct mnt_list {
8fa62f
-	char *path;
8fa62f
+	char *mp;
8fa62f
 	unsigned int flags;
8fa62f
 	/*
8fa62f
 	 * List operations ie. get_mnt_list.
8fa62f
@@ -101,7 +101,7 @@ int ext_mount_remove(struct list_head *,
8fa62f
 int ext_mount_inuse(const char *);
8fa62f
 struct mnt_list *get_mnt_list(const char *table, const char *path, int include);
8fa62f
 void free_mnt_list(struct mnt_list *list);
8fa62f
-int is_mounted(const char *table, const char *path, unsigned int type);
8fa62f
+int is_mounted(const char *table, const char *mp, unsigned int type);
8fa62f
 void tree_free_mnt_tree(struct mnt_list *tree);
8fa62f
 struct mnt_list *tree_make_mnt_tree(const char *table, const char *path);
8fa62f
 int tree_get_mnt_list(struct mnt_list *mnts, struct list_head *list, const char *path, int include);
8fa62f
--- autofs-5.1.4.orig/lib/mounts.c
8fa62f
+++ autofs-5.1.4/lib/mounts.c
8fa62f
@@ -817,8 +817,8 @@ struct mnt_list *get_mnt_list(const char
8fa62f
 	  	     strncmp(mnt->mnt_dir, path, pathlen) != 0)
8fa62f
 			continue;
8fa62f
 
8fa62f
-		/* Not a subdirectory of requested path ? */
8fa62f
-		/* pathlen == 1 => everything is subdir    */
8fa62f
+		/* Not a subdirectory of requested mp? */
8fa62f
+		/* mp_len == 1 => everything is subdir    */
8fa62f
 		if (pathlen > 1 && len > pathlen &&
8fa62f
 				mnt->mnt_dir[pathlen] != '/')
8fa62f
 			continue;
8fa62f
@@ -834,7 +834,7 @@ struct mnt_list *get_mnt_list(const char
8fa62f
 		mptr = list;
8fa62f
 		last = NULL;
8fa62f
 		while (mptr) {
8fa62f
-			if (len >= strlen(mptr->path))
8fa62f
+			if (len >= strlen(mptr->mp))
8fa62f
 				break;
8fa62f
 			last = mptr;
8fa62f
 			mptr = mptr->next;
8fa62f
@@ -847,13 +847,13 @@ struct mnt_list *get_mnt_list(const char
8fa62f
 
8fa62f
 		ent->next = mptr;
8fa62f
 
8fa62f
-		ent->path = malloc(len + 1);
8fa62f
-		if (!ent->path) {
8fa62f
+		ent->mp = malloc(len + 1);
8fa62f
+		if (!ent->mp) {
8fa62f
 			endmntent(tab);
8fa62f
 			free_mnt_list(list);
8fa62f
 			return NULL;
8fa62f
 		}
8fa62f
-		strcpy(ent->path, mnt->mnt_dir);
8fa62f
+		strcpy(ent->mp, mnt->mnt_dir);
8fa62f
 
8fa62f
 		if (!strcmp(mnt->mnt_type, "autofs"))
8fa62f
 			ent->flags |= MNTS_AUTOFS;
8fa62f
@@ -885,23 +885,23 @@ void free_mnt_list(struct mnt_list *list
8fa62f
 
8fa62f
 		next = this->next;
8fa62f
 
8fa62f
-		if (this->path)
8fa62f
-			free(this->path);
8fa62f
+		if (this->mp)
8fa62f
+			free(this->mp);
8fa62f
 
8fa62f
 		free(this);
8fa62f
 	}
8fa62f
 }
8fa62f
 
8fa62f
-static int table_is_mounted(const char *table, const char *path, unsigned int type)
8fa62f
+static int table_is_mounted(const char *table, const char *mp, unsigned int type)
8fa62f
 {
8fa62f
 	struct mntent *mnt;
8fa62f
 	struct mntent mnt_wrk;
8fa62f
 	char buf[PATH_MAX * 3];
8fa62f
-	size_t pathlen = strlen(path);
8fa62f
+	size_t mp_len = strlen(mp);
8fa62f
 	FILE *tab;
8fa62f
 	int ret = 0;
8fa62f
 
8fa62f
-	if (!path || !pathlen || pathlen >= PATH_MAX)
8fa62f
+	if (!mp || !mp_len || mp_len >= PATH_MAX)
8fa62f
 		return 0;
8fa62f
 
8fa62f
 	tab = open_setmntent_r(table);
8fa62f
@@ -928,7 +928,7 @@ static int table_is_mounted(const char *
8fa62f
 					continue;
8fa62f
 		}
8fa62f
 
8fa62f
-		if (pathlen == len && !strncmp(path, mnt->mnt_dir, pathlen)) {
8fa62f
+		if (mp_len == len && !strncmp(mp, mnt->mnt_dir, mp_len)) {
8fa62f
 			ret = 1;
8fa62f
 			break;
8fa62f
 		}
8fa62f
@@ -938,7 +938,7 @@ static int table_is_mounted(const char *
8fa62f
 	return ret;
8fa62f
 }
8fa62f
 
8fa62f
-static int ioctl_is_mounted(const char *table, const char *path, unsigned int type)
8fa62f
+static int ioctl_is_mounted(const char *table, const char *mp, unsigned int type)
8fa62f
 {
8fa62f
 	struct ioctl_ops *ops = get_ioctl_ops();
8fa62f
 	unsigned int mounted;
8fa62f
@@ -947,9 +947,9 @@ static int ioctl_is_mounted(const char *
8fa62f
 	/* If the ioctl fails fall back to the potentially resource
8fa62f
 	 * intensive mount table check.
8fa62f
 	 */
8fa62f
-	ret = ops->ismountpoint(LOGOPT_NONE, -1, path, &mounted);
8fa62f
+	ret = ops->ismountpoint(LOGOPT_NONE, -1, mp, &mounted);
8fa62f
 	if (ret == -1)
8fa62f
-		return table_is_mounted(table, path, type);
8fa62f
+		return table_is_mounted(table, mp, type);
8fa62f
 
8fa62f
 	if (mounted) {
8fa62f
 		switch (type) {
8fa62f
@@ -964,14 +964,14 @@ static int ioctl_is_mounted(const char *
8fa62f
 	return 0;
8fa62f
 }
8fa62f
 
8fa62f
-int is_mounted(const char *table, const char *path, unsigned int type)
8fa62f
+int is_mounted(const char *table, const char *mp, unsigned int type)
8fa62f
 {
8fa62f
 	struct ioctl_ops *ops = get_ioctl_ops();
8fa62f
 
8fa62f
 	if (ops->ismountpoint)
8fa62f
-		return ioctl_is_mounted(table, path, type);
8fa62f
+		return ioctl_is_mounted(table, mp, type);
8fa62f
 	else
8fa62f
-		return table_is_mounted(table, path, type);
8fa62f
+		return table_is_mounted(table, mp, type);
8fa62f
 }
8fa62f
 
8fa62f
 /*
8fa62f
@@ -1006,12 +1006,12 @@ void tree_free_mnt_tree(struct mnt_list
8fa62f
 
8fa62f
 		list_del(&this->self);
8fa62f
 
8fa62f
-		free(this->path);
8fa62f
+		free(this->mp);
8fa62f
 
8fa62f
 		free(this);
8fa62f
 	}
8fa62f
 
8fa62f
-	free(tree->path);
8fa62f
+	free(tree->mp);
8fa62f
 	free(tree);
8fa62f
 }
8fa62f
 
8fa62f
@@ -1062,14 +1062,14 @@ struct mnt_list *tree_make_mnt_tree(cons
8fa62f
 		INIT_LIST_HEAD(&ent->entries);
8fa62f
 		INIT_LIST_HEAD(&ent->sublist);
8fa62f
 
8fa62f
-		ent->path = malloc(len + 1);
8fa62f
-		if (!ent->path) {
8fa62f
+		ent->mp = malloc(len + 1);
8fa62f
+		if (!ent->mp) {
8fa62f
 			endmntent(tab);
8fa62f
 			free(ent);
8fa62f
 			tree_free_mnt_tree(tree);
8fa62f
 			return NULL;
8fa62f
 		}
8fa62f
-		strcpy(ent->path, mnt->mnt_dir);
8fa62f
+		strcpy(ent->mp, mnt->mnt_dir);
8fa62f
 
8fa62f
 		if (!strcmp(mnt->mnt_type, "autofs"))
8fa62f
 			ent->flags |= MNTS_AUTOFS;
8fa62f
@@ -1085,8 +1085,8 @@ struct mnt_list *tree_make_mnt_tree(cons
8fa62f
 
8fa62f
 		mptr = tree;
8fa62f
 		while (mptr) {
8fa62f
-			int elen = strlen(ent->path);
8fa62f
-			int mlen = strlen(mptr->path);
8fa62f
+			int elen = strlen(ent->mp);
8fa62f
+			int mlen = strlen(mptr->mp);
8fa62f
 
8fa62f
 			if (elen < mlen) {
8fa62f
 				if (mptr->left) {
8fa62f
@@ -1106,7 +1106,7 @@ struct mnt_list *tree_make_mnt_tree(cons
8fa62f
 				}
8fa62f
 			}
8fa62f
 
8fa62f
-			eq = strcmp(ent->path, mptr->path);
8fa62f
+			eq = strcmp(ent->mp, mptr->mp);
8fa62f
 			if (eq < 0) {
8fa62f
 				if (mptr->left)
8fa62f
 					mptr = mptr->left;
8fa62f
@@ -1146,7 +1146,7 @@ int tree_get_mnt_list(struct mnt_list *m
8fa62f
 		return 0;
8fa62f
 
8fa62f
 	plen = strlen(path);
8fa62f
-	mlen = strlen(mnts->path);
8fa62f
+	mlen = strlen(mnts->mp);
8fa62f
 	if (mlen < plen)
8fa62f
 		return tree_get_mnt_list(mnts->right, list, path, include);
8fa62f
 	else {
8fa62f
@@ -1155,10 +1155,10 @@ int tree_get_mnt_list(struct mnt_list *m
8fa62f
 		tree_get_mnt_list(mnts->left, list, path, include);
8fa62f
 
8fa62f
 		if ((!include && mlen <= plen) ||
8fa62f
-				strncmp(mnts->path, path, plen))
8fa62f
+				strncmp(mnts->mp, path, plen))
8fa62f
 			goto skip;
8fa62f
 
8fa62f
-		if (plen > 1 && mlen > plen && mnts->path[plen] != '/')
8fa62f
+		if (plen > 1 && mlen > plen && mnts->mp[plen] != '/')
8fa62f
 			goto skip;
8fa62f
 
8fa62f
 		INIT_LIST_HEAD(&mnts->list);
8fa62f
@@ -1193,7 +1193,7 @@ int tree_get_mnt_sublist(struct mnt_list
8fa62f
 		return 0;
8fa62f
 
8fa62f
 	plen = strlen(path);
8fa62f
-	mlen = strlen(mnts->path);
8fa62f
+	mlen = strlen(mnts->mp);
8fa62f
 	if (mlen < plen)
8fa62f
 		return tree_get_mnt_sublist(mnts->right, list, path, include);
8fa62f
 	else {
8fa62f
@@ -1202,10 +1202,10 @@ int tree_get_mnt_sublist(struct mnt_list
8fa62f
 		tree_get_mnt_sublist(mnts->left, list, path, include);
8fa62f
 
8fa62f
 		if ((!include && mlen <= plen) ||
8fa62f
-				strncmp(mnts->path, path, plen))
8fa62f
+				strncmp(mnts->mp, path, plen))
8fa62f
 			goto skip;
8fa62f
 
8fa62f
-		if (plen > 1 && mlen > plen && mnts->path[plen] != '/')
8fa62f
+		if (plen > 1 && mlen > plen && mnts->mp[plen] != '/')
8fa62f
 			goto skip;
8fa62f
 
8fa62f
 		INIT_LIST_HEAD(&mnts->sublist);
8fa62f
@@ -1237,7 +1237,7 @@ int tree_find_mnt_ents(struct mnt_list *
8fa62f
 		return 0;
8fa62f
 
8fa62f
 	plen = strlen(path);
8fa62f
-	mlen = strlen(mnts->path);
8fa62f
+	mlen = strlen(mnts->mp);
8fa62f
 	if (mlen < plen)
8fa62f
 		return tree_find_mnt_ents(mnts->right, list, path);
8fa62f
 	else if (mlen > plen)
8fa62f
@@ -1247,7 +1247,7 @@ int tree_find_mnt_ents(struct mnt_list *
8fa62f
 
8fa62f
 		tree_find_mnt_ents(mnts->left, list, path);
8fa62f
 
8fa62f
-		if (!strcmp(mnts->path, path)) {
8fa62f
+		if (!strcmp(mnts->mp, path)) {
8fa62f
 			INIT_LIST_HEAD(&mnts->entries);
8fa62f
 			list_add(&mnts->entries, list);
8fa62f
 		}
8fa62f
@@ -1258,7 +1258,7 @@ int tree_find_mnt_ents(struct mnt_list *
8fa62f
 
8fa62f
 			this = list_entry(p, struct mnt_list, self);
8fa62f
 
8fa62f
-			if (!strcmp(this->path, path)) {
8fa62f
+			if (!strcmp(this->mp, path)) {
8fa62f
 				INIT_LIST_HEAD(&this->entries);
8fa62f
 				list_add(&this->entries, list);
8fa62f
 			}