Blame SOURCES/autofs-5.1.5-always-use-PROC_MOUNTS-to-make-mount-lists.patch

c8d72b
autofs-5.1.5 - always use PROC_MOUNTS to make mount lists
c8d72b
c8d72b
From: Ian Kent <raven@themaw.net>
c8d72b
c8d72b
If it's necessary to read a mount table then always use the proc file
c8d72b
system mount table.
c8d72b
c8d72b
This could be very inefficient for cases where the mtab (_PATH_MOUNTED)
c8d72b
is specified but the mtab has been a symlink to the proc mount tables
c8d72b
for quite a while now so it doesn't make any difference always using
c8d72b
the proc tables.
c8d72b
c8d72b
Signed-off-by: Ian Kent <raven@themaw.net>
c8d72b
---
c8d72b
 CHANGELOG           |    1 +
c8d72b
 daemon/automount.c  |    6 +++---
c8d72b
 daemon/direct.c     |   14 +++++++-------
c8d72b
 daemon/indirect.c   |    8 ++++----
c8d72b
 daemon/lookup.c     |    4 ++--
c8d72b
 daemon/spawn.c      |    2 +-
c8d72b
 daemon/state.c      |    2 +-
c8d72b
 include/mounts.h    |    6 +++---
c8d72b
 lib/mounts.c        |   32 ++++++++++++++++----------------
c8d72b
 modules/parse_amd.c |    4 ++--
c8d72b
 10 files changed, 40 insertions(+), 39 deletions(-)
c8d72b
c8d72b
--- autofs-5.0.7.orig/CHANGELOG
c8d72b
+++ autofs-5.0.7/CHANGELOG
c8d72b
@@ -339,6 +339,7 @@
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
+- always use PROC_MOUNTS to make mount lists.
c8d72b
 
c8d72b
 25/07/2012 autofs-5.0.7
c8d72b
 =======================
c8d72b
--- autofs-5.0.7.orig/daemon/automount.c
c8d72b
+++ autofs-5.0.7/daemon/automount.c
c8d72b
@@ -331,7 +331,7 @@ static int walk_tree(const char *base, i
c8d72b
 	struct stat st, *pst = &st;
c8d72b
 	int ret;
c8d72b
 
c8d72b
-	if (!is_mounted(_PATH_MOUNTED, base, MNTS_REAL))
c8d72b
+	if (!is_mounted(base, MNTS_REAL))
c8d72b
 		ret = lstat(base, pst);
c8d72b
 	else {
c8d72b
 		pst = NULL;
c8d72b
@@ -595,11 +595,11 @@ static int umount_subtree_mounts(struct
c8d72b
 	 * If this is the root of a multi-mount we've had to umount
c8d72b
 	 * it already to ensure it's ok to remove any offset triggers.
c8d72b
 	 */
c8d72b
-	if (!is_mm_root && is_mounted(_PATH_MOUNTED, path, MNTS_REAL)) {
c8d72b
+	if (!is_mm_root && is_mounted(path, MNTS_REAL)) {
c8d72b
 		struct amd_entry *entry;
c8d72b
 		debug(ap->logopt, "unmounting dir = %s", path);
c8d72b
 		if (umount_ent(ap, path) &&
c8d72b
-		    is_mounted(_PATH_MOUNTED, path, MNTS_REAL)) {
c8d72b
+		    is_mounted(path, MNTS_REAL)) {
c8d72b
 			warn(ap->logopt, "could not umount dir %s", path);
c8d72b
 			left++;
c8d72b
 			goto done;
c8d72b
--- autofs-5.0.7.orig/daemon/direct.c
c8d72b
+++ autofs-5.0.7/daemon/direct.c
c8d72b
@@ -207,7 +207,7 @@ int umount_autofs_direct(struct autofs_p
c8d72b
 	struct mnt_list *mnts;
c8d72b
 	struct mapent *me, *ne;
c8d72b
 
c8d72b
-	mnts = tree_make_mnt_tree(_PROC_MOUNTS, "/");
c8d72b
+	mnts = tree_make_mnt_tree("/");
c8d72b
 	pthread_cleanup_push(mnts_cleanup, mnts);
c8d72b
 	nc = ap->entry->master->nc;
c8d72b
 	cache_readlock(nc);
c8d72b
@@ -521,7 +521,7 @@ int mount_autofs_direct(struct autofs_po
c8d72b
 		return -1;
c8d72b
 	}
c8d72b
 
c8d72b
-	mnts = tree_make_mnt_tree(_PROC_MOUNTS, "/");
c8d72b
+	mnts = tree_make_mnt_tree("/");
c8d72b
 	pthread_cleanup_push(mnts_cleanup, mnts);
c8d72b
 	pthread_cleanup_push(master_source_lock_cleanup, ap->entry);
c8d72b
 	master_source_readlock(ap->entry);
c8d72b
@@ -589,7 +589,7 @@ int umount_autofs_offset(struct autofs_p
c8d72b
 	int opened = 0;
c8d72b
 
c8d72b
 	if (me->ioctlfd != -1) {
c8d72b
-		if (is_mounted(_PATH_MOUNTED, me->key, MNTS_REAL)) {
c8d72b
+		if (is_mounted(me->key, MNTS_REAL)) {
c8d72b
 			error(ap->logopt,
c8d72b
 			      "attempt to umount busy offset %s", me->key);
c8d72b
 			return 1;
c8d72b
@@ -597,7 +597,7 @@ int umount_autofs_offset(struct autofs_p
c8d72b
 		ioctlfd = me->ioctlfd;
c8d72b
 	} else {
c8d72b
 		/* offset isn't mounted, return success and try to recover */
c8d72b
-		if (!is_mounted(_PROC_MOUNTS, me->key, MNTS_AUTOFS)) {
c8d72b
+		if (!is_mounted(me->key, MNTS_AUTOFS)) {
c8d72b
 			debug(ap->logopt,
c8d72b
 			      "offset %s not mounted",
c8d72b
 			      me->key);
c8d72b
@@ -713,7 +713,7 @@ int mount_autofs_offset(struct autofs_po
c8d72b
 		if (!(ret == -1 && errno == ENOENT))
c8d72b
 			return MOUNT_OFFSET_FAIL;
c8d72b
 	} else {
c8d72b
-		if (is_mounted(_PROC_MOUNTS, me->key, MNTS_AUTOFS)) {
c8d72b
+		if (is_mounted(me->key, MNTS_AUTOFS)) {
c8d72b
 			if (ap->state != ST_READMAP)
c8d72b
 				warn(ap->logopt,
c8d72b
 				     "trigger %s already mounted", me->key);
c8d72b
@@ -767,7 +767,7 @@ int mount_autofs_offset(struct autofs_po
c8d72b
 			 * the kernel NFS client.
c8d72b
 			 */
c8d72b
 			if (me->multi != me &&
c8d72b
-			    is_mounted(_PROC_MOUNTS, mountpoint, MNTS_REAL))
c8d72b
+			    is_mounted(mountpoint, MNTS_REAL))
c8d72b
 				return MOUNT_OFFSET_IGNORE;
c8d72b
 
c8d72b
 			/* 
c8d72b
@@ -887,7 +887,7 @@ void *expire_proc_direct(void *arg)
c8d72b
 
c8d72b
 	left = 0;
c8d72b
 
c8d72b
-	mnts = tree_make_mnt_tree(_PROC_MOUNTS, "/");
c8d72b
+	mnts = tree_make_mnt_tree("/");
c8d72b
 	pthread_cleanup_push(mnts_cleanup, mnts);
c8d72b
 
c8d72b
 	/* Get a list of mounts select real ones and expire them if possible */
c8d72b
--- autofs-5.0.7.orig/daemon/indirect.c
c8d72b
+++ autofs-5.0.7/daemon/indirect.c
c8d72b
@@ -103,7 +103,7 @@ static int do_mount_autofs_indirect(stru
c8d72b
 		if (ret == 0)
c8d72b
 			return -1;
c8d72b
 	} else {
c8d72b
-		mnts = get_mnt_list(_PROC_MOUNTS, ap->path, 1);
c8d72b
+		mnts = get_mnt_list(ap->path, 1);
c8d72b
 		if (mnts) {
c8d72b
 			ret = unlink_mount_tree(ap, mnts);
c8d72b
 			free_mnt_list(mnts);
c8d72b
@@ -429,7 +429,7 @@ void *expire_proc_indirect(void *arg)
c8d72b
 	left = 0;
c8d72b
 
c8d72b
 	/* Get a list of real mounts and expire them if possible */
c8d72b
-	mnts = get_mnt_list(_PROC_MOUNTS, ap->path, 0);
c8d72b
+	mnts = get_mnt_list(ap->path, 0);
c8d72b
 	pthread_cleanup_push(mnts_cleanup, mnts);
c8d72b
 	for (next = mnts; next; next = next->next) {
c8d72b
 		char *ind_key;
c8d72b
@@ -450,7 +450,7 @@ 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->mp, MNTS_REAL)) {
c8d72b
+				if (is_mounted(next->mp, MNTS_REAL)) {
c8d72b
 					pthread_setcancelstate(cur_state, NULL);
c8d72b
 					continue;
c8d72b
 				}
c8d72b
@@ -559,7 +559,7 @@ void *expire_proc_indirect(void *arg)
c8d72b
 	pthread_cleanup_pop(1);
c8d72b
 
c8d72b
 	count = offsets = submnts = 0;
c8d72b
-	mnts = get_mnt_list(_PROC_MOUNTS, ap->path, 0);
c8d72b
+	mnts = get_mnt_list(ap->path, 0);
c8d72b
 	pthread_cleanup_push(mnts_cleanup, mnts);
c8d72b
 	/* Are there any real mounts left */
c8d72b
 	for (next = mnts; next; next = next->next) {
c8d72b
--- autofs-5.0.7.orig/daemon/lookup.c
c8d72b
+++ autofs-5.0.7/daemon/lookup.c
c8d72b
@@ -1419,7 +1419,7 @@ void lookup_prune_one_cache(struct autof
c8d72b
 			valid = NULL;
c8d72b
 		}
c8d72b
 		if (!valid &&
c8d72b
-		    is_mounted(_PATH_MOUNTED, path, MNTS_REAL)) {
c8d72b
+		    is_mounted(path, MNTS_REAL)) {
c8d72b
 			debug(ap->logopt, "prune posponed, %s mounted", path);
c8d72b
 			free(key);
c8d72b
 			free(path);
c8d72b
@@ -1442,7 +1442,7 @@ void lookup_prune_one_cache(struct autof
c8d72b
 
c8d72b
 		if (valid)
c8d72b
 			cache_delete(mc, key);
c8d72b
-		else if (!is_mounted(_PROC_MOUNTS, path, MNTS_AUTOFS)) {
c8d72b
+		else if (!is_mounted(path, MNTS_AUTOFS)) {
c8d72b
 			dev_t devid = ap->dev;
c8d72b
 			status = CHE_FAIL;
c8d72b
 			if (ap->type == LKP_DIRECT)
c8d72b
--- autofs-5.0.7.orig/daemon/spawn.c
c8d72b
+++ autofs-5.0.7/daemon/spawn.c
c8d72b
@@ -406,7 +406,7 @@ static int do_spawn(unsigned logopt, uns
c8d72b
 			if (!is_bind)
c8d72b
 				goto done;
c8d72b
 
c8d72b
-			if (is_mounted(_PROC_MOUNTS, argv[loc], MNTS_AUTOFS)) {
c8d72b
+			if (is_mounted(argv[loc], MNTS_AUTOFS)) {
c8d72b
 				fprintf(stderr,
c8d72b
 				     "error: can't bind to an autofs mount\n");
c8d72b
 				close(STDOUT_FILENO);
c8d72b
--- autofs-5.0.7.orig/daemon/state.c
c8d72b
+++ autofs-5.0.7/daemon/state.c
c8d72b
@@ -499,7 +499,7 @@ static void *do_readmap(void *arg)
c8d72b
 		struct mapent *me;
c8d72b
 		unsigned int append_alarm = !ap->exp_runfreq;
c8d72b
 
c8d72b
-		mnts = tree_make_mnt_tree(_PROC_MOUNTS, "/");
c8d72b
+		mnts = tree_make_mnt_tree("/");
c8d72b
 		pthread_cleanup_push(tree_mnts_cleanup, mnts);
c8d72b
 		nc = ap->entry->master->nc;
c8d72b
 		cache_readlock(nc);
c8d72b
--- autofs-5.0.7.orig/include/mounts.h
c8d72b
+++ autofs-5.0.7/include/mounts.h
c8d72b
@@ -99,11 +99,11 @@ char *make_mnt_name_string(char *path);
c8d72b
 int ext_mount_add(struct list_head *, const char *, unsigned int);
c8d72b
 int ext_mount_remove(struct list_head *, const char *);
c8d72b
 int ext_mount_inuse(const char *);
c8d72b
-struct mnt_list *get_mnt_list(const char *table, const char *path, int include);
c8d72b
+struct mnt_list *get_mnt_list(const char *path, int include);
c8d72b
 void free_mnt_list(struct mnt_list *list);
c8d72b
-int is_mounted(const char *table, const char *mp, unsigned int type);
c8d72b
+int is_mounted(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
+struct mnt_list *tree_make_mnt_tree(const char *path);
c8d72b
 int tree_get_mnt_list(struct mnt_list *mnts, struct list_head *list, const char *path, int include);
c8d72b
 int tree_get_mnt_sublist(struct mnt_list *mnts, struct list_head *list, const char *path, int include);
c8d72b
 int tree_find_mnt_ents(struct mnt_list *mnts, struct list_head *list, const char *path);
c8d72b
--- autofs-5.0.7.orig/lib/mounts.c
c8d72b
+++ autofs-5.0.7/lib/mounts.c
c8d72b
@@ -790,7 +790,7 @@ done:
c8d72b
 /*
c8d72b
  * Get list of mounts under path in longest->shortest order
c8d72b
  */
c8d72b
-struct mnt_list *get_mnt_list(const char *table, const char *path, int include)
c8d72b
+struct mnt_list *get_mnt_list(const char *path, int include)
c8d72b
 {
c8d72b
 	FILE *tab;
c8d72b
 	size_t pathlen = strlen(path);
c8d72b
@@ -804,7 +804,7 @@ struct mnt_list *get_mnt_list(const char
c8d72b
 	if (!path || !pathlen || pathlen > PATH_MAX)
c8d72b
 		return NULL;
c8d72b
 
c8d72b
-	tab = open_setmntent_r(table);
c8d72b
+	tab = open_setmntent_r(_PROC_MOUNTS);
c8d72b
 	if (!tab) {
c8d72b
 		char *estr = strerror_r(errno, buf, PATH_MAX - 1);
c8d72b
 		logerr("setmntent: %s", estr);
c8d72b
@@ -893,7 +893,7 @@ void free_mnt_list(struct mnt_list *list
c8d72b
 	}
c8d72b
 }
c8d72b
 
c8d72b
-static int table_is_mounted(const char *table, const char *mp, unsigned int type)
c8d72b
+static int table_is_mounted(const char *mp, unsigned int type)
c8d72b
 {
c8d72b
 	struct mntent *mnt;
c8d72b
 	struct mntent mnt_wrk;
c8d72b
@@ -905,7 +905,7 @@ static int table_is_mounted(const char *
c8d72b
 	if (!mp || !mp_len || mp_len >= PATH_MAX)
c8d72b
 		return 0;
c8d72b
 
c8d72b
-	tab = open_setmntent_r(table);
c8d72b
+	tab = open_setmntent_r(_PROC_MOUNTS);
c8d72b
 	if (!tab) {
c8d72b
 		char *estr = strerror_r(errno, buf, PATH_MAX - 1);
c8d72b
 		logerr("setmntent: %s", estr);
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 *mp, unsigned int type)
c8d72b
+int is_mounted(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(mp, type);
c8d72b
 	else
c8d72b
-		return table_is_mounted(table, mp, type);
c8d72b
+		return table_is_mounted(mp, type);
c8d72b
 }
c8d72b
 
c8d72b
 /*
c8d72b
@@ -1012,7 +1012,7 @@ void tree_free_mnt_tree(struct mnt_list
c8d72b
 /*
c8d72b
  * Make tree of system mounts in /proc/mounts.
c8d72b
  */
c8d72b
-struct mnt_list *tree_make_mnt_tree(const char *table, const char *path)
c8d72b
+struct mnt_list *tree_make_mnt_tree(const char *path)
c8d72b
 {
c8d72b
 	FILE *tab;
c8d72b
 	struct mntent mnt_wrk;
c8d72b
@@ -1023,7 +1023,7 @@ struct mnt_list *tree_make_mnt_tree(cons
c8d72b
 	size_t plen;
c8d72b
 	int eq;
c8d72b
 
c8d72b
-	tab = open_setmntent_r(table);
c8d72b
+	tab = open_setmntent_r(_PROC_MOUNTS);
c8d72b
 	if (!tab) {
c8d72b
 		char *estr = strerror_r(errno, buf, PATH_MAX - 1);
c8d72b
 		logerr("setmntent: %s", estr);
c8d72b
@@ -1851,7 +1851,7 @@ void set_indirect_mount_tree_catatonic(s
c8d72b
 	struct mapent_cache *mc;
c8d72b
 	struct mapent *me;
c8d72b
 
c8d72b
-	if (!is_mounted(_PROC_MOUNTS, ap->path, MNTS_AUTOFS))
c8d72b
+	if (!is_mounted(ap->path, MNTS_AUTOFS))
c8d72b
 		return;
c8d72b
 
c8d72b
 	map = entry->maps;
c8d72b
@@ -1915,7 +1915,7 @@ int umount_ent(struct autofs_point *ap,
c8d72b
 		 * so that we do not try to call rmdir_path on the
c8d72b
 		 * directory.
c8d72b
 		 */
c8d72b
-		if (!rv && is_mounted(_PATH_MOUNTED, path, MNTS_REAL)) {
c8d72b
+		if (!rv && is_mounted(path, MNTS_REAL)) {
c8d72b
 			crit(ap->logopt,
c8d72b
 			     "the umount binary reported that %s was "
c8d72b
 			     "unmounted, but there is still something "
c8d72b
@@ -2048,7 +2048,7 @@ int mount_multi_triggers(struct autofs_p
c8d72b
 		 */
c8d72b
 		if (ap->state == ST_READMAP && ap->flags & MOUNT_FLAG_REMOUNT) {
c8d72b
 			if (oe->ioctlfd != -1 ||
c8d72b
-			    is_mounted(_PROC_MOUNTS, oe->key, MNTS_REAL)) {
c8d72b
+			    is_mounted(oe->key, MNTS_REAL)) {
c8d72b
 				char oe_root[PATH_MAX + 1];
c8d72b
 				strcpy(oe_root, root);
c8d72b
 				strcat(oe_root, offset); 
c8d72b
@@ -2137,7 +2137,7 @@ int umount_multi_triggers(struct autofs_
c8d72b
 		left += umount_multi_triggers(ap, oe, root, oe_base);
c8d72b
 
c8d72b
 		if (oe->ioctlfd != -1 ||
c8d72b
-		    is_mounted(_PROC_MOUNTS, oe->key, MNTS_REAL)) {
c8d72b
+		    is_mounted(oe->key, MNTS_REAL)) {
c8d72b
 			left++;
c8d72b
 			continue;
c8d72b
 		}
c8d72b
@@ -2180,10 +2180,10 @@ int umount_multi_triggers(struct autofs_
c8d72b
 		 * delete the offsets from the cache and we need to put
c8d72b
 		 * the offset triggers back.
c8d72b
 		 */
c8d72b
-		if (is_mounted(_PATH_MOUNTED, root, MNTS_REAL)) {
c8d72b
+		if (is_mounted(root, MNTS_REAL)) {
c8d72b
 			info(ap->logopt, "unmounting dir = %s", root);
c8d72b
 			if (umount_ent(ap, root) &&
c8d72b
-			    is_mounted(_PATH_MOUNTED, root, MNTS_REAL)) {
c8d72b
+			    is_mounted(root, MNTS_REAL)) {
c8d72b
 				if (mount_multi_triggers(ap, me, root, strlen(root), "/") < 0)
c8d72b
 					warn(ap->logopt,
c8d72b
 					     "failed to remount offset triggers");
c8d72b
@@ -2283,9 +2283,9 @@ int clean_stale_multi_triggers(struct au
c8d72b
 		 * ESTALE errors when attempting list the directory.
c8d72b
 		 */
c8d72b
 		if (oe->ioctlfd != -1 ||
c8d72b
-		    is_mounted(_PROC_MOUNTS, oe->key, MNTS_REAL)) {
c8d72b
+		    is_mounted(oe->key, MNTS_REAL)) {
c8d72b
 			if (umount_ent(ap, oe->key) &&
c8d72b
-			    is_mounted(_PROC_MOUNTS, oe->key, MNTS_REAL)) {
c8d72b
+			    is_mounted(oe->key, MNTS_REAL)) {
c8d72b
 				debug(ap->logopt,
c8d72b
 				      "offset %s has active mount, invalidate",
c8d72b
 				      oe->key);
c8d72b
--- autofs-5.0.7.orig/modules/parse_amd.c
c8d72b
+++ autofs-5.0.7/modules/parse_amd.c
c8d72b
@@ -1175,7 +1175,7 @@ static int do_generic_mount(struct autof
c8d72b
 		 * multiple times since they are outside of
c8d72b
 		 * the automount filesystem.
c8d72b
 		 */
c8d72b
-		if (!is_mounted(_PATH_MOUNTED, entry->fs, MNTS_REAL)) {
c8d72b
+		if (!is_mounted(entry->fs, MNTS_REAL)) {
c8d72b
 			ret = do_mount(ap, entry->fs, "/", 1,
c8d72b
 				       target, entry->type, opts);
c8d72b
 			if (ret)
c8d72b
@@ -1218,7 +1218,7 @@ static int do_nfs_mount(struct autofs_po
c8d72b
 					     target, entry->type, opts,
c8d72b
 					     mount_nfs->context);
c8d72b
 	} else {
c8d72b
-		if (!is_mounted(_PATH_MOUNTED, entry->fs, MNTS_REAL)) {
c8d72b
+		if (!is_mounted(entry->fs, MNTS_REAL)) {
c8d72b
 			ret = mount_nfs->mount_mount(ap, entry->fs, "/", 1,
c8d72b
 						target, entry->type, opts,
c8d72b
 						mount_nfs->context);