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

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