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

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