autofs-5.0.6 - allow update of multi mount offset entries From: Ian Kent Currently multi mount offsets can only be added or all offsets owned by an entry deleted at once. In order to be able to update multi mount map entries we need to be able to update offset entries of an already expanded multi map cache entry. --- include/automount.h | 2 +- lib/cache.c | 4 ++-- modules/parse_sun.c | 20 ++++++++++---------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/automount.h b/include/automount.h index 40c1975..561fcc2 100644 --- a/include/automount.h +++ b/include/automount.h @@ -188,7 +188,7 @@ struct mapent *cache_lookup_distinct(struct mapent_cache *mc, const char *key); struct mapent *cache_lookup_offset(const char *prefix, const char *offset, int start, struct list_head *head); struct mapent *cache_partial_match(struct mapent_cache *mc, const char *prefix); int cache_add(struct mapent_cache *mc, struct map_source *ms, const char *key, const char *mapent, time_t age); -int cache_add_offset(struct mapent_cache *mc, const char *mkey, const char *key, const char *mapent, time_t age); +int cache_update_offset(struct mapent_cache *mc, const char *mkey, const char *key, const char *mapent, time_t age); int cache_set_parents(struct mapent *mm); int cache_update(struct mapent_cache *mc, struct map_source *ms, const char *key, const char *mapent, time_t age); int cache_delete(struct mapent_cache *mc, const char *key); diff --git a/lib/cache.c b/lib/cache.c index 1489273..9179ad5 100644 --- a/lib/cache.c +++ b/lib/cache.c @@ -647,7 +647,7 @@ static void cache_add_ordered_offset(struct mapent *me, struct list_head *head) } /* cache must be write locked by caller */ -int cache_add_offset(struct mapent_cache *mc, const char *mkey, const char *key, const char *mapent, time_t age) +int cache_update_offset(struct mapent_cache *mc, const char *mkey, const char *key, const char *mapent, time_t age) { unsigned logopt = mc->ap ? mc->ap->logopt : master_get_logopt(); struct mapent *me, *owner; @@ -659,7 +659,7 @@ int cache_add_offset(struct mapent_cache *mc, const char *mkey, const char *key, me = cache_lookup_distinct(mc, key); if (me && me->age == age) { - if (me != owner) + if (me->multi != owner) return CHE_DUPLICATE; } diff --git a/modules/parse_sun.c b/modules/parse_sun.c index c4decbc..5be7345 100644 --- a/modules/parse_sun.c +++ b/modules/parse_sun.c @@ -781,10 +781,10 @@ static int check_is_multi(const char *mapent) } static int -add_offset_entry(struct autofs_point *ap, const char *name, - const char *m_root, int m_root_len, - const char *path, const char *myoptions, const char *loc, - time_t age) +update_offset_entry(struct autofs_point *ap, const char *name, + const char *m_root, int m_root_len, + const char *path, const char *myoptions, const char *loc, + time_t age) { struct map_source *source; struct mapent_cache *mc; @@ -838,17 +838,17 @@ add_offset_entry(struct autofs_point *ap, const char *name, } else strcpy(m_mapent, loc); - ret = cache_add_offset(mc, name, m_key, m_mapent, age); + ret = cache_update_offset(mc, name, m_key, m_mapent, age); if (ret == CHE_DUPLICATE) warn(ap->logopt, MODPREFIX "syntax error or duplicate offset %s -> %s", path, loc); else if (ret == CHE_FAIL) debug(ap->logopt, MODPREFIX - "failed to add multi-mount offset %s -> %s", path, m_mapent); + "failed to update multi-mount offset %s -> %s", path, m_mapent); else { ret = CHE_OK; debug(ap->logopt, MODPREFIX - "added multi-mount offset %s -> %s", path, m_mapent); + "updated multi-mount offset %s -> %s", path, m_mapent); } return ret; @@ -1448,9 +1448,9 @@ int parse_mount(struct autofs_point *ap, const char *name, master_source_current_wait(ap->entry); ap->entry->current = source; - status = add_offset_entry(ap, name, - m_root, m_root_len, - path, myoptions, loc, age); + status = update_offset_entry(ap, name, + m_root, m_root_len, + path, myoptions, loc, age); if (status != CHE_OK) { warn(ap->logopt, MODPREFIX "error adding multi-mount");