diff options
author | Ian Kent <raven@themaw.net> | 2019-06-19 10:03:19 +0800 |
---|---|---|
committer | Ian Kent <raven@themaw.net> | 2020-12-14 15:35:16 +0800 |
commit | 9c4c59243fd156bd798cc93a96a069d48544bc89 (patch) | |
tree | 40b57f9528ccac7c4ad6e9ef28d1115908663d28 /modules | |
parent | 759b1cc2e7da8305039dc51d4a5bb533b4da570b (diff) | |
download | autofs-9c4c59243fd156bd798cc93a96a069d48544bc89.tar.gz |
autofs-5.1.6 - use mnt_list for amdmounts
Use struct mnt_list objects for the list of amd mounts instead of
struct amd_entry.
Signed-off-by: Ian Kent <raven@themaw.net>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/mount_autofs.c | 15 | ||||
-rw-r--r-- | modules/parse_amd.c | 43 |
2 files changed, 41 insertions, 17 deletions
diff --git a/modules/mount_autofs.c b/modules/mount_autofs.c index 356bba8c..1c40e27a 100644 --- a/modules/mount_autofs.c +++ b/modules/mount_autofs.c @@ -286,16 +286,19 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, mounts_mutex_lock(ap); if (source->flags & MAP_FLAG_FORMAT_AMD) { - struct amd_entry *am_entry = __master_find_amdmount(ap, entry->path); + struct mnt_list *mnt; - if (am_entry) { - if (am_entry->pref) { - nap->pref = am_entry->pref; - am_entry->pref = NULL; + mnt = mnts_find_amdmount(entry->path); + if (mnt) { + if (mnt->amd_pref) { + nap->pref = mnt->amd_pref; + mnt->amd_pref = NULL; } - if (am_entry->cache_opts & AMD_CACHE_OPTION_ALL) + if (mnt->amd_cache_opts & AMD_CACHE_OPTION_ALL) nap->flags |= MOUNT_FLAG_AMD_CACHE_ALL; + + mnts_put_mount(mnt); } } diff --git a/modules/parse_amd.c b/modules/parse_amd.c index 43ee779e..d3e8a450 100644 --- a/modules/parse_amd.c +++ b/modules/parse_amd.c @@ -1300,6 +1300,7 @@ static int do_host_mount(struct autofs_point *ap, const char *name, { struct lookup_mod *lookup; struct map_source *instance; + struct mnt_list *mnt = NULL; struct mapent *me; const char *argv[2]; const char **pargv = NULL; @@ -1316,7 +1317,9 @@ static int do_host_mount(struct autofs_point *ap, const char *name, */ if (strcmp(name, entry->rhost)) { char *target; - size_t len = strlen(ap->path) + strlen(entry->rhost) + 2; + size_t len; + + len = strlen(ap->path) + strlen(entry->rhost) + 2; target = malloc(len); if (!target) { warn(ap->logopt, MODPREFIX @@ -1329,6 +1332,15 @@ static int do_host_mount(struct autofs_point *ap, const char *name, if (entry->path) free(entry->path); entry->path = target; + + /* Add an mnt_list entry for the updated path. */ + mnt = mnts_add_amdmount(ap, entry); + if (!mnt) { + error(ap->logopt, MODPREFIX + "failed to update mount mnt_list entry"); + goto out; + } + /* * Wait for any expire before racing to mount the * export tree or bail out if we're shutting down. @@ -1388,6 +1400,8 @@ static int do_host_mount(struct autofs_point *ap, const char *name, warn(ap->logopt, MODPREFIX "failed to create symlink to hosts mount base"); out: + if (ret && mnt) + mnts_remove_amdmount(mnt->mp); return ret; } @@ -2204,6 +2218,7 @@ int parse_mount(struct autofs_point *ap, const char *name, struct list_head entries, *p, *head; struct amd_entry *defaults_entry; struct amd_entry *cur_defaults; + struct mnt_list *mnt; int rv = 1; int cur_state; int ret; @@ -2313,21 +2328,27 @@ int parse_mount(struct autofs_point *ap, const char *name, * add parsed entry to parent amd mount list and remove * on mount fail. */ - mounts_mutex_lock(ap); - list_add_tail(&this->entries, &ap->amdmounts); - mounts_mutex_unlock(ap); + mnt = mnts_add_amdmount(ap, this); + if (!mnt) { + error(ap->logopt, MODPREFIX + "failed to add mount to mnt_list"); + break; + } rv = amd_mount(ap, name, this, source, sv, flags, ctxt); - mounts_mutex_lock(ap); if (!rv) { - /* Mounted, remove entry from parsed list */ - list_del_init(&this->list); - mounts_mutex_unlock(ap); + /* + * If entry->path doesn't match the mnt->mp then + * the mount point path has changed and a new + * mnt_list entry added for it, so remove the + * original. + */ + if (strcmp(this->path, mnt->mp)) + mnts_remove_amdmount(this->path); break; } - /* Not mounted, remove entry from the parent list */ - list_del_init(&this->entries); - mounts_mutex_unlock(ap); + /* Not mounted, remove the mnt_list entry from amdmount list */ + mnts_remove_amdmount(this->path); } free_amd_entry(cur_defaults); |