Blame SOURCES/autofs-5.0.9-amd-lookup-dont-umount-admin-mounted-external-mounts.patch

6bbd11
autofs-5.0.9 - amd lookup dont umount admin mounted external mounts
6bbd11
6bbd11
From: Ian Kent <raven@themaw.net>
6bbd11
6bbd11
If an autofs doesn't mount an external mount then it shouldn't
6bbd11
umount it.
6bbd11
---
6bbd11
 include/mounts.h    |    2 +-
6bbd11
 lib/mounts.c        |    7 +++++--
6bbd11
 modules/parse_amd.c |    8 ++++++--
6bbd11
 3 files changed, 12 insertions(+), 5 deletions(-)
6bbd11
6bbd11
diff --git a/include/mounts.h b/include/mounts.h
6bbd11
index 07a8c3b..17cae31 100644
6bbd11
--- a/include/mounts.h
6bbd11
+++ b/include/mounts.h
6bbd11
@@ -101,7 +101,7 @@ unsigned int get_kver_major(void);
6bbd11
 unsigned int get_kver_minor(void);
6bbd11
 char *make_options_string(char *path, int kernel_pipefd, const char *extra);
6bbd11
 char *make_mnt_name_string(char *path);
6bbd11
-int ext_mount_add(struct list_head *, const char *);
6bbd11
+int ext_mount_add(struct list_head *, const char *, unsigned int);
6bbd11
 int ext_mount_remove(struct list_head *, const char *);
6bbd11
 struct mnt_list *get_mnt_list(const char *table, const char *path, int include);
6bbd11
 struct mnt_list *reverse_mnt_list(struct mnt_list *list);
6bbd11
diff --git a/lib/mounts.c b/lib/mounts.c
6bbd11
index d8357d0..c9e1237 100644
6bbd11
--- a/lib/mounts.c
6bbd11
+++ b/lib/mounts.c
6bbd11
@@ -51,6 +51,7 @@ static const char kver_options_template[]  = "fd=%d,pgrp=%u,minproto=3,maxproto=
6bbd11
 
6bbd11
 struct ext_mount {
6bbd11
 	char *mountpoint;
6bbd11
+	unsigned int umount;
6bbd11
 	struct list_head mount;
6bbd11
 	struct list_head mounts;
6bbd11
 };
6bbd11
@@ -619,7 +620,7 @@ static struct ext_mount *ext_mount_lookup(const char *mountpoint)
6bbd11
 	return NULL;
6bbd11
 }
6bbd11
 
6bbd11
-int ext_mount_add(struct list_head *entry, const char *path)
6bbd11
+int ext_mount_add(struct list_head *entry, const char *path, unsigned int umount)
6bbd11
 {
6bbd11
 	struct ext_mount *em;
6bbd11
 	char *auto_dir;
6bbd11
@@ -661,6 +662,7 @@ int ext_mount_add(struct list_head *entry, const char *path)
6bbd11
 		ret = -1;
6bbd11
 		goto done;
6bbd11
 	}
6bbd11
+	em->umount = umount;
6bbd11
 	INIT_LIST_HEAD(&em->mount);
6bbd11
 	INIT_LIST_HEAD(&em->mounts);
6bbd11
 
6bbd11
@@ -701,11 +703,12 @@ int ext_mount_remove(struct list_head *entry, const char *path)
6bbd11
 		goto done;
6bbd11
 	else {
6bbd11
 		list_del_init(&em->mount);
6bbd11
+		if (em->umount)
6bbd11
+			ret = 1;
6bbd11
 		if (list_empty(&em->mount)) {
6bbd11
 			free(em->mountpoint);
6bbd11
 			free(em);
6bbd11
 		}
6bbd11
-		ret = 1;
6bbd11
 	}
6bbd11
 done:
6bbd11
 	pthread_mutex_unlock(&ext_mount_hash_mutex);
6bbd11
diff --git a/modules/parse_amd.c b/modules/parse_amd.c
6bbd11
index fa0f75d..bc056a7 100644
6bbd11
--- a/modules/parse_amd.c
6bbd11
+++ b/modules/parse_amd.c
6bbd11
@@ -978,6 +978,7 @@ static int do_generic_mount(struct autofs_point *ap, const char *name,
6bbd11
 			    struct amd_entry *entry, const char *target,
6bbd11
 			    unsigned int flags)
6bbd11
 {
6bbd11
+	unsigned int umount = 0;
6bbd11
 	int ret = 0;
6bbd11
 
6bbd11
 	if (!entry->sublink) {
6bbd11
@@ -994,9 +995,10 @@ static int do_generic_mount(struct autofs_point *ap, const char *name,
6bbd11
 				       target, entry->type, entry->opts);
6bbd11
 			if (ret)
6bbd11
 				goto out;
6bbd11
+			umount = 1;
6bbd11
 		}
6bbd11
 		/* We might be using an external mount */
6bbd11
-		ext_mount_add(&entry->ext_mount, entry->fs);
6bbd11
+		ext_mount_add(&entry->ext_mount, entry->fs, umount);
6bbd11
 		ret = do_link_mount(ap, name, entry, flags);
6bbd11
 	}
6bbd11
 out:
6bbd11
@@ -1009,6 +1011,7 @@ static int do_nfs_mount(struct autofs_point *ap, const char *name,
6bbd11
 	char target[PATH_MAX + 1];
6bbd11
 	unsigned int proximity;
6bbd11
 	char *opts = entry->opts;
6bbd11
+	unsigned int umount = 0;
6bbd11
 	int ret = 0;
6bbd11
 
6bbd11
 	strcpy(target, entry->rhost);
6bbd11
@@ -1030,9 +1033,10 @@ static int do_nfs_mount(struct autofs_point *ap, const char *name,
6bbd11
 						mount_nfs->context);
6bbd11
 			if (ret)
6bbd11
 				goto out;
6bbd11
+			umount = 1;
6bbd11
 		}
6bbd11
 		/* We might be using an external mount */
6bbd11
-		ext_mount_add(&entry->ext_mount, entry->fs);
6bbd11
+		ext_mount_add(&entry->ext_mount, entry->fs, umount);
6bbd11
 		ret = do_link_mount(ap, name, entry, flags);
6bbd11
 	}
6bbd11
 out: