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

c8d72b
autofs-5.1.5 - use mp instead of path in mnt_list entries
c8d72b
c8d72b
From: Ian Kent <raven@themaw.net>
c8d72b
c8d72b
Use the simpler, more instructive mp instead of path in the
c8d72b
mnt_list structure.
c8d72b
c8d72b
Signed-off-by: Ian Kent <raven@themaw.net>
c8d72b
---
c8d72b
 CHANGELOG         |    1 
c8d72b
 daemon/direct.c   |   18 +++++++-------
c8d72b
 daemon/indirect.c |   22 ++++++++---------
c8d72b
 include/mounts.h  |    4 +--
c8d72b
 lib/mounts.c      |   68 +++++++++++++++++++++++++++---------------------------
c8d72b
 5 files changed, 57 insertions(+), 56 deletions(-)
c8d72b
c8d72b
--- autofs-5.0.7.orig/CHANGELOG
c8d72b
+++ autofs-5.0.7/CHANGELOG
c8d72b
@@ -338,6 +338,7 @@
c8d72b
 - use ignore option for offset mounts as well.
c8d72b
 - add config option for "ignore" mount option
c8d72b
 - use bit flags for autofs mount types in mnt_list.
c8d72b
+- use mp instead of path in mnt_list entries.
c8d72b
 
c8d72b
 25/07/2012 autofs-5.0.7
c8d72b
 =======================
c8d72b
--- autofs-5.0.7.orig/daemon/direct.c
c8d72b
+++ autofs-5.0.7/daemon/direct.c
c8d72b
@@ -272,12 +272,12 @@ static int unlink_mount_tree(struct auto
c8d72b
 		mnt = list_entry(p, struct mnt_list, list);
c8d72b
 
c8d72b
 		if (mnt->flags & MNTS_AUTOFS)
c8d72b
-			rv = umount2(mnt->path, MNT_DETACH);
c8d72b
+			rv = umount2(mnt->mp, MNT_DETACH);
c8d72b
 		else
c8d72b
-			rv = spawn_umount(ap->logopt, "-l", mnt->path, NULL);
c8d72b
+			rv = spawn_umount(ap->logopt, "-l", mnt->mp, NULL);
c8d72b
 		if (rv == -1) {
c8d72b
 			debug(ap->logopt,
c8d72b
-			      "can't unlink %s from mount tree", mnt->path);
c8d72b
+			      "can't unlink %s from mount tree", mnt->mp);
c8d72b
 
c8d72b
 			switch (errno) {
c8d72b
 			case EINVAL:
c8d72b
@@ -906,7 +906,7 @@ void *expire_proc_direct(void *arg)
c8d72b
 		 */
c8d72b
 		pthread_cleanup_push(master_source_lock_cleanup, ap->entry);
c8d72b
 		master_source_readlock(ap->entry);
c8d72b
-		me = lookup_source_mapent(ap, next->path, LKP_DISTINCT);
c8d72b
+		me = lookup_source_mapent(ap, next->mp, LKP_DISTINCT);
c8d72b
 		pthread_cleanup_pop(1);
c8d72b
 		if (!me)
c8d72b
 			continue;
c8d72b
@@ -923,7 +923,7 @@ void *expire_proc_direct(void *arg)
c8d72b
 			 */
c8d72b
 			pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state);
c8d72b
 			if (next->flags & MNTS_INDIRECT) {
c8d72b
-				master_notify_submount(ap, next->path, ap->state);
c8d72b
+				master_notify_submount(ap, next->mp, ap->state);
c8d72b
 				pthread_setcancelstate(cur_state, NULL);
c8d72b
 				continue;
c8d72b
 			}
c8d72b
@@ -954,7 +954,7 @@ void *expire_proc_direct(void *arg)
c8d72b
 			cache_writelock(me->mc);
c8d72b
 			if (me->ioctlfd != -1 && 
c8d72b
 			    fstat(me->ioctlfd, &st) != -1 &&
c8d72b
-			    !count_mounts(ap, next->path, st.st_dev)) {
c8d72b
+			    !count_mounts(ap, next->mp, st.st_dev)) {
c8d72b
 				ops->close(ap->logopt, me->ioctlfd);
c8d72b
 				me->ioctlfd = -1;
c8d72b
 				cache_unlock(me->mc);
c8d72b
@@ -965,7 +965,7 @@ void *expire_proc_direct(void *arg)
c8d72b
 
c8d72b
 			ioctlfd = me->ioctlfd;
c8d72b
 
c8d72b
-			ret = ops->expire(ap->logopt, ioctlfd, next->path, now);
c8d72b
+			ret = ops->expire(ap->logopt, ioctlfd, next->mp, now);
c8d72b
 			if (ret) {
c8d72b
 				left++;
c8d72b
 				pthread_setcancelstate(cur_state, NULL);
c8d72b
@@ -988,10 +988,10 @@ void *expire_proc_direct(void *arg)
c8d72b
 		if (ap->state == ST_EXPIRE || ap->state == ST_PRUNE)
c8d72b
 			pthread_testcancel();
c8d72b
 
c8d72b
-		debug(ap->logopt, "send expire to trigger %s", next->path);
c8d72b
+		debug(ap->logopt, "send expire to trigger %s", next->mp);
c8d72b
 
c8d72b
 		pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state);
c8d72b
-		ret = ops->expire(ap->logopt, ioctlfd, next->path, now);
c8d72b
+		ret = ops->expire(ap->logopt, ioctlfd, next->mp, now);
c8d72b
 		if (ret)
c8d72b
 			left++;
c8d72b
 		pthread_setcancelstate(cur_state, NULL);
c8d72b
--- autofs-5.0.7.orig/daemon/indirect.c
c8d72b
+++ autofs-5.0.7/daemon/indirect.c
c8d72b
@@ -49,12 +49,12 @@ static int unlink_mount_tree(struct auto
c8d72b
 	this = mnts;
c8d72b
 	while (this) {
c8d72b
 		if (this->flags & MNTS_AUTOFS)
c8d72b
-			rv = umount2(this->path, MNT_DETACH);
c8d72b
+			rv = umount2(this->mp, MNT_DETACH);
c8d72b
 		else
c8d72b
-			rv = spawn_umount(ap->logopt, "-l", this->path, NULL);
c8d72b
+			rv = spawn_umount(ap->logopt, "-l", this->mp, NULL);
c8d72b
 		if (rv == -1) {
c8d72b
 			debug(ap->logopt,
c8d72b
-			      "can't unlink %s from mount tree", this->path);
c8d72b
+			      "can't unlink %s from mount tree", this->mp);
c8d72b
 
c8d72b
 			switch (errno) {
c8d72b
 			case EINVAL:
c8d72b
@@ -442,7 +442,7 @@ void *expire_proc_indirect(void *arg)
c8d72b
 			 */
c8d72b
 			pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state);
c8d72b
 			if (next->flags & MNTS_INDIRECT)
c8d72b
-				master_notify_submount(ap, next->path, ap->state);
c8d72b
+				master_notify_submount(ap, next->mp, ap->state);
c8d72b
 			else if (next->flags & MNTS_OFFSET) {
c8d72b
 				struct map_source *map;
c8d72b
 				struct mapent_cache *mc = NULL;
c8d72b
@@ -450,13 +450,13 @@ void *expire_proc_indirect(void *arg)
c8d72b
 				struct stat st;
c8d72b
 
c8d72b
 				/* It's got a mount, deal with in the outer loop */
c8d72b
-				if (is_mounted(_PATH_MOUNTED, next->path, MNTS_REAL)) {
c8d72b
+				if (is_mounted(_PATH_MOUNTED, next->mp, MNTS_REAL)) {
c8d72b
 					pthread_setcancelstate(cur_state, NULL);
c8d72b
 					continue;
c8d72b
 				}
c8d72b
 
c8d72b
 				/* Don't touch submounts */
c8d72b
-				if (master_find_submount(ap, next->path)) {
c8d72b
+				if (master_find_submount(ap, next->mp)) {
c8d72b
 					pthread_setcancelstate(cur_state, NULL);
c8d72b
 					continue;
c8d72b
 				}
c8d72b
@@ -467,7 +467,7 @@ void *expire_proc_indirect(void *arg)
c8d72b
 				while (map) {
c8d72b
 					mc = map->mc;
c8d72b
 					cache_writelock(mc);
c8d72b
-					me = cache_lookup_distinct(mc, next->path);
c8d72b
+					me = cache_lookup_distinct(mc, next->mp);
c8d72b
 					if (me)
c8d72b
 						break;
c8d72b
 					cache_unlock(mc);
c8d72b
@@ -509,7 +509,7 @@ void *expire_proc_indirect(void *arg)
c8d72b
 		 * If the mount corresponds to an offset trigger then
c8d72b
 		 * the key is the path, otherwise it's the last component.
c8d72b
 		 */
c8d72b
-		ind_key = strrchr(next->path, '/');
c8d72b
+		ind_key = strrchr(next->mp, '/');
c8d72b
 		if (ind_key)
c8d72b
 			ind_key++;
c8d72b
 
c8d72b
@@ -522,7 +522,7 @@ void *expire_proc_indirect(void *arg)
c8d72b
 		 */
c8d72b
 		pthread_cleanup_push(master_source_lock_cleanup, ap->entry);
c8d72b
 		master_source_readlock(ap->entry);
c8d72b
-		me = lookup_source_mapent(ap, next->path, LKP_DISTINCT);
c8d72b
+		me = lookup_source_mapent(ap, next->mp, LKP_DISTINCT);
c8d72b
 		if (!me && ind_key)
c8d72b
 			me = lookup_source_mapent(ap, ind_key, LKP_NORMAL);
c8d72b
 		pthread_cleanup_pop(1);
c8d72b
@@ -534,10 +534,10 @@ void *expire_proc_indirect(void *arg)
c8d72b
 			cache_unlock(me->mc);
c8d72b
 		}
c8d72b
 
c8d72b
-		debug(ap->logopt, "expire %s", next->path);
c8d72b
+		debug(ap->logopt, "expire %s", next->mp);
c8d72b
 
c8d72b
 		pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state);
c8d72b
-		ret = ops->expire(ap->logopt, ioctlfd, next->path, now);
c8d72b
+		ret = ops->expire(ap->logopt, ioctlfd, next->mp, now);
c8d72b
 		if (ret)
c8d72b
 			left++;
c8d72b
 		pthread_setcancelstate(cur_state, NULL);
c8d72b
--- autofs-5.0.7.orig/include/mounts.h
c8d72b
+++ autofs-5.0.7/include/mounts.h
c8d72b
@@ -52,7 +52,7 @@ extern const unsigned int t_offset;
c8d72b
 struct mapent;
c8d72b
 
c8d72b
 struct mnt_list {
c8d72b
-	char *path;
c8d72b
+	char *mp;
c8d72b
 	unsigned int flags;
c8d72b
 	/*
c8d72b
 	 * List operations ie. get_mnt_list.
c8d72b
@@ -101,7 +101,7 @@ int ext_mount_remove(struct list_head *,
c8d72b
 int ext_mount_inuse(const char *);
c8d72b
 struct mnt_list *get_mnt_list(const char *table, const char *path, int include);
c8d72b
 void free_mnt_list(struct mnt_list *list);
c8d72b
-int is_mounted(const char *table, const char *path, unsigned int type);
c8d72b
+int is_mounted(const char *table, const char *mp, unsigned int type);
c8d72b
 void tree_free_mnt_tree(struct mnt_list *tree);
c8d72b
 struct mnt_list *tree_make_mnt_tree(const char *table, const char *path);
c8d72b
 int tree_get_mnt_list(struct mnt_list *mnts, struct list_head *list, const char *path, int include);
c8d72b
--- autofs-5.0.7.orig/lib/mounts.c
c8d72b
+++ autofs-5.0.7/lib/mounts.c
c8d72b
@@ -818,8 +818,8 @@ struct mnt_list *get_mnt_list(const char
c8d72b
 	  	     strncmp(mnt->mnt_dir, path, pathlen) != 0)
c8d72b
 			continue;
c8d72b
 
c8d72b
-		/* Not a subdirectory of requested path ? */
c8d72b
-		/* pathlen == 1 => everything is subdir    */
c8d72b
+		/* Not a subdirectory of requested mp? */
c8d72b
+		/* mp_len == 1 => everything is subdir    */
c8d72b
 		if (pathlen > 1 && len > pathlen &&
c8d72b
 				mnt->mnt_dir[pathlen] != '/')
c8d72b
 			continue;
c8d72b
@@ -835,7 +835,7 @@ struct mnt_list *get_mnt_list(const char
c8d72b
 		mptr = list;
c8d72b
 		last = NULL;
c8d72b
 		while (mptr) {
c8d72b
-			if (len >= strlen(mptr->path))
c8d72b
+			if (len >= strlen(mptr->mp))
c8d72b
 				break;
c8d72b
 			last = mptr;
c8d72b
 			mptr = mptr->next;
c8d72b
@@ -848,13 +848,13 @@ struct mnt_list *get_mnt_list(const char
c8d72b
 
c8d72b
 		ent->next = mptr;
c8d72b
 
c8d72b
-		ent->path = malloc(len + 1);
c8d72b
-		if (!ent->path) {
c8d72b
+		ent->mp = malloc(len + 1);
c8d72b
+		if (!ent->mp) {
c8d72b
 			endmntent(tab);
c8d72b
 			free_mnt_list(list);
c8d72b
 			return NULL;
c8d72b
 		}
c8d72b
-		strcpy(ent->path, mnt->mnt_dir);
c8d72b
+		strcpy(ent->mp, mnt->mnt_dir);
c8d72b
 
c8d72b
 		if (!strcmp(mnt->mnt_type, "autofs"))
c8d72b
 			ent->flags |= MNTS_AUTOFS;
c8d72b
@@ -886,23 +886,23 @@ void free_mnt_list(struct mnt_list *list
c8d72b
 
c8d72b
 		next = this->next;
c8d72b
 
c8d72b
-		if (this->path)
c8d72b
-			free(this->path);
c8d72b
+		if (this->mp)
c8d72b
+			free(this->mp);
c8d72b
 
c8d72b
 		free(this);
c8d72b
 	}
c8d72b
 }
c8d72b
 
c8d72b
-static int table_is_mounted(const char *table, const char *path, unsigned int type)
c8d72b
+static int table_is_mounted(const char *table, const char *mp, unsigned int type)
c8d72b
 {
c8d72b
 	struct mntent *mnt;
c8d72b
 	struct mntent mnt_wrk;
c8d72b
 	char buf[PATH_MAX * 3];
c8d72b
-	size_t pathlen = strlen(path);
c8d72b
+	size_t mp_len = strlen(mp);
c8d72b
 	FILE *tab;
c8d72b
 	int ret = 0;
c8d72b
 
c8d72b
-	if (!path || !pathlen || pathlen >= PATH_MAX)
c8d72b
+	if (!mp || !mp_len || mp_len >= PATH_MAX)
c8d72b
 		return 0;
c8d72b
 
c8d72b
 	tab = open_setmntent_r(table);
c8d72b
@@ -929,7 +929,7 @@ static int table_is_mounted(const char *
c8d72b
 					continue;
c8d72b
 		}
c8d72b
 
c8d72b
-		if (pathlen == len && !strncmp(path, mnt->mnt_dir, pathlen)) {
c8d72b
+		if (mp_len == len && !strncmp(mp, mnt->mnt_dir, mp_len)) {
c8d72b
 			ret = 1;
c8d72b
 			break;
c8d72b
 		}
c8d72b
@@ -939,12 +939,12 @@ static int table_is_mounted(const char *
c8d72b
 	return ret;
c8d72b
 }
c8d72b
 
c8d72b
-static int ioctl_is_mounted(const char *path, unsigned int type)
c8d72b
+static int ioctl_is_mounted(const char *mp, unsigned int type)
c8d72b
 {
c8d72b
 	struct ioctl_ops *ops = get_ioctl_ops();
c8d72b
 	unsigned int mounted;
c8d72b
 
c8d72b
-	ops->ismountpoint(LOGOPT_NONE, -1, path, &mounted);
c8d72b
+	ops->ismountpoint(LOGOPT_NONE, -1, mp, &mounted);
c8d72b
 	if (mounted) {
c8d72b
 		switch (type) {
c8d72b
 		case MNTS_ALL:
c8d72b
@@ -958,14 +958,14 @@ static int ioctl_is_mounted(const char *
c8d72b
 	return 0;
c8d72b
 }
c8d72b
 
c8d72b
-int is_mounted(const char *table, const char *path, unsigned int type)
c8d72b
+int is_mounted(const char *table, const char *mp, unsigned int type)
c8d72b
 {
c8d72b
 	struct ioctl_ops *ops = get_ioctl_ops();
c8d72b
 
c8d72b
 	if (ops->ismountpoint)
c8d72b
-		return ioctl_is_mounted(path, type);
c8d72b
+		return ioctl_is_mounted(mp, type);
c8d72b
 	else
c8d72b
-		return table_is_mounted(table, path, type);
c8d72b
+		return table_is_mounted(table, mp, type);
c8d72b
 }
c8d72b
 
c8d72b
 /*
c8d72b
@@ -1000,12 +1000,12 @@ void tree_free_mnt_tree(struct mnt_list
c8d72b
 
c8d72b
 		list_del(&this->self);
c8d72b
 
c8d72b
-		free(this->path);
c8d72b
+		free(this->mp);
c8d72b
 
c8d72b
 		free(this);
c8d72b
 	}
c8d72b
 
c8d72b
-	free(tree->path);
c8d72b
+	free(tree->mp);
c8d72b
 	free(tree);
c8d72b
 }
c8d72b
 
c8d72b
@@ -1056,14 +1056,14 @@ struct mnt_list *tree_make_mnt_tree(cons
c8d72b
 		INIT_LIST_HEAD(&ent->entries);
c8d72b
 		INIT_LIST_HEAD(&ent->sublist);
c8d72b
 
c8d72b
-		ent->path = malloc(len + 1);
c8d72b
-		if (!ent->path) {
c8d72b
+		ent->mp = malloc(len + 1);
c8d72b
+		if (!ent->mp) {
c8d72b
 			endmntent(tab);
c8d72b
 			free(ent);
c8d72b
 			tree_free_mnt_tree(tree);
c8d72b
 			return NULL;
c8d72b
 		}
c8d72b
-		strcpy(ent->path, mnt->mnt_dir);
c8d72b
+		strcpy(ent->mp, mnt->mnt_dir);
c8d72b
 
c8d72b
 		if (!strcmp(mnt->mnt_type, "autofs"))
c8d72b
 			ent->flags |= MNTS_AUTOFS;
c8d72b
@@ -1079,8 +1079,8 @@ struct mnt_list *tree_make_mnt_tree(cons
c8d72b
 
c8d72b
 		mptr = tree;
c8d72b
 		while (mptr) {
c8d72b
-			int elen = strlen(ent->path);
c8d72b
-			int mlen = strlen(mptr->path);
c8d72b
+			int elen = strlen(ent->mp);
c8d72b
+			int mlen = strlen(mptr->mp);
c8d72b
 
c8d72b
 			if (elen < mlen) {
c8d72b
 				if (mptr->left) {
c8d72b
@@ -1100,7 +1100,7 @@ struct mnt_list *tree_make_mnt_tree(cons
c8d72b
 				}
c8d72b
 			}
c8d72b
 
c8d72b
-			eq = strcmp(ent->path, mptr->path);
c8d72b
+			eq = strcmp(ent->mp, mptr->mp);
c8d72b
 			if (eq < 0) {
c8d72b
 				if (mptr->left)
c8d72b
 					mptr = mptr->left;
c8d72b
@@ -1140,7 +1140,7 @@ int tree_get_mnt_list(struct mnt_list *m
c8d72b
 		return 0;
c8d72b
 
c8d72b
 	plen = strlen(path);
c8d72b
-	mlen = strlen(mnts->path);
c8d72b
+	mlen = strlen(mnts->mp);
c8d72b
 	if (mlen < plen)
c8d72b
 		return tree_get_mnt_list(mnts->right, list, path, include);
c8d72b
 	else {
c8d72b
@@ -1149,10 +1149,10 @@ int tree_get_mnt_list(struct mnt_list *m
c8d72b
 		tree_get_mnt_list(mnts->left, list, path, include);
c8d72b
 
c8d72b
 		if ((!include && mlen <= plen) ||
c8d72b
-				strncmp(mnts->path, path, plen))
c8d72b
+				strncmp(mnts->mp, path, plen))
c8d72b
 			goto skip;
c8d72b
 
c8d72b
-		if (plen > 1 && mlen > plen && mnts->path[plen] != '/')
c8d72b
+		if (plen > 1 && mlen > plen && mnts->mp[plen] != '/')
c8d72b
 			goto skip;
c8d72b
 
c8d72b
 		INIT_LIST_HEAD(&mnts->list);
c8d72b
@@ -1187,7 +1187,7 @@ int tree_get_mnt_sublist(struct mnt_list
c8d72b
 		return 0;
c8d72b
 
c8d72b
 	plen = strlen(path);
c8d72b
-	mlen = strlen(mnts->path);
c8d72b
+	mlen = strlen(mnts->mp);
c8d72b
 	if (mlen < plen)
c8d72b
 		return tree_get_mnt_sublist(mnts->right, list, path, include);
c8d72b
 	else {
c8d72b
@@ -1196,10 +1196,10 @@ int tree_get_mnt_sublist(struct mnt_list
c8d72b
 		tree_get_mnt_sublist(mnts->left, list, path, include);
c8d72b
 
c8d72b
 		if ((!include && mlen <= plen) ||
c8d72b
-				strncmp(mnts->path, path, plen))
c8d72b
+				strncmp(mnts->mp, path, plen))
c8d72b
 			goto skip;
c8d72b
 
c8d72b
-		if (plen > 1 && mlen > plen && mnts->path[plen] != '/')
c8d72b
+		if (plen > 1 && mlen > plen && mnts->mp[plen] != '/')
c8d72b
 			goto skip;
c8d72b
 
c8d72b
 		INIT_LIST_HEAD(&mnts->sublist);
c8d72b
@@ -1231,7 +1231,7 @@ int tree_find_mnt_ents(struct mnt_list *
c8d72b
 		return 0;
c8d72b
 
c8d72b
 	plen = strlen(path);
c8d72b
-	mlen = strlen(mnts->path);
c8d72b
+	mlen = strlen(mnts->mp);
c8d72b
 	if (mlen < plen)
c8d72b
 		return tree_find_mnt_ents(mnts->right, list, path);
c8d72b
 	else if (mlen > plen)
c8d72b
@@ -1241,7 +1241,7 @@ int tree_find_mnt_ents(struct mnt_list *
c8d72b
 
c8d72b
 		tree_find_mnt_ents(mnts->left, list, path);
c8d72b
 
c8d72b
-		if (!strcmp(mnts->path, path)) {
c8d72b
+		if (!strcmp(mnts->mp, path)) {
c8d72b
 			INIT_LIST_HEAD(&mnts->entries);
c8d72b
 			list_add(&mnts->entries, list);
c8d72b
 		}
c8d72b
@@ -1252,7 +1252,7 @@ int tree_find_mnt_ents(struct mnt_list *
c8d72b
 
c8d72b
 			this = list_entry(p, struct mnt_list, self);
c8d72b
 
c8d72b
-			if (!strcmp(this->path, path)) {
c8d72b
+			if (!strcmp(this->mp, path)) {
c8d72b
 				INIT_LIST_HEAD(&this->entries);
c8d72b
 				list_add(&this->entries, list);
c8d72b
 			}