diff --git a/CHANGELOG b/CHANGELOG index 559f087..5ca3a1a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -29,6 +29,7 @@ - fix nested submount expiring away when pwd is base of submount. - more expire re-work to cope better with shutdown following cthon tests. - allow hostname to start with numeric when validating. +- fix included map lookup. 13/7/2006 autofs-5.0.1 rc1 -------------------------- diff --git a/daemon/automount.c b/daemon/automount.c index 446c184..a8969c0 100644 --- a/daemon/automount.c +++ b/daemon/automount.c @@ -386,7 +386,7 @@ static int umount_subtree_mounts(struct return 0; } - mc = me->source->mc; + mc = me->mc; is_mm_root = (me->multi == me); left = 0; diff --git a/daemon/direct.c b/daemon/direct.c index 18b56fe..ffb3009 100644 --- a/daemon/direct.c +++ b/daemon/direct.c @@ -424,7 +424,7 @@ got_version: "failed to stat direct mount trigger %s", me->key); goto out_close; } - cache_set_ino_index(me->source->mc, me->key, st.st_dev, st.st_ino); + cache_set_ino_index(me->mc, me->key, st.st_dev, st.st_ino); close(ioctlfd); @@ -705,7 +705,7 @@ int mount_autofs_offset(struct autofs_po goto out_close; } - cache_set_ino_index(me->source->mc, me->key, st.st_dev, st.st_ino); + cache_set_ino_index(me->mc, me->key, st.st_dev, st.st_ino); close(ioctlfd); @@ -826,9 +826,9 @@ void *expire_proc_direct(void *arg) if (me->ioctlfd >= 0) { /* Real mounts have an open ioctl fd */ ioctlfd = me->ioctlfd; - cache_unlock(me->source->mc); + cache_unlock(me->mc); } else { - cache_unlock(me->source->mc); + cache_unlock(me->mc); continue; } diff --git a/daemon/indirect.c b/daemon/indirect.c index e04f164..729c9de 100644 --- a/daemon/indirect.c +++ b/daemon/indirect.c @@ -482,7 +482,7 @@ void *expire_proc_indirect(void *arg) } else { ioctlfd = ap->ioctlfd; } - cache_unlock(me->source->mc); + cache_unlock(me->mc); debug(ap->logopt, "expire %s", next->path); diff --git a/include/automount.h b/include/automount.h index e3ecc75..6153f71 100644 --- a/include/automount.h +++ b/include/automount.h @@ -139,8 +139,7 @@ struct mapent { struct list_head ino_index; pthread_mutex_t multi_mutex; struct list_head multi_list; - /* Map source of the cache entry */ - struct map_source *source; + struct mapent_cache *mc; /* Need to know owner if we're a multi-mount */ struct mapent *multi; /* Parent nesting point within multi-mount */ @@ -173,12 +172,10 @@ struct mapent *cache_lookup(struct mapen 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 *source, - const char *key, const char *mapent, time_t age); +int cache_add(struct mapent_cache *mc, 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_set_parents(struct mapent *mm); -int cache_update(struct mapent_cache *mc, struct map_source *source, - const char *key, const char *mapent, time_t age); +int cache_update(struct mapent_cache *mc, const char *key, const char *mapent, time_t age); int cache_delete(struct mapent_cache *mc, const char *key); void cache_multi_lock(struct mapent *me); void cache_multi_unlock(struct mapent *me); diff --git a/lib/cache.c b/lib/cache.c index 35dfa5a..009d271 100644 --- a/lib/cache.c +++ b/lib/cache.c @@ -441,8 +441,7 @@ struct mapent *cache_partial_match(struc } /* cache must be write locked by caller */ -int cache_add(struct mapent_cache *mc, struct map_source *source, - const char *key, const char *mapent, time_t age) +int cache_add(struct mapent_cache *mc, const char *key, const char *mapent, time_t age) { struct mapent *me, *existing = NULL; char *pkey, *pent; @@ -473,7 +472,7 @@ int cache_add(struct mapent_cache *mc, s me->age = age; me->status = 0; - me->source = source; + me->mc = mc; INIT_LIST_HEAD(&me->ino_index); INIT_LIST_HEAD(&me->multi_list); me->multi = NULL; @@ -551,7 +550,7 @@ int cache_add_offset(struct mapent_cache if (me && me != owner) return CHE_DUPLICATE; - ret = cache_add(mc, owner->source, key, mapent, age); + ret = cache_add(mc, key, mapent, age); if (ret == CHE_FAIL) { warn(LOGOPT_ANY, "failed to add key %s to cache", key); return CHE_FAIL; @@ -619,8 +618,7 @@ int cache_set_parents(struct mapent *mm) } /* cache must be write locked by caller */ -int cache_update(struct mapent_cache *mc, struct map_source *source, - const char *key, const char *mapent, time_t age) +int cache_update(struct mapent_cache *mc, const char *key, const char *mapent, time_t age) { struct mapent *me = NULL; char *pent; @@ -628,7 +626,7 @@ int cache_update(struct mapent_cache *mc me = cache_lookup(mc, key); if (!me || (*me->key == '*' && *key != '*')) { - ret = cache_add(mc, source, key, mapent, age); + ret = cache_add(mc, key, mapent, age); if (!ret) { debug(LOGOPT_NONE, "failed for %s", key); return CHE_FAIL; diff --git a/lib/parse_subs.c b/lib/parse_subs.c index a782146..b584250 100644 --- a/lib/parse_subs.c +++ b/lib/parse_subs.c @@ -470,7 +470,7 @@ int umount_multi_triggers(struct autofs_ } if (!left && me->multi == me) { - struct mapent_cache *mc = me->source->mc; + struct mapent_cache *mc = me->mc; int status; /* diff --git a/modules/lookup_file.c b/modules/lookup_file.c index 9a9f498..47a208b 100644 --- a/modules/lookup_file.c +++ b/modules/lookup_file.c @@ -521,6 +521,7 @@ prepare_plus_include(struct autofs_point return NULL; } iap = entry->ap; + iap->kpipefd = ap->kpipefd; set_mnt_logging(iap); /* @@ -681,7 +682,7 @@ int lookup_read_map(struct autofs_point continue; cache_writelock(mc); - cache_update(mc, source, s_key, mapent, age); + cache_update(mc, s_key, mapent, age); cache_unlock(mc); free(s_key); @@ -794,7 +795,7 @@ static int lookup_one(struct autofs_poin fclose(f); cache_writelock(mc); - ret = cache_update(mc, source, key, mapent, age); + ret = cache_update(mc, key, mapent, age); cache_unlock(mc); return ret; @@ -877,7 +878,7 @@ static int lookup_wild(struct autofs_poi fclose(f); cache_writelock(mc); - ret = cache_update(mc, source, "*", mapent, age); + ret = cache_update(mc, "*", mapent, age); cache_unlock(mc); return ret; } @@ -910,7 +911,7 @@ static int check_map_indirect(struct aut cache_readlock(mc); exists = cache_lookup_distinct(mc, key); - if (exists && exists->source != source) + if (exists && exists->mc != mc) exists = NULL; cache_unlock(mc); @@ -1024,7 +1025,7 @@ int lookup_mount(struct autofs_point *ap * the map cache already we never get a mount lookup, so * we never know about it. */ - if (ap->type == LKP_INDIRECT) { + if (ap->type == LKP_INDIRECT && *key != '/') { char *lkp_key; cache_readlock(mc); @@ -1079,7 +1080,7 @@ int lookup_mount(struct autofs_point *ap cache_writelock(mc); me = cache_lookup_distinct(mc, key); if (!me) - rv = cache_update(mc, source, key, NULL, now); + rv = cache_update(mc, key, NULL, now); if (rv != CHE_FAIL) { me = cache_lookup_distinct(mc, key); me->status = now + NEGATIVE_TIMEOUT; diff --git a/modules/lookup_hesiod.c b/modules/lookup_hesiod.c index f30e9b2..562c51b 100644 --- a/modules/lookup_hesiod.c +++ b/modules/lookup_hesiod.c @@ -154,7 +154,7 @@ int lookup_mount(struct autofs_point *ap } cache_writelock(mc); - rv = cache_update(mc, source, name, best_record, time(NULL)); + rv = cache_update(mc, name, best_record, time(NULL)); cache_unlock(mc); if (rv == CHE_FAIL) return NSS_STATUS_UNAVAIL; diff --git a/modules/lookup_hosts.c b/modules/lookup_hosts.c index 3b8c4ae..08ef278 100644 --- a/modules/lookup_hosts.c +++ b/modules/lookup_hosts.c @@ -97,7 +97,7 @@ int lookup_read_map(struct autofs_point while ((host = gethostent()) != NULL) { pthread_cleanup_push(cache_lock_cleanup, mc); cache_writelock(mc); - cache_update(mc, source, host->h_name, NULL, age); + cache_update(mc, host->h_name, NULL, age); cache_unlock(mc); pthread_cleanup_pop(0); } @@ -253,7 +253,7 @@ done: debug(ap->logopt, MODPREFIX "%s -> %s", name, mapent); cache_writelock(mc); - cache_update(mc, source, name, mapent, now); + cache_update(mc, name, mapent, now); cache_unlock(mc); master_source_current_wait(ap->entry); diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c index 40864d8..855cb95 100644 --- a/modules/lookup_ldap.c +++ b/modules/lookup_ldap.c @@ -1251,7 +1251,7 @@ static int read_one_map(struct autofs_po goto next; cache_writelock(mc); - cache_update(mc, source, s_key, mapent, age); + cache_update(mc, s_key, mapent, age); cache_unlock(mc); free(s_key); @@ -1463,7 +1463,7 @@ static int lookup_one(struct autofs_poin goto next; wild = 1; cache_writelock(mc); - cache_update(mc, source, "*", mapent, age); + cache_update(mc, "*", mapent, age); cache_unlock(mc); goto next; } @@ -1473,7 +1473,7 @@ static int lookup_one(struct autofs_poin goto next; cache_writelock(mc); - ret = cache_update(mc, source, s_key, mapent, age); + ret = cache_update(mc, s_key, mapent, age); cache_unlock(mc); free(s_key); @@ -1517,7 +1517,7 @@ static int check_map_indirect(struct aut cache_readlock(mc); exists = cache_lookup_distinct(mc, key); - if (exists && exists->source != source) + if (exists && exists->mc != mc) exists = NULL; cache_unlock(mc); @@ -1613,7 +1613,7 @@ int lookup_mount(struct autofs_point *ap * the map cache already we never get a mount lookup, so * we never know about it. */ - if (ap->type == LKP_INDIRECT) { + if (ap->type == LKP_INDIRECT && *key != '/') { char *lkp_key; cache_readlock(mc); @@ -1665,7 +1665,7 @@ int lookup_mount(struct autofs_point *ap cache_writelock(mc); me = cache_lookup_distinct(mc, key); if (!me) - rv = cache_update(mc, source, key, NULL, now); + rv = cache_update(mc, key, NULL, now); if (rv != CHE_FAIL) { me = cache_lookup_distinct(mc, key); me->status = now + NEGATIVE_TIMEOUT; diff --git a/modules/lookup_nisplus.c b/modules/lookup_nisplus.c index e891c25..500bc53 100644 --- a/modules/lookup_nisplus.c +++ b/modules/lookup_nisplus.c @@ -223,7 +223,7 @@ int lookup_read_map(struct autofs_point mapent = ENTRY_VAL(this, 1); cache_writelock(mc); - cache_update(mc, source, s_key, mapent, age); + cache_update(mc, s_key, mapent, age); cache_unlock(mc); free(s_key); @@ -280,7 +280,7 @@ static int lookup_one(struct autofs_poin this = NIS_RES_OBJECT(result); mapent = ENTRY_VAL(this, 1); cache_writelock(mc); - ret = cache_update(mc, source, key, mapent, age); + ret = cache_update(mc, key, mapent, age); cache_unlock(mc); nis_freeresult(result); @@ -328,7 +328,7 @@ static int lookup_wild(struct autofs_poi this = NIS_RES_OBJECT(result); mapent = ENTRY_VAL(this, 1); cache_writelock(mc); - ret = cache_update(mc, source, "*", mapent, age); + ret = cache_update(mc, "*", mapent, age); cache_unlock(mc); nis_freeresult(result); @@ -356,7 +356,7 @@ static int check_map_indirect(struct aut cache_readlock(mc); exists = cache_lookup_distinct(mc, key); - if (exists && exists->source != source) + if (exists && exists->mc != mc) exists = NULL; cache_unlock(mc); @@ -466,7 +466,7 @@ int lookup_mount(struct autofs_point *ap * the map cache already we never get a mount lookup, so * we never know about it. */ - if (ap->type == LKP_INDIRECT) { + if (ap->type == LKP_INDIRECT && *key != '/') { char *lkp_key; cache_readlock(mc); @@ -516,7 +516,7 @@ int lookup_mount(struct autofs_point *ap cache_writelock(mc); me = cache_lookup_distinct(mc, key); if (!me) - rv = cache_update(mc, source, key, NULL, now); + rv = cache_update(mc, key, NULL, now); if (rv != CHE_FAIL) { me = cache_lookup_distinct(mc, key); me->status = time(NULL) + NEGATIVE_TIMEOUT; diff --git a/modules/lookup_program.c b/modules/lookup_program.c index 1cdbf80..a22d400 100644 --- a/modules/lookup_program.c +++ b/modules/lookup_program.c @@ -339,7 +339,7 @@ int lookup_mount(struct autofs_point *ap } cache_writelock(mc); - ret = cache_update(mc, source, name, mapent, time(NULL)); + ret = cache_update(mc, name, mapent, time(NULL)); cache_unlock(mc); if (ret == CHE_FAIL) return NSS_STATUS_UNAVAIL; diff --git a/modules/lookup_userhome.c b/modules/lookup_userhome.c index efcab0b..00a01ea 100644 --- a/modules/lookup_userhome.c +++ b/modules/lookup_userhome.c @@ -78,7 +78,7 @@ int lookup_mount(struct autofs_point *ap } cache_writelock(mc); - ret = cache_update(mc, source, name, NULL, time(NULL)); + ret = cache_update(mc, name, NULL, time(NULL)); cache_unlock(mc); if (ret == CHE_FAIL) { diff --git a/modules/lookup_yp.c b/modules/lookup_yp.c index 29a72fb..ccf6d60 100644 --- a/modules/lookup_yp.c +++ b/modules/lookup_yp.c @@ -270,7 +270,7 @@ int yp_all_callback(int status, char *yp *(mapent + vallen) = '\0'; cache_writelock(mc); - ret = cache_update(mc, source, key, mapent, age); + ret = cache_update(mc, key, mapent, age); cache_unlock(mc); free(key); @@ -387,7 +387,7 @@ static int lookup_one(struct autofs_poin } cache_writelock(mc); - ret = cache_update(mc, source, key, mapent, age); + ret = cache_update(mc, key, mapent, age); cache_unlock(mc); free(mapent); @@ -439,7 +439,7 @@ static int lookup_wild(struct autofs_poi } cache_writelock(mc); - ret = cache_update(mc, source, "*", mapent, age); + ret = cache_update(mc, "*", mapent, age); cache_unlock(mc); free(mapent); @@ -465,7 +465,7 @@ static int check_map_indirect(struct aut cache_readlock(mc); exists = cache_lookup_distinct(mc, key); - if (exists && exists->source != source) + if (exists && exists->mc != mc) exists = NULL; cache_unlock(mc); @@ -572,7 +572,7 @@ int lookup_mount(struct autofs_point *ap * the map cache already we never get a mount lookup, so * we never know about it. */ - if (ap->type == LKP_INDIRECT) { + if (ap->type == LKP_INDIRECT && *key != '/') { char *lkp_key; cache_readlock(mc); @@ -623,7 +623,7 @@ int lookup_mount(struct autofs_point *ap cache_writelock(mc); me = cache_lookup_distinct(mc, key); if (!me) - rv = cache_update(mc, source, key, NULL, now); + rv = cache_update(mc, key, NULL, now); if (rv != CHE_FAIL) { me = cache_lookup_distinct(mc, key); me->status = now + NEGATIVE_TIMEOUT; diff --git a/modules/parse_sun.c b/modules/parse_sun.c index 1f1bc3c..b3f5d67 100644 --- a/modules/parse_sun.c +++ b/modules/parse_sun.c @@ -989,7 +989,7 @@ int parse_mount(struct autofs_point *ap, * Not in the cache, perhaps it's a program map * or one that doesn't support enumeration */ - ret = cache_add(mc, source, name, mapent, time(NULL)); + ret = cache_add(mc, name, mapent, time(NULL)); if (ret == CHE_FAIL) { cache_unlock(mc); free(options);