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