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

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