|
|
9a499a |
autofs-5.1.6 - use mnt_list for amdmounts
|
|
|
9a499a |
|
|
|
9a499a |
From: Ian Kent <raven@themaw.net>
|
|
|
9a499a |
|
|
|
9a499a |
Use struct mnt_list objects for the list of amd mounts instead of
|
|
|
9a499a |
struct amd_entry.
|
|
|
9a499a |
|
|
|
9a499a |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
9a499a |
---
|
|
|
9a499a |
CHANGELOG | 1
|
|
|
9a499a |
daemon/automount.c | 48 ++++++++++------------
|
|
|
9a499a |
daemon/lookup.c | 18 +++++---
|
|
|
9a499a |
include/automount.h | 2
|
|
|
9a499a |
include/master.h | 2
|
|
|
9a499a |
include/mounts.h | 12 +++++
|
|
|
9a499a |
include/parse_amd.h | 1
|
|
|
9a499a |
lib/master.c | 36 +----------------
|
|
|
9a499a |
lib/mounts.c | 103 ++++++++++++++++++++++++++++++++++++++++++++++++-
|
|
|
9a499a |
modules/mount_autofs.c | 15 ++++---
|
|
|
9a499a |
modules/parse_amd.c | 43 +++++++++++++++-----
|
|
|
9a499a |
11 files changed, 193 insertions(+), 88 deletions(-)
|
|
|
9a499a |
|
|
|
9a499a |
--- autofs-5.1.4.orig/CHANGELOG
|
|
|
9a499a |
+++ autofs-5.1.4/CHANGELOG
|
|
|
9a499a |
@@ -123,6 +123,7 @@ xx/xx/2018 autofs-5.1.5
|
|
|
9a499a |
- make external mounts use simpler hashtable.
|
|
|
9a499a |
- add a hash index to mnt_list.
|
|
|
9a499a |
- use mnt_list for submounts.
|
|
|
9a499a |
+- use mnt_list for amdmounts.
|
|
|
9a499a |
|
|
|
9a499a |
19/12/2017 autofs-5.1.4
|
|
|
9a499a |
- fix spec file url.
|
|
|
9a499a |
--- autofs-5.1.4.orig/daemon/automount.c
|
|
|
9a499a |
+++ autofs-5.1.4/daemon/automount.c
|
|
|
9a499a |
@@ -595,7 +595,8 @@ static int umount_subtree_mounts(struct
|
|
|
9a499a |
* it already to ensure it's ok to remove any offset triggers.
|
|
|
9a499a |
*/
|
|
|
9a499a |
if (!is_mm_root && is_mounted(path, MNTS_REAL)) {
|
|
|
9a499a |
- struct amd_entry *entry;
|
|
|
9a499a |
+ struct mnt_list *mnt;
|
|
|
9a499a |
+
|
|
|
9a499a |
debug(ap->logopt, "unmounting dir = %s", path);
|
|
|
9a499a |
if (umount_ent(ap, path) &&
|
|
|
9a499a |
is_mounted(path, MNTS_REAL)) {
|
|
|
9a499a |
@@ -605,16 +606,12 @@ static int umount_subtree_mounts(struct
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
/* Check for an external mount and umount if possible */
|
|
|
9a499a |
- mounts_mutex_lock(ap);
|
|
|
9a499a |
- entry = __master_find_amdmount(ap, path);
|
|
|
9a499a |
- if (!entry) {
|
|
|
9a499a |
- mounts_mutex_unlock(ap);
|
|
|
9a499a |
- goto done;
|
|
|
9a499a |
+ mnt = mnts_find_amdmount(path);
|
|
|
9a499a |
+ if (mnt) {
|
|
|
9a499a |
+ umount_amd_ext_mount(ap, mnt->ext_mp);
|
|
|
9a499a |
+ mnts_remove_amdmount(path);
|
|
|
9a499a |
+ mnts_put_mount(mnt);
|
|
|
9a499a |
}
|
|
|
9a499a |
- list_del(&entry->entries);
|
|
|
9a499a |
- mounts_mutex_unlock(ap);
|
|
|
9a499a |
- umount_amd_ext_mount(ap, entry->fs);
|
|
|
9a499a |
- free_amd_entry(entry);
|
|
|
9a499a |
}
|
|
|
9a499a |
done:
|
|
|
9a499a |
return left;
|
|
|
9a499a |
@@ -639,7 +636,8 @@ int umount_multi(struct autofs_point *ap
|
|
|
9a499a |
|
|
|
9a499a |
/* if this is a symlink we can handle it now */
|
|
|
9a499a |
if (S_ISLNK(st.st_mode)) {
|
|
|
9a499a |
- struct amd_entry *entry;
|
|
|
9a499a |
+ struct mnt_list *mnt;
|
|
|
9a499a |
+
|
|
|
9a499a |
if (st.st_dev != ap->dev) {
|
|
|
9a499a |
crit(ap->logopt,
|
|
|
9a499a |
"symlink %s has the wrong device, "
|
|
|
9a499a |
@@ -671,17 +669,15 @@ int umount_multi(struct autofs_point *ap
|
|
|
9a499a |
"mkdir_path %s failed: %s", path, estr);
|
|
|
9a499a |
}
|
|
|
9a499a |
}
|
|
|
9a499a |
+
|
|
|
9a499a |
/* Check for an external mount and attempt umount if needed */
|
|
|
9a499a |
- mounts_mutex_lock(ap);
|
|
|
9a499a |
- entry = __master_find_amdmount(ap, path);
|
|
|
9a499a |
- if (!entry) {
|
|
|
9a499a |
- mounts_mutex_unlock(ap);
|
|
|
9a499a |
- return 0;
|
|
|
9a499a |
- }
|
|
|
9a499a |
- list_del(&entry->entries);
|
|
|
9a499a |
- mounts_mutex_unlock(ap);
|
|
|
9a499a |
- umount_amd_ext_mount(ap, entry->fs);
|
|
|
9a499a |
- free_amd_entry(entry);
|
|
|
9a499a |
+ mnt = mnts_find_amdmount(path);
|
|
|
9a499a |
+ if (mnt) {
|
|
|
9a499a |
+ umount_amd_ext_mount(ap, mnt->ext_mp);
|
|
|
9a499a |
+ mnts_remove_amdmount(path);
|
|
|
9a499a |
+ mnts_put_mount(mnt);
|
|
|
9a499a |
+ }
|
|
|
9a499a |
+
|
|
|
9a499a |
return 0;
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
@@ -1720,17 +1716,17 @@ static void handle_mounts_cleanup(void *
|
|
|
9a499a |
clean = 1;
|
|
|
9a499a |
|
|
|
9a499a |
if (submount) {
|
|
|
9a499a |
- struct amd_entry *am;
|
|
|
9a499a |
+ struct mnt_list *mnt;
|
|
|
9a499a |
|
|
|
9a499a |
/* We are finishing up */
|
|
|
9a499a |
ap->parent->submnt_count--;
|
|
|
9a499a |
|
|
|
9a499a |
/* Submount at ap->path belongs to parent submount list. */
|
|
|
9a499a |
mnts_remove_submount(ap->path);
|
|
|
9a499a |
- am = __master_find_amdmount(ap->parent, ap->path);
|
|
|
9a499a |
- if (am) {
|
|
|
9a499a |
- list_del_init(&am->entries);
|
|
|
9a499a |
- free_amd_entry(am);
|
|
|
9a499a |
+ mnt = mnts_find_amdmount(ap->path);
|
|
|
9a499a |
+ if (mnt) {
|
|
|
9a499a |
+ mnts_remove_amdmount(ap->path);
|
|
|
9a499a |
+ mnts_put_mount(mnt);
|
|
|
9a499a |
}
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
--- autofs-5.1.4.orig/daemon/lookup.c
|
|
|
9a499a |
+++ autofs-5.1.4/daemon/lookup.c
|
|
|
9a499a |
@@ -838,7 +838,7 @@ static int lookup_amd_instance(struct au
|
|
|
9a499a |
const char *name, int name_len)
|
|
|
9a499a |
{
|
|
|
9a499a |
struct map_source *instance;
|
|
|
9a499a |
- struct amd_entry *entry;
|
|
|
9a499a |
+ struct mnt_list *mnt;
|
|
|
9a499a |
const char *argv[2];
|
|
|
9a499a |
const char **pargv = NULL;
|
|
|
9a499a |
int argc = 0;
|
|
|
9a499a |
@@ -861,21 +861,23 @@ static int lookup_amd_instance(struct au
|
|
|
9a499a |
strcpy(m_key, ap->path);
|
|
|
9a499a |
strcat(m_key, "/");
|
|
|
9a499a |
strcat(m_key, me->multi->key);
|
|
|
9a499a |
- entry = master_find_amdmount(ap, m_key);
|
|
|
9a499a |
+
|
|
|
9a499a |
+ mnt = mnts_find_amdmount(m_key);
|
|
|
9a499a |
free(m_key);
|
|
|
9a499a |
|
|
|
9a499a |
- if (!entry) {
|
|
|
9a499a |
+ if (!mnt) {
|
|
|
9a499a |
error(ap->logopt, "expected amd mount entry not found");
|
|
|
9a499a |
return NSS_STATUS_UNKNOWN;
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
- if (strcmp(entry->type, "host")) {
|
|
|
9a499a |
- error(ap->logopt, "unexpected map type %s", entry->type);
|
|
|
9a499a |
+ if (strcmp(mnt->amd_type, "host")) {
|
|
|
9a499a |
+ error(ap->logopt, "unexpected map type %s", mnt->amd_type);
|
|
|
9a499a |
+ mnts_put_mount(mnt);
|
|
|
9a499a |
return NSS_STATUS_UNKNOWN;
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
- if (entry->opts && *entry->opts) {
|
|
|
9a499a |
- argv[0] = entry->opts;
|
|
|
9a499a |
+ if (mnt->amd_opts && *mnt->amd_opts) {
|
|
|
9a499a |
+ argv[0] = mnt->amd_opts;
|
|
|
9a499a |
argv[1] = NULL;
|
|
|
9a499a |
pargv = argv;
|
|
|
9a499a |
argc = 1;
|
|
|
9a499a |
@@ -894,9 +896,11 @@ static int lookup_amd_instance(struct au
|
|
|
9a499a |
}
|
|
|
9a499a |
}
|
|
|
9a499a |
if (!instance) {
|
|
|
9a499a |
+ mnts_put_mount(mnt);
|
|
|
9a499a |
error(ap->logopt, "expected hosts map instance not found");
|
|
|
9a499a |
return NSS_STATUS_UNKNOWN;
|
|
|
9a499a |
}
|
|
|
9a499a |
+ mnts_put_mount(mnt);
|
|
|
9a499a |
|
|
|
9a499a |
return do_lookup_mount(ap, instance, name, name_len);
|
|
|
9a499a |
}
|
|
|
9a499a |
--- autofs-5.1.4.orig/include/automount.h
|
|
|
9a499a |
+++ autofs-5.1.4/include/automount.h
|
|
|
9a499a |
@@ -568,10 +568,10 @@ struct autofs_point {
|
|
|
9a499a |
struct autofs_point *parent; /* Owner of mounts list for submount */
|
|
|
9a499a |
pthread_mutex_t mounts_mutex; /* Protect mount lists */
|
|
|
9a499a |
struct list_head mounts; /* List of autofs mounts at current level */
|
|
|
9a499a |
- struct list_head amdmounts; /* List of non submount amd mounts */
|
|
|
9a499a |
unsigned int submount; /* Is this a submount */
|
|
|
9a499a |
unsigned int submnt_count; /* Number of submounts */
|
|
|
9a499a |
struct list_head submounts; /* List of child submounts */
|
|
|
9a499a |
+ struct list_head amdmounts; /* List of non submount amd mounts */
|
|
|
9a499a |
unsigned int shutdown; /* Shutdown notification */
|
|
|
9a499a |
};
|
|
|
9a499a |
|
|
|
9a499a |
--- autofs-5.1.4.orig/include/master.h
|
|
|
9a499a |
+++ autofs-5.1.4/include/master.h
|
|
|
9a499a |
@@ -109,8 +109,6 @@ void master_source_current_wait(struct m
|
|
|
9a499a |
void master_source_current_signal(struct master_mapent *);
|
|
|
9a499a |
struct master_mapent *master_find_mapent(struct master *, const char *);
|
|
|
9a499a |
unsigned int master_partial_match_mapent(struct master *, const char *);
|
|
|
9a499a |
-struct amd_entry *__master_find_amdmount(struct autofs_point *, const char *);
|
|
|
9a499a |
-struct amd_entry *master_find_amdmount(struct autofs_point *, const char *);
|
|
|
9a499a |
struct master_mapent *master_new_mapent(struct master *, const char *, time_t);
|
|
|
9a499a |
void master_add_mapent(struct master *, struct master_mapent *);
|
|
|
9a499a |
void master_remove_mapent(struct master_mapent *);
|
|
|
9a499a |
--- autofs-5.1.4.orig/include/mounts.h
|
|
|
9a499a |
+++ autofs-5.1.4/include/mounts.h
|
|
|
9a499a |
@@ -38,6 +38,7 @@
|
|
|
9a499a |
#define MNTS_INDIRECT 0x0008
|
|
|
9a499a |
#define MNTS_DIRECT 0x0010
|
|
|
9a499a |
#define MNTS_OFFSET 0x0020
|
|
|
9a499a |
+#define MNTS_AMD_MOUNT 0x0040
|
|
|
9a499a |
|
|
|
9a499a |
#define REMOUNT_SUCCESS 0x0000
|
|
|
9a499a |
#define REMOUNT_FAIL 0x0001
|
|
|
9a499a |
@@ -64,6 +65,14 @@ struct mnt_list {
|
|
|
9a499a |
struct list_head submount;
|
|
|
9a499a |
struct list_head submount_work;
|
|
|
9a499a |
|
|
|
9a499a |
+ /* List of amd-mounts of an autofs_point */
|
|
|
9a499a |
+ char *ext_mp;
|
|
|
9a499a |
+ char *amd_pref;
|
|
|
9a499a |
+ char *amd_type;
|
|
|
9a499a |
+ char *amd_opts;
|
|
|
9a499a |
+ unsigned int amd_cache_opts;
|
|
|
9a499a |
+ struct list_head amdmount;
|
|
|
9a499a |
+
|
|
|
9a499a |
/*
|
|
|
9a499a |
* List operations ie. get_mnt_list.
|
|
|
9a499a |
*/
|
|
|
9a499a |
@@ -118,6 +127,9 @@ struct mnt_list *mnts_add_submount(struc
|
|
|
9a499a |
void mnts_remove_submount(const char *mp);
|
|
|
9a499a |
void mnts_get_submount_list(struct list_head *mnts, struct autofs_point *ap);
|
|
|
9a499a |
void mnts_put_submount_list(struct list_head *mnts);
|
|
|
9a499a |
+struct mnt_list *mnts_find_amdmount(const char *path);
|
|
|
9a499a |
+struct mnt_list *mnts_add_amdmount(struct autofs_point *ap, struct amd_entry *entry);
|
|
|
9a499a |
+void mnts_remove_amdmount(const char *mp);
|
|
|
9a499a |
struct mnt_list *get_mnt_list(const char *path, int include);
|
|
|
9a499a |
int unlink_mount_tree(struct autofs_point *ap, const char *mp);
|
|
|
9a499a |
void free_mnt_list(struct mnt_list *list);
|
|
|
9a499a |
--- autofs-5.1.4.orig/include/parse_amd.h
|
|
|
9a499a |
+++ autofs-5.1.4/include/parse_amd.h
|
|
|
9a499a |
@@ -65,7 +65,6 @@ struct amd_entry {
|
|
|
9a499a |
char *umount;
|
|
|
9a499a |
struct selector *selector;
|
|
|
9a499a |
struct list_head list;
|
|
|
9a499a |
- struct list_head entries;
|
|
|
9a499a |
};
|
|
|
9a499a |
|
|
|
9a499a |
int amd_parse_list(struct autofs_point *,
|
|
|
9a499a |
--- autofs-5.1.4.orig/lib/master.c
|
|
|
9a499a |
+++ autofs-5.1.4/lib/master.c
|
|
|
9a499a |
@@ -152,12 +152,10 @@ void master_free_autofs_point(struct aut
|
|
|
9a499a |
head = &ap->amdmounts;
|
|
|
9a499a |
p = head->next;
|
|
|
9a499a |
while (p != head) {
|
|
|
9a499a |
- struct amd_entry *entry = list_entry(p, struct amd_entry, entries);
|
|
|
9a499a |
+ struct mnt_list *mnt = list_entry(p, struct mnt_list, amdmount);
|
|
|
9a499a |
p = p->next;
|
|
|
9a499a |
- if (!list_empty(&entry->entries))
|
|
|
9a499a |
- list_del(&entry->entries);
|
|
|
9a499a |
- ext_mount_remove(entry->fs);
|
|
|
9a499a |
- free_amd_entry(entry);
|
|
|
9a499a |
+ ext_mount_remove(mnt->ext_mp);
|
|
|
9a499a |
+ mnts_remove_amdmount(mnt->mp);
|
|
|
9a499a |
}
|
|
|
9a499a |
mounts_mutex_unlock(ap);
|
|
|
9a499a |
|
|
|
9a499a |
@@ -761,34 +759,6 @@ unsigned int master_partial_match_mapent
|
|
|
9a499a |
return ret;
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
-struct amd_entry *__master_find_amdmount(struct autofs_point *ap, const char *path)
|
|
|
9a499a |
-{
|
|
|
9a499a |
- struct list_head *head, *p;
|
|
|
9a499a |
-
|
|
|
9a499a |
- head = &ap->amdmounts;
|
|
|
9a499a |
- list_for_each(p, head) {
|
|
|
9a499a |
- struct amd_entry *entry;
|
|
|
9a499a |
-
|
|
|
9a499a |
- entry = list_entry(p, struct amd_entry, entries);
|
|
|
9a499a |
-
|
|
|
9a499a |
- if (!strcmp(entry->path, path))
|
|
|
9a499a |
- return entry;
|
|
|
9a499a |
- }
|
|
|
9a499a |
-
|
|
|
9a499a |
- return NULL;
|
|
|
9a499a |
-}
|
|
|
9a499a |
-
|
|
|
9a499a |
-struct amd_entry *master_find_amdmount(struct autofs_point *ap, const char *path)
|
|
|
9a499a |
-{
|
|
|
9a499a |
- struct amd_entry *entry;
|
|
|
9a499a |
-
|
|
|
9a499a |
- mounts_mutex_lock(ap);
|
|
|
9a499a |
- entry = __master_find_amdmount(ap, path);
|
|
|
9a499a |
- mounts_mutex_unlock(ap);
|
|
|
9a499a |
-
|
|
|
9a499a |
- return entry;
|
|
|
9a499a |
-}
|
|
|
9a499a |
-
|
|
|
9a499a |
struct master_mapent *master_new_mapent(struct master *master, const char *path, time_t age)
|
|
|
9a499a |
{
|
|
|
9a499a |
struct master_mapent *entry;
|
|
|
9a499a |
--- autofs-5.1.4.orig/lib/mounts.c
|
|
|
9a499a |
+++ autofs-5.1.4/lib/mounts.c
|
|
|
9a499a |
@@ -546,7 +546,6 @@ struct amd_entry *new_amd_entry(const st
|
|
|
9a499a |
memset(new, 0, sizeof(*new));
|
|
|
9a499a |
new->path = path;
|
|
|
9a499a |
INIT_LIST_HEAD(&new->list);
|
|
|
9a499a |
- INIT_LIST_HEAD(&new->entries);
|
|
|
9a499a |
|
|
|
9a499a |
return new;
|
|
|
9a499a |
}
|
|
|
9a499a |
@@ -887,6 +886,7 @@ static struct mnt_list *mnts_alloc_mount
|
|
|
9a499a |
INIT_HLIST_NODE(&this->hash);
|
|
|
9a499a |
INIT_LIST_HEAD(&this->submount);
|
|
|
9a499a |
INIT_LIST_HEAD(&this->submount_work);
|
|
|
9a499a |
+ INIT_LIST_HEAD(&this->amdmount);
|
|
|
9a499a |
done:
|
|
|
9a499a |
return this;
|
|
|
9a499a |
}
|
|
|
9a499a |
@@ -1048,6 +1048,107 @@ void mnts_put_submount_list(struct list_
|
|
|
9a499a |
mnts_hash_mutex_unlock();
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
+struct mnt_list *mnts_find_amdmount(const char *path)
|
|
|
9a499a |
+{
|
|
|
9a499a |
+ struct mnt_list *mnt;
|
|
|
9a499a |
+
|
|
|
9a499a |
+ mnt = mnts_lookup_mount(path);
|
|
|
9a499a |
+ if (mnt && mnt->flags & MNTS_AMD_MOUNT)
|
|
|
9a499a |
+ return mnt;
|
|
|
9a499a |
+ mnts_put_mount(mnt);
|
|
|
9a499a |
+ return NULL;
|
|
|
9a499a |
+}
|
|
|
9a499a |
+
|
|
|
9a499a |
+struct mnt_list *mnts_add_amdmount(struct autofs_point *ap, struct amd_entry *entry)
|
|
|
9a499a |
+{
|
|
|
9a499a |
+ struct mnt_list *this;
|
|
|
9a499a |
+ char *type, *ext_mp, *pref, *opts;
|
|
|
9a499a |
+
|
|
|
9a499a |
+ ext_mp = pref = type = opts = NULL;
|
|
|
9a499a |
+
|
|
|
9a499a |
+ if (entry->fs) {
|
|
|
9a499a |
+ ext_mp = strdup(entry->fs);
|
|
|
9a499a |
+ if (!ext_mp)
|
|
|
9a499a |
+ goto fail;
|
|
|
9a499a |
+ }
|
|
|
9a499a |
+
|
|
|
9a499a |
+ if (entry->pref) {
|
|
|
9a499a |
+ pref = strdup(entry->pref);
|
|
|
9a499a |
+ if (!pref)
|
|
|
9a499a |
+ goto fail;
|
|
|
9a499a |
+ }
|
|
|
9a499a |
+
|
|
|
9a499a |
+ if (entry->type) {
|
|
|
9a499a |
+ type = strdup(entry->type);
|
|
|
9a499a |
+ if (!type)
|
|
|
9a499a |
+ goto fail;
|
|
|
9a499a |
+ }
|
|
|
9a499a |
+
|
|
|
9a499a |
+ if (entry->opts) {
|
|
|
9a499a |
+ opts = strdup(entry->opts);
|
|
|
9a499a |
+ if (!opts)
|
|
|
9a499a |
+ goto fail;
|
|
|
9a499a |
+ }
|
|
|
9a499a |
+
|
|
|
9a499a |
+ mnts_hash_mutex_lock();
|
|
|
9a499a |
+ this = mnts_get_mount(entry->path);
|
|
|
9a499a |
+ if (this) {
|
|
|
9a499a |
+ this->ext_mp = ext_mp;
|
|
|
9a499a |
+ this->amd_pref = pref;
|
|
|
9a499a |
+ this->amd_type = type;
|
|
|
9a499a |
+ this->amd_opts = opts;
|
|
|
9a499a |
+ this->amd_cache_opts = entry->cache_opts;
|
|
|
9a499a |
+ this->flags |= MNTS_AMD_MOUNT;
|
|
|
9a499a |
+ if (list_empty(&this->amdmount))
|
|
|
9a499a |
+ list_add_tail(&this->amdmount, &ap->amdmounts);
|
|
|
9a499a |
+ }
|
|
|
9a499a |
+ mnts_hash_mutex_unlock();
|
|
|
9a499a |
+
|
|
|
9a499a |
+ return this;
|
|
|
9a499a |
+fail:
|
|
|
9a499a |
+ if (ext_mp)
|
|
|
9a499a |
+ free(ext_mp);
|
|
|
9a499a |
+ if (pref)
|
|
|
9a499a |
+ free(pref);
|
|
|
9a499a |
+ if (type)
|
|
|
9a499a |
+ free(type);
|
|
|
9a499a |
+ if (opts)
|
|
|
9a499a |
+ free(opts);
|
|
|
9a499a |
+ return NULL;
|
|
|
9a499a |
+}
|
|
|
9a499a |
+
|
|
|
9a499a |
+void mnts_remove_amdmount(const char *mp)
|
|
|
9a499a |
+{
|
|
|
9a499a |
+ struct mnt_list *this;
|
|
|
9a499a |
+
|
|
|
9a499a |
+ mnts_hash_mutex_lock();
|
|
|
9a499a |
+ this = mnts_lookup(mp);
|
|
|
9a499a |
+ if (!(this && this->flags & MNTS_AMD_MOUNT))
|
|
|
9a499a |
+ goto done;
|
|
|
9a499a |
+ this->flags &= ~MNTS_AMD_MOUNT;
|
|
|
9a499a |
+ list_del_init(&this->submount);
|
|
|
9a499a |
+ if (this->ext_mp) {
|
|
|
9a499a |
+ free(this->ext_mp);
|
|
|
9a499a |
+ this->ext_mp = NULL;
|
|
|
9a499a |
+ }
|
|
|
9a499a |
+ if (this->amd_type) {
|
|
|
9a499a |
+ free(this->amd_type);
|
|
|
9a499a |
+ this->amd_type = NULL;
|
|
|
9a499a |
+ }
|
|
|
9a499a |
+ if (this->amd_pref) {
|
|
|
9a499a |
+ free(this->amd_pref);
|
|
|
9a499a |
+ this->amd_pref = NULL;
|
|
|
9a499a |
+ }
|
|
|
9a499a |
+ if (this->amd_opts) {
|
|
|
9a499a |
+ free(this->amd_opts);
|
|
|
9a499a |
+ this->amd_opts = NULL;
|
|
|
9a499a |
+ }
|
|
|
9a499a |
+ this->amd_cache_opts = 0;
|
|
|
9a499a |
+ __mnts_put_mount(this);
|
|
|
9a499a |
+done:
|
|
|
9a499a |
+ mnts_hash_mutex_unlock();
|
|
|
9a499a |
+}
|
|
|
9a499a |
+
|
|
|
9a499a |
/* From glibc decode_name() */
|
|
|
9a499a |
/* Since the values in a line are separated by spaces, a name cannot
|
|
|
9a499a |
* contain a space. Therefore some programs encode spaces in names
|
|
|
9a499a |
--- autofs-5.1.4.orig/modules/mount_autofs.c
|
|
|
9a499a |
+++ autofs-5.1.4/modules/mount_autofs.c
|
|
|
9a499a |
@@ -286,16 +286,19 @@ int mount_mount(struct autofs_point *ap,
|
|
|
9a499a |
mounts_mutex_lock(ap);
|
|
|
9a499a |
|
|
|
9a499a |
if (source->flags & MAP_FLAG_FORMAT_AMD) {
|
|
|
9a499a |
- struct amd_entry *am_entry = __master_find_amdmount(ap, entry->path);
|
|
|
9a499a |
+ struct mnt_list *mnt;
|
|
|
9a499a |
|
|
|
9a499a |
- if (am_entry) {
|
|
|
9a499a |
- if (am_entry->pref) {
|
|
|
9a499a |
- nap->pref = am_entry->pref;
|
|
|
9a499a |
- am_entry->pref = NULL;
|
|
|
9a499a |
+ mnt = mnts_find_amdmount(entry->path);
|
|
|
9a499a |
+ if (mnt) {
|
|
|
9a499a |
+ if (mnt->amd_pref) {
|
|
|
9a499a |
+ nap->pref = mnt->amd_pref;
|
|
|
9a499a |
+ mnt->amd_pref = NULL;
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
- if (am_entry->cache_opts & AMD_CACHE_OPTION_ALL)
|
|
|
9a499a |
+ if (mnt->amd_cache_opts & AMD_CACHE_OPTION_ALL)
|
|
|
9a499a |
nap->flags |= MOUNT_FLAG_AMD_CACHE_ALL;
|
|
|
9a499a |
+
|
|
|
9a499a |
+ mnts_put_mount(mnt);
|
|
|
9a499a |
}
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
--- autofs-5.1.4.orig/modules/parse_amd.c
|
|
|
9a499a |
+++ autofs-5.1.4/modules/parse_amd.c
|
|
|
9a499a |
@@ -1300,6 +1300,7 @@ static int do_host_mount(struct autofs_p
|
|
|
9a499a |
{
|
|
|
9a499a |
struct lookup_mod *lookup;
|
|
|
9a499a |
struct map_source *instance;
|
|
|
9a499a |
+ struct mnt_list *mnt = NULL;
|
|
|
9a499a |
struct mapent *me;
|
|
|
9a499a |
const char *argv[2];
|
|
|
9a499a |
const char **pargv = NULL;
|
|
|
9a499a |
@@ -1316,7 +1317,9 @@ static int do_host_mount(struct autofs_p
|
|
|
9a499a |
*/
|
|
|
9a499a |
if (strcmp(name, entry->rhost)) {
|
|
|
9a499a |
char *target;
|
|
|
9a499a |
- size_t len = strlen(ap->path) + strlen(entry->rhost) + 2;
|
|
|
9a499a |
+ size_t len;
|
|
|
9a499a |
+
|
|
|
9a499a |
+ len = strlen(ap->path) + strlen(entry->rhost) + 2;
|
|
|
9a499a |
target = malloc(len);
|
|
|
9a499a |
if (!target) {
|
|
|
9a499a |
warn(ap->logopt, MODPREFIX
|
|
|
9a499a |
@@ -1329,6 +1332,15 @@ static int do_host_mount(struct autofs_p
|
|
|
9a499a |
if (entry->path)
|
|
|
9a499a |
free(entry->path);
|
|
|
9a499a |
entry->path = target;
|
|
|
9a499a |
+
|
|
|
9a499a |
+ /* Add an mnt_list entry for the updated path. */
|
|
|
9a499a |
+ mnt = mnts_add_amdmount(ap, entry);
|
|
|
9a499a |
+ if (!mnt) {
|
|
|
9a499a |
+ error(ap->logopt, MODPREFIX
|
|
|
9a499a |
+ "failed to update mount mnt_list entry");
|
|
|
9a499a |
+ goto out;
|
|
|
9a499a |
+ }
|
|
|
9a499a |
+
|
|
|
9a499a |
/*
|
|
|
9a499a |
* Wait for any expire before racing to mount the
|
|
|
9a499a |
* export tree or bail out if we're shutting down.
|
|
|
9a499a |
@@ -1388,6 +1400,8 @@ static int do_host_mount(struct autofs_p
|
|
|
9a499a |
warn(ap->logopt, MODPREFIX
|
|
|
9a499a |
"failed to create symlink to hosts mount base");
|
|
|
9a499a |
out:
|
|
|
9a499a |
+ if (ret && mnt)
|
|
|
9a499a |
+ mnts_remove_amdmount(mnt->mp);
|
|
|
9a499a |
return ret;
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
@@ -2204,6 +2218,7 @@ int parse_mount(struct autofs_point *ap,
|
|
|
9a499a |
struct list_head entries, *p, *head;
|
|
|
9a499a |
struct amd_entry *defaults_entry;
|
|
|
9a499a |
struct amd_entry *cur_defaults;
|
|
|
9a499a |
+ struct mnt_list *mnt;
|
|
|
9a499a |
int rv = 1;
|
|
|
9a499a |
int cur_state;
|
|
|
9a499a |
int ret;
|
|
|
9a499a |
@@ -2313,21 +2328,27 @@ int parse_mount(struct autofs_point *ap,
|
|
|
9a499a |
* add parsed entry to parent amd mount list and remove
|
|
|
9a499a |
* on mount fail.
|
|
|
9a499a |
*/
|
|
|
9a499a |
- mounts_mutex_lock(ap);
|
|
|
9a499a |
- list_add_tail(&this->entries, &ap->amdmounts);
|
|
|
9a499a |
- mounts_mutex_unlock(ap);
|
|
|
9a499a |
+ mnt = mnts_add_amdmount(ap, this);
|
|
|
9a499a |
+ if (!mnt) {
|
|
|
9a499a |
+ error(ap->logopt, MODPREFIX
|
|
|
9a499a |
+ "failed to add mount to mnt_list");
|
|
|
9a499a |
+ break;
|
|
|
9a499a |
+ }
|
|
|
9a499a |
|
|
|
9a499a |
rv = amd_mount(ap, name, this, source, sv, flags, ctxt);
|
|
|
9a499a |
- mounts_mutex_lock(ap);
|
|
|
9a499a |
if (!rv) {
|
|
|
9a499a |
- /* Mounted, remove entry from parsed list */
|
|
|
9a499a |
- list_del_init(&this->list);
|
|
|
9a499a |
- mounts_mutex_unlock(ap);
|
|
|
9a499a |
+ /*
|
|
|
9a499a |
+ * If entry->path doesn't match the mnt->mp then
|
|
|
9a499a |
+ * the mount point path has changed and a new
|
|
|
9a499a |
+ * mnt_list entry added for it, so remove the
|
|
|
9a499a |
+ * original.
|
|
|
9a499a |
+ */
|
|
|
9a499a |
+ if (strcmp(this->path, mnt->mp))
|
|
|
9a499a |
+ mnts_remove_amdmount(this->path);
|
|
|
9a499a |
break;
|
|
|
9a499a |
}
|
|
|
9a499a |
- /* Not mounted, remove entry from the parent list */
|
|
|
9a499a |
- list_del_init(&this->entries);
|
|
|
9a499a |
- mounts_mutex_unlock(ap);
|
|
|
9a499a |
+ /* Not mounted, remove the mnt_list entry from amdmount list */
|
|
|
9a499a |
+ mnts_remove_amdmount(this->path);
|
|
|
9a499a |
}
|
|
|
9a499a |
free_amd_entry(cur_defaults);
|
|
|
9a499a |
|