Blame SOURCES/autofs-5.1.5-move-unlink_mount_tree-to-lib_mounts_c.patch

c8d72b
autofs-5.1.5 - move unlink_mount_tree() to lib/mounts.c
c8d72b
c8d72b
From: Ian Kent <raven@themaw.net>
c8d72b
c8d72b
Both daemon/direct.c and daemon/indirect.c use the same function to
c8d72b
lazy umount a list of mounts, move that function to lib/mounts.c.
c8d72b
c8d72b
Signed-off-by: Ian Kent <raven@themaw.net>
c8d72b
---
c8d72b
 CHANGELOG         |    1 +
c8d72b
 daemon/direct.c   |    2 --
c8d72b
 daemon/indirect.c |   34 ----------------------------------
c8d72b
 include/mounts.h  |    1 +
c8d72b
 lib/mounts.c      |   35 +++++++++++++++++++++++++++++++++++
c8d72b
 5 files changed, 37 insertions(+), 36 deletions(-)
c8d72b
c8d72b
--- autofs-5.0.7.orig/CHANGELOG
c8d72b
+++ autofs-5.0.7/CHANGELOG
c8d72b
@@ -345,6 +345,7 @@
c8d72b
 - refactor unlink_active_mounts() in direct.c.
c8d72b
 - don't use tree_is_mounted() for mounted checks.
c8d72b
 - use single unlink_umount_tree() for both direct and indirect mounts.
c8d72b
+- move unlink_mount_tree() to lib/mounts.c.
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
@@ -49,8 +49,6 @@ pthread_key_t key_mnt_direct_params;
c8d72b
 pthread_key_t key_mnt_offset_params;
c8d72b
 pthread_once_t key_mnt_params_once = PTHREAD_ONCE_INIT;
c8d72b
 
c8d72b
-int unlink_mount_tree(struct autofs_point *ap, struct mnt_list *mnts);
c8d72b
-
c8d72b
 static void key_mnt_params_destroy(void *arg)
c8d72b
 {
c8d72b
 	struct mnt_params *mp;
c8d72b
--- autofs-5.0.7.orig/daemon/indirect.c
c8d72b
+++ autofs-5.0.7/daemon/indirect.c
c8d72b
@@ -40,40 +40,6 @@
c8d72b
 /* Attribute to create detached thread */
c8d72b
 extern pthread_attr_t th_attr_detached;
c8d72b
 
c8d72b
-int unlink_mount_tree(struct autofs_point *ap, struct mnt_list *mnts)
c8d72b
-{
c8d72b
-	struct mnt_list *this;
c8d72b
-	int rv, ret;
c8d72b
-
c8d72b
-	ret = 1;
c8d72b
-	this = mnts;
c8d72b
-	while (this) {
c8d72b
-		if (this->flags & MNTS_AUTOFS)
c8d72b
-			rv = umount2(this->mp, MNT_DETACH);
c8d72b
-		else
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->mp);
c8d72b
-
c8d72b
-			switch (errno) {
c8d72b
-			case EINVAL:
c8d72b
-				warn(ap->logopt,
c8d72b
-				      "bad superblock or not mounted");
c8d72b
-				break;
c8d72b
-
c8d72b
-			case ENOENT:
c8d72b
-			case EFAULT:
c8d72b
-				ret = 0;
c8d72b
-				warn(ap->logopt, "bad path for mount");
c8d72b
-				break;
c8d72b
-			}
c8d72b
-		}
c8d72b
-		this = this->next;
c8d72b
-	}
c8d72b
-	return ret;
c8d72b
-}
c8d72b
-
c8d72b
 static int do_mount_autofs_indirect(struct autofs_point *ap, const char *root)
c8d72b
 {
c8d72b
 	const char *str_indirect = mount_type_str(t_indirect);
c8d72b
--- autofs-5.0.7.orig/include/mounts.h
c8d72b
+++ autofs-5.0.7/include/mounts.h
c8d72b
@@ -100,6 +100,7 @@ int ext_mount_add(struct list_head *, co
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 *path, int include);
c8d72b
+int unlink_mount_tree(struct autofs_point *ap, struct mnt_list *mnts);
c8d72b
 void free_mnt_list(struct mnt_list *list);
c8d72b
 int is_mounted(const char *mp, unsigned int type);
c8d72b
 void tree_free_mnt_tree(struct mnt_list *tree);
c8d72b
--- autofs-5.0.7.orig/lib/mounts.c
c8d72b
+++ autofs-5.0.7/lib/mounts.c
c8d72b
@@ -882,6 +882,41 @@ local_getmntent_r(FILE *tab, struct mnte
c8d72b
 	return mnt;
c8d72b
 }
c8d72b
 
c8d72b
+int unlink_mount_tree(struct autofs_point *ap, struct mnt_list *mnts)
c8d72b
+{
c8d72b
+	struct mnt_list *this;
c8d72b
+	int rv, ret;
c8d72b
+
c8d72b
+	ret = 1;
c8d72b
+	this = mnts;
c8d72b
+	while (this) {
c8d72b
+		if (this->flags & MNTS_AUTOFS)
c8d72b
+			rv = umount2(this->mp, MNT_DETACH);
c8d72b
+		else
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->mp);
c8d72b
+
c8d72b
+			switch (errno) {
c8d72b
+			case EINVAL:
c8d72b
+				warn(ap->logopt,
c8d72b
+				      "bad superblock or not mounted");
c8d72b
+				break;
c8d72b
+
c8d72b
+			case ENOENT:
c8d72b
+			case EFAULT:
c8d72b
+				ret = 0;
c8d72b
+				warn(ap->logopt, "bad path for mount");
c8d72b
+				break;
c8d72b
+			}
c8d72b
+		}
c8d72b
+		this = this->next;
c8d72b
+	}
c8d72b
+
c8d72b
+	return ret;
c8d72b
+}
c8d72b
+
c8d72b
 /*
c8d72b
  * Get list of mounts under path in longest->shortest order
c8d72b
  */