Blame SOURCES/autofs-5.0.8-change-walk_tree-to-take-ap.patch

306fa1
autofs-5.0.8 - change walk_tree() to take ap
306fa1
306fa1
From: Ian Kent <raven@themaw.net>
306fa1
306fa1
Change walk_tree() to take an autofs_point pointer instead of
306fa1
logopt.
306fa1
---
306fa1
 CHANGELOG           |    1 +
306fa1
 daemon/automount.c  |   49 +++++++++++++++++++++++++++++--------------------
306fa1
 daemon/direct.c     |    2 +-
306fa1
 daemon/indirect.c   |    6 +++---
306fa1
 include/automount.h |    4 ++--
306fa1
 5 files changed, 36 insertions(+), 26 deletions(-)
306fa1
306fa1
--- autofs-5.0.7.orig/CHANGELOG
306fa1
+++ autofs-5.0.7/CHANGELOG
306fa1
@@ -90,6 +90,7 @@
306fa1
 - fix master map type check.
306fa1
 - fix bad mkdir permission on create.
306fa1
 - fix macro_addvar() and move init to main thread.
306fa1
+- change walk_tree() to take ap.
306fa1
 
306fa1
 25/07/2012 autofs-5.0.7
306fa1
 =======================
306fa1
--- autofs-5.0.7.orig/daemon/automount.c
306fa1
+++ autofs-5.0.7/daemon/automount.c
306fa1
@@ -254,10 +254,12 @@ int rmdir_path(struct autofs_point *ap,
306fa1
 /* Like ftw, except fn gets called twice: before a directory is
306fa1
    entered, and after.  If the before call returns 0, the directory
306fa1
    isn't entered. */
306fa1
-static int walk_tree(const char *base, int (*fn) (unsigned logopt,
306fa1
+static int walk_tree(const char *base, int (*fn) (struct autofs_point *ap,
306fa1
 						  const char *file,
306fa1
 						  const struct stat * st,
306fa1
-						  int, void *), int incl, unsigned logopt, void *arg)
306fa1
+						  int, void *), int incl,
306fa1
+						  struct autofs_point *ap,
306fa1
+						  void *arg)
306fa1
 {
306fa1
 	char buf[PATH_MAX + 1];
306fa1
 	struct stat st, *pst = &st;
306fa1
@@ -270,7 +272,7 @@ static int walk_tree(const char *base, i
306fa1
 		ret = 0;
306fa1
 	}
306fa1
 
306fa1
-	if (ret != -1 && (fn) (logopt, base, pst, 0, arg)) {
306fa1
+	if (ret != -1 && (fn) (ap, base, pst, 0, arg)) {
306fa1
 		if (S_ISDIR(st.st_mode)) {
306fa1
 			struct dirent **de;
306fa1
 			int n;
306fa1
@@ -298,18 +300,20 @@ static int walk_tree(const char *base, i
306fa1
 					return -1;
306fa1
 				}
306fa1
 
306fa1
-				walk_tree(buf, fn, 1, logopt, arg);
306fa1
+				walk_tree(buf, fn, 1, ap, arg);
306fa1
 				free(de[n]);
306fa1
 			}
306fa1
 			free(de);
306fa1
 		}
306fa1
 		if (incl)
306fa1
-			(fn) (logopt, base, pst, 1, arg);
306fa1
+			(fn) (ap, base, pst, 1, arg);
306fa1
 	}
306fa1
 	return 0;
306fa1
 }
306fa1
 
306fa1
-static int rm_unwanted_fn(unsigned logopt, const char *file, const struct stat *st, int when, void *arg)
306fa1
+static int rm_unwanted_fn(struct autofs_point *ap,
306fa1
+			  const char *file, const struct stat *st,
306fa1
+			  int when, void *arg)
306fa1
 {
306fa1
 	dev_t dev = *(dev_t *) arg;
306fa1
 	char buf[MAX_ERR_BUF];
306fa1
@@ -325,38 +329,40 @@ static int rm_unwanted_fn(unsigned logop
306fa1
 	}
306fa1
 
306fa1
 	if (lstat(file, &newst)) {
306fa1
-		crit(logopt, "unable to stat file, possible race condition");
306fa1
+		crit(ap->logopt,
306fa1
+		     "unable to stat file, possible race condition");
306fa1
 		return 0;
306fa1
 	}
306fa1
 
306fa1
 	if (newst.st_dev != dev) {
306fa1
-		crit(logopt, "file %s has the wrong device, possible race condition",
306fa1
+		crit(ap->logopt,
306fa1
+		     "file %s has the wrong device, possible race condition",
306fa1
 		     file);
306fa1
 		return 0;
306fa1
 	}
306fa1
 
306fa1
 	if (S_ISDIR(newst.st_mode)) {
306fa1
-		debug(logopt, "removing directory %s", file);
306fa1
+		debug(ap->logopt, "removing directory %s", file);
306fa1
 		if (rmdir(file)) {
306fa1
 			char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
306fa1
-			warn(logopt,
306fa1
+			warn(ap->logopt,
306fa1
 			      "unable to remove directory %s: %s", file, estr);
306fa1
 			return 0;
306fa1
 		}
306fa1
 	} else if (S_ISREG(newst.st_mode)) {
306fa1
-		crit(logopt, "attempting to remove files from a mounted "
306fa1
+		crit(ap->logopt, "attempting to remove files from a mounted "
306fa1
 		     "directory. file %s", file);
306fa1
 		return 0;
306fa1
 	} else if (S_ISLNK(newst.st_mode)) {
306fa1
-		debug(logopt, "removing symlink %s", file);
306fa1
+		debug(ap->logopt, "removing symlink %s", file);
306fa1
 		unlink(file);
306fa1
 	}
306fa1
 	return 1;
306fa1
 }
306fa1
 
306fa1
-void rm_unwanted(unsigned logopt, const char *path, int incl, dev_t dev)
306fa1
+void rm_unwanted(struct autofs_point *ap, const char *path, int incl)
306fa1
 {
306fa1
-	walk_tree(path, rm_unwanted_fn, incl, logopt, &dev;;
306fa1
+	walk_tree(path, rm_unwanted_fn, incl, ap, &ap->dev);
306fa1
 }
306fa1
 
306fa1
 struct counter_args {
306fa1
@@ -364,7 +370,8 @@ struct counter_args {
306fa1
 	dev_t dev;
306fa1
 };
306fa1
 
306fa1
-static int counter_fn(unsigned logopt, const char *file, const struct stat *st, int when, void *arg)
306fa1
+static int counter_fn(struct autofs_point *ap, const char *file,
306fa1
+		      const struct stat *st, int when, void *arg)
306fa1
 {
306fa1
 	struct counter_args *counter = (struct counter_args *) arg;
306fa1
 
306fa1
@@ -378,14 +385,14 @@ static int counter_fn(unsigned logopt, c
306fa1
 }
306fa1
 
306fa1
 /* Count mounted filesystems and symlinks */
306fa1
-int count_mounts(unsigned logopt, const char *path, dev_t dev)
306fa1
+int count_mounts(struct autofs_point *ap, const char *path, dev_t dev)
306fa1
 {
306fa1
 	struct counter_args counter;
306fa1
 
306fa1
 	counter.count = 0;
306fa1
 	counter.dev = dev;
306fa1
 	
306fa1
-	if (walk_tree(path, counter_fn, 0, logopt, &counter) == -1)
306fa1
+	if (walk_tree(path, counter_fn, 0, ap, &counter) == -1)
306fa1
 		return -1;
306fa1
 
306fa1
 	return counter.count;
306fa1
@@ -409,9 +416,9 @@ static void check_rm_dirs(struct autofs_
306fa1
 	    (ap->state == ST_SHUTDOWN_PENDING ||
306fa1
 	     ap->state == ST_SHUTDOWN_FORCE ||
306fa1
 	     ap->state == ST_SHUTDOWN))
306fa1
-		rm_unwanted(ap->logopt, path, incl, ap->dev);
306fa1
+		rm_unwanted(ap, path, incl);
306fa1
 	else if ((ap->flags & MOUNT_FLAG_GHOST) && (ap->type == LKP_INDIRECT))
306fa1
-		rm_unwanted(ap->logopt, path, 0, ap->dev);
306fa1
+		rm_unwanted(ap, path, 0);
306fa1
 }
306fa1
 
306fa1
 /* Try to purge cache entries kept around due to existing mounts */
306fa1
@@ -553,7 +560,9 @@ int umount_multi(struct autofs_point *ap
306fa1
 	left += umount_subtree_mounts(ap, path, is_autofs_fs);
306fa1
 
306fa1
 	/* Delete detritus like unwanted mountpoints and symlinks */
306fa1
-	if (left == 0 && ap->state != ST_READMAP) {
306fa1
+	if (left == 0 &&
306fa1
+	    ap->state != ST_READMAP &&
306fa1
+	    !count_mounts(ap, path, ap->dev)) {
306fa1
 		update_map_cache(ap, path);
306fa1
 		check_rm_dirs(ap, path, incl);
306fa1
 	}
306fa1
--- autofs-5.0.7.orig/daemon/direct.c
306fa1
+++ autofs-5.0.7/daemon/direct.c
306fa1
@@ -912,7 +912,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->logopt, next->path, st.st_dev)) {
306fa1
+			    !count_mounts(ap, next->path, st.st_dev)) {
306fa1
 				ops->close(ap->logopt, me->ioctlfd);
306fa1
 				me->ioctlfd = -1;
306fa1
 				cache_unlock(me->mc);
306fa1
--- autofs-5.0.7.orig/daemon/indirect.c
306fa1
+++ autofs-5.0.7/daemon/indirect.c
306fa1
@@ -365,7 +365,7 @@ force_umount:
306fa1
 	} else {
306fa1
 		info(ap->logopt, "umounted indirect mount %s", mountpoint);
306fa1
 		if (ap->submount)
306fa1
-			rm_unwanted(ap->logopt, mountpoint, 1, ap->dev);
306fa1
+			rm_unwanted(ap, mountpoint, 1);
306fa1
 	}
306fa1
 
306fa1
 	return rv;
306fa1
@@ -476,7 +476,7 @@ void *expire_proc_indirect(void *arg)
306fa1
 
306fa1
 				/* Check for manual umount */
306fa1
 				if (fstat(me->ioctlfd, &st) == -1 ||
306fa1
-				    !count_mounts(ap->logopt, me->key, st.st_dev)) {
306fa1
+				    !count_mounts(ap, me->key, st.st_dev)) {
306fa1
 					ops->close(ap->logopt, me->ioctlfd);
306fa1
 					me->ioctlfd = -1;
306fa1
 				}
306fa1
@@ -538,7 +538,7 @@ void *expire_proc_indirect(void *arg)
306fa1
 	 * so we need to umount or unlink them here.
306fa1
 	 */
306fa1
 	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state);
306fa1
-	retries = (count_mounts(ap->logopt, ap->path, ap->dev) + 1);
306fa1
+	retries = (count_mounts(ap, ap->path, ap->dev) + 1);
306fa1
 	while (retries--) {
306fa1
 		ret = ops->expire(ap->logopt, ap->ioctlfd, ap->path, now);
306fa1
 		if (ret)
306fa1
--- autofs-5.0.7.orig/include/automount.h
306fa1
+++ autofs-5.0.7/include/automount.h
306fa1
@@ -526,8 +526,8 @@ int handle_packet_expire_indirect(struct
306fa1
 int handle_packet_expire_direct(struct autofs_point *ap, autofs_packet_expire_direct_t *pkt);
306fa1
 int handle_packet_missing_indirect(struct autofs_point *ap, autofs_packet_missing_indirect_t *pkt);
306fa1
 int handle_packet_missing_direct(struct autofs_point *ap, autofs_packet_missing_direct_t *pkt);
306fa1
-void rm_unwanted(unsigned logopt, const char *path, int incl, dev_t dev);
306fa1
-int count_mounts(unsigned logopt, const char *path, dev_t dev);
306fa1
+void rm_unwanted(struct autofs_point *ap, const char *path, int incl);
306fa1
+int count_mounts(struct autofs_point *ap, const char *path, dev_t dev);
306fa1
 
306fa1
 #define mounts_mutex_lock(ap) \
306fa1
 do { \