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

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