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

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