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

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