|
|
96dc52 |
autofs-5.1.7 - remove obsolete functions
|
|
|
96dc52 |
|
|
|
96dc52 |
From: Ian Kent <raven@themaw.net>
|
|
|
96dc52 |
|
|
|
96dc52 |
Remove the code that's no longer used due to the tree mapent
|
|
|
96dc52 |
implementation.
|
|
|
96dc52 |
|
|
|
96dc52 |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
96dc52 |
---
|
|
|
96dc52 |
CHANGELOG | 1
|
|
|
96dc52 |
include/automount.h | 10 --
|
|
|
96dc52 |
include/mounts.h | 2
|
|
|
96dc52 |
lib/cache.c | 227 -------------------------------------
|
|
|
96dc52 |
lib/mounts.c | 311 ---------------------------------------------------
|
|
|
96dc52 |
modules/parse_sun.c | 56 ---------
|
|
|
96dc52 |
6 files changed, 2 insertions(+), 605 deletions(-)
|
|
|
96dc52 |
|
|
|
96dc52 |
diff --git a/CHANGELOG b/CHANGELOG
|
|
|
96dc52 |
index 5ac09f77..76fccf70 100644
|
|
|
96dc52 |
--- a/CHANGELOG
|
|
|
96dc52 |
+++ b/CHANGELOG
|
|
|
96dc52 |
@@ -41,6 +41,7 @@
|
|
|
96dc52 |
- add set_offset_tree_catatonic().
|
|
|
96dc52 |
- add mount and umount offsets functions.
|
|
|
96dc52 |
- switch to use tree implementation for offsets.
|
|
|
96dc52 |
+- remove obsolete functions.
|
|
|
96dc52 |
|
|
|
96dc52 |
25/01/2021 autofs-5.1.7
|
|
|
96dc52 |
- make bind mounts propagation slave by default.
|
|
|
96dc52 |
diff --git a/include/automount.h b/include/automount.h
|
|
|
96dc52 |
index a71b8674..e33ee8d2 100644
|
|
|
96dc52 |
--- a/include/automount.h
|
|
|
96dc52 |
+++ b/include/automount.h
|
|
|
96dc52 |
@@ -162,16 +162,13 @@ struct stack {
|
|
|
96dc52 |
struct mapent {
|
|
|
96dc52 |
struct mapent *next;
|
|
|
96dc52 |
struct list_head ino_index;
|
|
|
96dc52 |
- struct list_head multi_list;
|
|
|
96dc52 |
struct mapent_cache *mc;
|
|
|
96dc52 |
struct map_source *source;
|
|
|
96dc52 |
/* Need to know owner if we're a multi-mount */
|
|
|
96dc52 |
struct tree_node *mm_root;
|
|
|
96dc52 |
+ /* Parent nesting point within multi-mount */
|
|
|
96dc52 |
struct tree_node *mm_parent;
|
|
|
96dc52 |
struct tree_node node;
|
|
|
96dc52 |
- struct mapent *multi;
|
|
|
96dc52 |
- /* Parent nesting point within multi-mount */
|
|
|
96dc52 |
- struct mapent *parent;
|
|
|
96dc52 |
char *key;
|
|
|
96dc52 |
size_t len;
|
|
|
96dc52 |
char *mapent;
|
|
|
96dc52 |
@@ -209,7 +206,6 @@ struct mapent *cache_lookup_next(struct mapent_cache *mc, struct mapent *me);
|
|
|
96dc52 |
struct mapent *cache_lookup_key_next(struct mapent *me);
|
|
|
96dc52 |
struct mapent *cache_lookup(struct mapent_cache *mc, const char *key);
|
|
|
96dc52 |
struct mapent *cache_lookup_distinct(struct mapent_cache *mc, const char *key);
|
|
|
96dc52 |
-struct mapent *cache_lookup_offset(const char *prefix, const char *offset, int start, struct list_head *head);
|
|
|
96dc52 |
struct mapent *cache_partial_match(struct mapent_cache *mc, const char *prefix);
|
|
|
96dc52 |
struct mapent *cache_partial_match_wild(struct mapent_cache *mc, const char *prefix);
|
|
|
96dc52 |
int cache_add(struct mapent_cache *mc, struct map_source *ms, const char *key, const char *mapent, time_t age);
|
|
|
96dc52 |
@@ -217,16 +213,12 @@ int cache_update_offset(struct mapent_cache *mc, const char *mkey, const char *k
|
|
|
96dc52 |
int cache_lookup_negative(struct mapent *me, const char *key);
|
|
|
96dc52 |
void cache_update_negative(struct mapent_cache *mc, struct map_source *ms, const char *key, time_t timeout);
|
|
|
96dc52 |
struct mapent *cache_get_offset_parent(struct mapent_cache *mc, const char *key);
|
|
|
96dc52 |
-int cache_set_offset_parent(struct mapent_cache *mc, const char *offset);
|
|
|
96dc52 |
int cache_update(struct mapent_cache *mc, struct map_source *ms, const char *key, const char *mapent, time_t age);
|
|
|
96dc52 |
int cache_delete(struct mapent_cache *mc, const char *key);
|
|
|
96dc52 |
-int cache_delete_offset(struct mapent_cache *mc, const char *key);
|
|
|
96dc52 |
-int cache_delete_offset_list(struct mapent_cache *mc, const char *key);
|
|
|
96dc52 |
void cache_release(struct map_source *map);
|
|
|
96dc52 |
void cache_clean_null_cache(struct mapent_cache *mc);
|
|
|
96dc52 |
void cache_release_null_cache(struct master *master);
|
|
|
96dc52 |
struct mapent *cache_enumerate(struct mapent_cache *mc, struct mapent *me);
|
|
|
96dc52 |
-char *cache_get_offset(const char *prefix, char *offset, int start, struct list_head *head, struct list_head **pos);
|
|
|
96dc52 |
|
|
|
96dc52 |
/* Utility functions */
|
|
|
96dc52 |
|
|
|
96dc52 |
diff --git a/include/mounts.h b/include/mounts.h
|
|
|
96dc52 |
index e56f80ba..ec895e1c 100644
|
|
|
96dc52 |
--- a/include/mounts.h
|
|
|
96dc52 |
+++ b/include/mounts.h
|
|
|
96dc52 |
@@ -187,8 +187,6 @@ void set_indirect_mount_tree_catatonic(struct autofs_point *);
|
|
|
96dc52 |
void set_direct_mount_tree_catatonic(struct autofs_point *, struct mapent *);
|
|
|
96dc52 |
int umount_ent(struct autofs_point *, const char *);
|
|
|
96dc52 |
int umount_amd_ext_mount(struct autofs_point *, const char *);
|
|
|
96dc52 |
-int mount_multi_triggers(struct autofs_point *, struct mapent *, const char *, unsigned int, const char *);
|
|
|
96dc52 |
-int umount_multi_triggers(struct autofs_point *, struct mapent *, char *, const char *);
|
|
|
96dc52 |
int clean_stale_multi_triggers(struct autofs_point *, struct mapent *, char *, const char *);
|
|
|
96dc52 |
|
|
|
96dc52 |
#endif
|
|
|
96dc52 |
diff --git a/lib/cache.c b/lib/cache.c
|
|
|
96dc52 |
index 93b02daf..ef761739 100644
|
|
|
96dc52 |
--- a/lib/cache.c
|
|
|
96dc52 |
+++ b/lib/cache.c
|
|
|
96dc52 |
@@ -461,30 +461,6 @@ struct mapent *cache_lookup_distinct(struct mapent_cache *mc, const char *key)
|
|
|
96dc52 |
return NULL;
|
|
|
96dc52 |
}
|
|
|
96dc52 |
|
|
|
96dc52 |
-/* Lookup an offset within a multi-mount entry */
|
|
|
96dc52 |
-struct mapent *cache_lookup_offset(const char *prefix, const char *offset, int start, struct list_head *head)
|
|
|
96dc52 |
-{
|
|
|
96dc52 |
- struct list_head *p;
|
|
|
96dc52 |
- struct mapent *this;
|
|
|
96dc52 |
- /* Keys for direct maps may be as long as a path name */
|
|
|
96dc52 |
- char o_key[PATH_MAX];
|
|
|
96dc52 |
- /* Avoid "//" at the beginning of paths */
|
|
|
96dc52 |
- const char *path_prefix = strlen(prefix) > 1 ? prefix : "";
|
|
|
96dc52 |
- size_t size;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- /* root offset duplicates "/" */
|
|
|
96dc52 |
- size = snprintf(o_key, sizeof(o_key), "%s%s", path_prefix, offset);
|
|
|
96dc52 |
- if (size >= sizeof(o_key))
|
|
|
96dc52 |
- return NULL;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- list_for_each(p, head) {
|
|
|
96dc52 |
- this = list_entry(p, struct mapent, multi_list);
|
|
|
96dc52 |
- if (!strcmp(&this->key[start], o_key))
|
|
|
96dc52 |
- return this;
|
|
|
96dc52 |
- }
|
|
|
96dc52 |
- return NULL;
|
|
|
96dc52 |
-}
|
|
|
96dc52 |
-
|
|
|
96dc52 |
/* cache must be read locked by caller */
|
|
|
96dc52 |
static struct mapent *__cache_partial_match(struct mapent_cache *mc,
|
|
|
96dc52 |
const char *prefix,
|
|
|
96dc52 |
@@ -583,9 +559,6 @@ int cache_add(struct mapent_cache *mc, struct map_source *ms, const char *key, c
|
|
|
96dc52 |
me->mm_parent = NULL;
|
|
|
96dc52 |
INIT_TREE_NODE(&me->node);
|
|
|
96dc52 |
INIT_LIST_HEAD(&me->ino_index);
|
|
|
96dc52 |
- INIT_LIST_HEAD(&me->multi_list);
|
|
|
96dc52 |
- me->multi = NULL;
|
|
|
96dc52 |
- me->parent = NULL;
|
|
|
96dc52 |
me->ioctlfd = -1;
|
|
|
96dc52 |
me->dev = (dev_t) -1;
|
|
|
96dc52 |
me->ino = (ino_t) -1;
|
|
|
96dc52 |
@@ -615,33 +588,6 @@ int cache_add(struct mapent_cache *mc, struct map_source *ms, const char *key, c
|
|
|
96dc52 |
return CHE_OK;
|
|
|
96dc52 |
}
|
|
|
96dc52 |
|
|
|
96dc52 |
-/* cache must be write locked by caller */
|
|
|
96dc52 |
-static void cache_add_ordered_offset(struct mapent *me, struct list_head *head)
|
|
|
96dc52 |
-{
|
|
|
96dc52 |
- struct list_head *p;
|
|
|
96dc52 |
- struct mapent *this;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- list_for_each(p, head) {
|
|
|
96dc52 |
- size_t tlen;
|
|
|
96dc52 |
- int eq;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- this = list_entry(p, struct mapent, multi_list);
|
|
|
96dc52 |
- tlen = strlen(this->key);
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- eq = strncmp(this->key, me->key, tlen);
|
|
|
96dc52 |
- if (!eq && tlen == strlen(me->key))
|
|
|
96dc52 |
- return;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- if (eq > 0) {
|
|
|
96dc52 |
- list_add_tail(&me->multi_list, p);
|
|
|
96dc52 |
- return;
|
|
|
96dc52 |
- }
|
|
|
96dc52 |
- }
|
|
|
96dc52 |
- list_add_tail(&me->multi_list, p);
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- return;
|
|
|
96dc52 |
-}
|
|
|
96dc52 |
-
|
|
|
96dc52 |
/* cache must be write locked by caller */
|
|
|
96dc52 |
int cache_update_offset(struct mapent_cache *mc, const char *mkey, const char *key, const char *mapent, time_t age)
|
|
|
96dc52 |
{
|
|
|
96dc52 |
@@ -777,25 +723,6 @@ struct mapent *cache_get_offset_parent(struct mapent_cache *mc, const char *key)
|
|
|
96dc52 |
return NULL;
|
|
|
96dc52 |
}
|
|
|
96dc52 |
|
|
|
96dc52 |
-int cache_set_offset_parent(struct mapent_cache *mc, const char *offset)
|
|
|
96dc52 |
-{
|
|
|
96dc52 |
- struct mapent *this, *parent;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- this = cache_lookup_distinct(mc, offset);
|
|
|
96dc52 |
- if (!this)
|
|
|
96dc52 |
- return 0;
|
|
|
96dc52 |
- if (!IS_MM(this))
|
|
|
96dc52 |
- return 0;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- parent = cache_get_offset_parent(mc, offset);
|
|
|
96dc52 |
- if (parent)
|
|
|
96dc52 |
- this->parent = parent;
|
|
|
96dc52 |
- else
|
|
|
96dc52 |
- this->parent = MM_ROOT(this);
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- return 1;
|
|
|
96dc52 |
-}
|
|
|
96dc52 |
-
|
|
|
96dc52 |
/* cache must be write locked by caller */
|
|
|
96dc52 |
int cache_update(struct mapent_cache *mc, struct map_source *ms, const char *key, const char *mapent, time_t age)
|
|
|
96dc52 |
{
|
|
|
96dc52 |
@@ -837,50 +764,6 @@ int cache_update(struct mapent_cache *mc, struct map_source *ms, const char *key
|
|
|
96dc52 |
return ret;
|
|
|
96dc52 |
}
|
|
|
96dc52 |
|
|
|
96dc52 |
-/* cache write lock of the multi mount owner must be held by caller */
|
|
|
96dc52 |
-int cache_delete_offset(struct mapent_cache *mc, const char *key)
|
|
|
96dc52 |
-{
|
|
|
96dc52 |
- u_int32_t hashval = hash(key, mc->size);
|
|
|
96dc52 |
- struct mapent *me = NULL, *pred;
|
|
|
96dc52 |
- int status;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- me = mc->hash[hashval];
|
|
|
96dc52 |
- if (!me)
|
|
|
96dc52 |
- return CHE_FAIL;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- if (strcmp(key, me->key) == 0) {
|
|
|
96dc52 |
- if (IS_MM(me) && IS_MM_ROOT(me))
|
|
|
96dc52 |
- return CHE_FAIL;
|
|
|
96dc52 |
- mc->hash[hashval] = me->next;
|
|
|
96dc52 |
- goto delete;
|
|
|
96dc52 |
- }
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- while (me->next != NULL) {
|
|
|
96dc52 |
- pred = me;
|
|
|
96dc52 |
- me = me->next;
|
|
|
96dc52 |
- if (strcmp(key, me->key) == 0) {
|
|
|
96dc52 |
- if (IS_MM(me) && IS_MM_ROOT(me))
|
|
|
96dc52 |
- return CHE_FAIL;
|
|
|
96dc52 |
- pred->next = me->next;
|
|
|
96dc52 |
- goto delete;
|
|
|
96dc52 |
- }
|
|
|
96dc52 |
- }
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- return CHE_FAIL;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
-delete:
|
|
|
96dc52 |
- list_del(&me->multi_list);
|
|
|
96dc52 |
- ino_index_lock(mc);
|
|
|
96dc52 |
- list_del(&me->ino_index);
|
|
|
96dc52 |
- ino_index_unlock(mc);
|
|
|
96dc52 |
- free(me->key);
|
|
|
96dc52 |
- if (me->mapent)
|
|
|
96dc52 |
- free(me->mapent);
|
|
|
96dc52 |
- free(me);
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- return CHE_OK;
|
|
|
96dc52 |
-}
|
|
|
96dc52 |
-
|
|
|
96dc52 |
/* cache must be write locked by caller */
|
|
|
96dc52 |
int cache_delete(struct mapent_cache *mc, const char *key)
|
|
|
96dc52 |
{
|
|
|
96dc52 |
@@ -1054,113 +937,3 @@ struct mapent *cache_enumerate(struct mapent_cache *mc, struct mapent *me)
|
|
|
96dc52 |
|
|
|
96dc52 |
return cache_lookup_next(mc, me);
|
|
|
96dc52 |
}
|
|
|
96dc52 |
-
|
|
|
96dc52 |
-/*
|
|
|
96dc52 |
- * Get each offset from list head under prefix.
|
|
|
96dc52 |
- * Maintain traversal current position in pos for subsequent calls.
|
|
|
96dc52 |
- * Return each offset into offset.
|
|
|
96dc52 |
- */
|
|
|
96dc52 |
-/* cache must be read locked by caller */
|
|
|
96dc52 |
-char *cache_get_offset(const char *prefix, char *offset, int start,
|
|
|
96dc52 |
- struct list_head *head, struct list_head **pos)
|
|
|
96dc52 |
-{
|
|
|
96dc52 |
- struct list_head *next;
|
|
|
96dc52 |
- struct mapent *this;
|
|
|
96dc52 |
- size_t plen = strlen(prefix);
|
|
|
96dc52 |
- size_t len = 0;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- if (*pos == head)
|
|
|
96dc52 |
- return NULL;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- /* Find an offset */
|
|
|
96dc52 |
- *offset = '\0';
|
|
|
96dc52 |
- next = *pos ? (*pos)->next : head->next;
|
|
|
96dc52 |
- while (next != head) {
|
|
|
96dc52 |
- char *offset_start, *pstart, *pend;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- this = list_entry(next, struct mapent, multi_list);
|
|
|
96dc52 |
- *pos = next;
|
|
|
96dc52 |
- next = next->next;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- offset_start = &this->key[start];
|
|
|
96dc52 |
- if (strlen(offset_start) <= plen)
|
|
|
96dc52 |
- continue;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- if (!strncmp(prefix, offset_start, plen)) {
|
|
|
96dc52 |
- struct mapent *np = NULL;
|
|
|
96dc52 |
- char pe[PATH_MAX + 1];
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- /* "/" doesn't count for root offset */
|
|
|
96dc52 |
- if (plen == 1)
|
|
|
96dc52 |
- pstart = &offset_start[plen - 1];
|
|
|
96dc52 |
- else
|
|
|
96dc52 |
- pstart = &offset_start[plen];
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- /* not part of this sub-tree */
|
|
|
96dc52 |
- if (*pstart != '/')
|
|
|
96dc52 |
- continue;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- /* get next offset */
|
|
|
96dc52 |
- pend = pstart;
|
|
|
96dc52 |
- while (*pend++) {
|
|
|
96dc52 |
- size_t nest_pt_offset;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- if (*pend != '/')
|
|
|
96dc52 |
- continue;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- nest_pt_offset = start + pend - pstart;
|
|
|
96dc52 |
- if (plen > 1)
|
|
|
96dc52 |
- nest_pt_offset += plen;
|
|
|
96dc52 |
- strcpy(pe, this->key);
|
|
|
96dc52 |
- pe[nest_pt_offset] = '\0';
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- np = cache_lookup_distinct(this->mc, pe);
|
|
|
96dc52 |
- if (np)
|
|
|
96dc52 |
- break;
|
|
|
96dc52 |
- }
|
|
|
96dc52 |
- if (np)
|
|
|
96dc52 |
- continue;
|
|
|
96dc52 |
- len = pend - pstart - 1;
|
|
|
96dc52 |
- strncpy(offset, pstart, len);
|
|
|
96dc52 |
- offset[len] ='\0';
|
|
|
96dc52 |
- break;
|
|
|
96dc52 |
- }
|
|
|
96dc52 |
- }
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- /* Seek to next offset */
|
|
|
96dc52 |
- while (next != head) {
|
|
|
96dc52 |
- char *offset_start, *pstart;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- this = list_entry(next, struct mapent, multi_list);
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- offset_start = &this->key[start];
|
|
|
96dc52 |
- if (strlen(offset_start) <= plen + len)
|
|
|
96dc52 |
- break;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- /* "/" doesn't count for root offset */
|
|
|
96dc52 |
- if (plen == 1)
|
|
|
96dc52 |
- pstart = &offset_start[plen - 1];
|
|
|
96dc52 |
- else
|
|
|
96dc52 |
- pstart = &offset_start[plen];
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- /* not part of this sub-tree */
|
|
|
96dc52 |
- if (*pstart != '/')
|
|
|
96dc52 |
- break;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- /* new offset */
|
|
|
96dc52 |
- if (!*(pstart + len + 1))
|
|
|
96dc52 |
- break;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- /* compare offset */
|
|
|
96dc52 |
- if (pstart[len] != '/' ||
|
|
|
96dc52 |
- strlen(pstart) != len ||
|
|
|
96dc52 |
- strncmp(offset, pstart, len))
|
|
|
96dc52 |
- break;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- *pos = next;
|
|
|
96dc52 |
- next = next->next;
|
|
|
96dc52 |
- }
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- return *offset ? offset : NULL;
|
|
|
96dc52 |
-}
|
|
|
96dc52 |
-
|
|
|
96dc52 |
diff --git a/lib/mounts.c b/lib/mounts.c
|
|
|
96dc52 |
index 6ca7eff1..c120d2a8 100644
|
|
|
96dc52 |
--- a/lib/mounts.c
|
|
|
96dc52 |
+++ b/lib/mounts.c
|
|
|
96dc52 |
@@ -2853,21 +2853,6 @@ static void set_offset_tree_catatonic(struct autofs_point *ap, struct mapent *me
|
|
|
96dc52 |
tree_traverse_inorder(MAPENT_ROOT(me), set_offset_tree_catatonic_work, NULL);
|
|
|
96dc52 |
}
|
|
|
96dc52 |
|
|
|
96dc52 |
-static void set_multi_mount_tree_catatonic(struct autofs_point *ap, struct mapent *me)
|
|
|
96dc52 |
-{
|
|
|
96dc52 |
- if (!list_empty(&me->multi_list)) {
|
|
|
96dc52 |
- struct list_head *head = &me->multi_list;
|
|
|
96dc52 |
- struct list_head *p;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- list_for_each(p, head) {
|
|
|
96dc52 |
- struct mapent *this;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- this = list_entry(p, struct mapent, multi_list);
|
|
|
96dc52 |
- set_mount_catatonic(ap, this, this->ioctlfd);
|
|
|
96dc52 |
- }
|
|
|
96dc52 |
- }
|
|
|
96dc52 |
-}
|
|
|
96dc52 |
-
|
|
|
96dc52 |
void set_indirect_mount_tree_catatonic(struct autofs_point *ap)
|
|
|
96dc52 |
{
|
|
|
96dc52 |
struct master_mapent *entry = ap->entry;
|
|
|
96dc52 |
@@ -3034,299 +3019,3 @@ done:
|
|
|
96dc52 |
out:
|
|
|
96dc52 |
return rv;
|
|
|
96dc52 |
}
|
|
|
96dc52 |
-
|
|
|
96dc52 |
-static int do_mount_autofs_offset(struct autofs_point *ap, struct mapent *oe)
|
|
|
96dc52 |
-{
|
|
|
96dc52 |
- int mounted = 0;
|
|
|
96dc52 |
- int ret;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- debug(ap->logopt, "mount offset %s", oe->key);
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- ret = mount_autofs_offset(ap, oe);
|
|
|
96dc52 |
- if (ret >= MOUNT_OFFSET_OK)
|
|
|
96dc52 |
- mounted++;
|
|
|
96dc52 |
- else {
|
|
|
96dc52 |
- if (ret != MOUNT_OFFSET_IGNORE)
|
|
|
96dc52 |
- warn(ap->logopt, "failed to mount offset");
|
|
|
96dc52 |
- else {
|
|
|
96dc52 |
- debug(ap->logopt, "ignoring \"nohide\" trigger %s",
|
|
|
96dc52 |
- oe->key);
|
|
|
96dc52 |
- /*
|
|
|
96dc52 |
- * Ok, so we shouldn't modify the mapent but
|
|
|
96dc52 |
- * mount requests are blocked at a point above
|
|
|
96dc52 |
- * this and expire only uses the mapent key or
|
|
|
96dc52 |
- * holds the cache write lock.
|
|
|
96dc52 |
- */
|
|
|
96dc52 |
- free(oe->mapent);
|
|
|
96dc52 |
- oe->mapent = NULL;
|
|
|
96dc52 |
- }
|
|
|
96dc52 |
- }
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- return mounted;
|
|
|
96dc52 |
-}
|
|
|
96dc52 |
-
|
|
|
96dc52 |
-static int rmdir_path_offset(struct autofs_point *ap, struct mapent *oe)
|
|
|
96dc52 |
-{
|
|
|
96dc52 |
- char *dir, *path;
|
|
|
96dc52 |
- unsigned int split;
|
|
|
96dc52 |
- int ret;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- if (ap->type == LKP_DIRECT)
|
|
|
96dc52 |
- return rmdir_path(ap, oe->key, MM_ROOT(oe)->dev);
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- dir = strdup(oe->key);
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- if (ap->flags & MOUNT_FLAG_GHOST)
|
|
|
96dc52 |
- split = ap->len + strlen(MM_ROOT(oe)->key) + 1;
|
|
|
96dc52 |
- else
|
|
|
96dc52 |
- split = ap->len;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- dir[split] = '\0';
|
|
|
96dc52 |
- path = &dir[split + 1];
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- if (chdir(dir) == -1) {
|
|
|
96dc52 |
- error(ap->logopt, "failed to chdir to %s", dir);
|
|
|
96dc52 |
- free(dir);
|
|
|
96dc52 |
- return -1;
|
|
|
96dc52 |
- }
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- ret = rmdir_path(ap, path, ap->dev);
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- free(dir);
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- if (chdir("/") == -1)
|
|
|
96dc52 |
- error(ap->logopt, "failed to chdir to /");
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- return ret;
|
|
|
96dc52 |
-}
|
|
|
96dc52 |
-
|
|
|
96dc52 |
-static int do_umount_offset(struct autofs_point *ap,
|
|
|
96dc52 |
- struct mapent *oe, const char *root, int start);
|
|
|
96dc52 |
-
|
|
|
96dc52 |
-static int do_umount_multi_triggers(struct autofs_point *ap,
|
|
|
96dc52 |
- struct mapent *me, const char *root,
|
|
|
96dc52 |
- int start, const char *base)
|
|
|
96dc52 |
-{
|
|
|
96dc52 |
- char path[PATH_MAX + 1];
|
|
|
96dc52 |
- char *offset;
|
|
|
96dc52 |
- struct mapent *oe;
|
|
|
96dc52 |
- struct list_head *mm_root, *pos;
|
|
|
96dc52 |
- const char o_root[] = "/";
|
|
|
96dc52 |
- const char *mm_base;
|
|
|
96dc52 |
- int left;
|
|
|
96dc52 |
- unsigned int root_len;
|
|
|
96dc52 |
- unsigned int mm_base_len;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- left = 0;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- mm_root = &me->multi->multi_list;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- if (!base)
|
|
|
96dc52 |
- mm_base = o_root;
|
|
|
96dc52 |
- else
|
|
|
96dc52 |
- mm_base = base;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- pos = NULL;
|
|
|
96dc52 |
- offset = path;
|
|
|
96dc52 |
- root_len = start;
|
|
|
96dc52 |
- mm_base_len = strlen(mm_base);
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- while ((offset = cache_get_offset(mm_base, offset, start, mm_root, &pos))) {
|
|
|
96dc52 |
- char key[PATH_MAX + 1];
|
|
|
96dc52 |
- int key_len = root_len + strlen(offset);
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- if (mm_base_len > 1)
|
|
|
96dc52 |
- key_len += mm_base_len;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- if (key_len > PATH_MAX) {
|
|
|
96dc52 |
- warn(ap->logopt, "path loo long");
|
|
|
96dc52 |
- continue;
|
|
|
96dc52 |
- }
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- strcpy(key, root);
|
|
|
96dc52 |
- if (mm_base_len > 1)
|
|
|
96dc52 |
- strcat(key, mm_base);
|
|
|
96dc52 |
- strcat(key, offset);
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- oe = cache_lookup_distinct(me->mc, key);
|
|
|
96dc52 |
- /* root offset is a special case */
|
|
|
96dc52 |
- if (!oe || (strlen(oe->key) - start) == 1)
|
|
|
96dc52 |
- continue;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- left += do_umount_offset(ap, oe, root, start);
|
|
|
96dc52 |
- }
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- return left;
|
|
|
96dc52 |
-}
|
|
|
96dc52 |
-
|
|
|
96dc52 |
-static int do_umount_offset(struct autofs_point *ap,
|
|
|
96dc52 |
- struct mapent *oe, const char *root, int start)
|
|
|
96dc52 |
-{
|
|
|
96dc52 |
- char *oe_base;
|
|
|
96dc52 |
- int left = 0;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- /*
|
|
|
96dc52 |
- * Check for and umount subtree offsets resulting from
|
|
|
96dc52 |
- * nonstrict mount fail.
|
|
|
96dc52 |
- */
|
|
|
96dc52 |
- oe_base = oe->key + start;
|
|
|
96dc52 |
- left += do_umount_multi_triggers(ap, oe, root, start, oe_base);
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- /*
|
|
|
96dc52 |
- * If an offset that has an active mount has been removed
|
|
|
96dc52 |
- * from the multi-mount we don't want to attempt to trigger
|
|
|
96dc52 |
- * mounts for it. Obviously this is because it has been
|
|
|
96dc52 |
- * removed, but less obvious is the potential strange
|
|
|
96dc52 |
- * behaviour that can result if we do try and mount it
|
|
|
96dc52 |
- * again after it's been expired. For example, if an NFS
|
|
|
96dc52 |
- * file system is no longer exported and is later umounted
|
|
|
96dc52 |
- * it can be mounted again without any error message but
|
|
|
96dc52 |
- * shows as an empty directory. That's going to confuse
|
|
|
96dc52 |
- * people for sure.
|
|
|
96dc52 |
- *
|
|
|
96dc52 |
- * If the mount cannot be umounted (the process is now
|
|
|
96dc52 |
- * using a stale mount) the offset needs to be invalidated
|
|
|
96dc52 |
- * so no further mounts will be attempted but the offset
|
|
|
96dc52 |
- * cache entry must remain so expires can continue to
|
|
|
96dc52 |
- * attempt to umount it. If the mount can be umounted and
|
|
|
96dc52 |
- * the offset is removed, at least for NFS we will get
|
|
|
96dc52 |
- * ESTALE errors when attempting list the directory.
|
|
|
96dc52 |
- */
|
|
|
96dc52 |
- if (oe->ioctlfd != -1 ||
|
|
|
96dc52 |
- is_mounted(oe->key, MNTS_REAL)) {
|
|
|
96dc52 |
- if (umount_ent(ap, oe->key) &&
|
|
|
96dc52 |
- is_mounted(oe->key, MNTS_REAL)) {
|
|
|
96dc52 |
- debug(ap->logopt,
|
|
|
96dc52 |
- "offset %s has active mount, invalidate",
|
|
|
96dc52 |
- oe->key);
|
|
|
96dc52 |
- /*
|
|
|
96dc52 |
- * Ok, so we shouldn't modify the mapent but
|
|
|
96dc52 |
- * mount requests are blocked at a point above
|
|
|
96dc52 |
- * this and expire only uses the mapent key or
|
|
|
96dc52 |
- * holds the cache write lock.
|
|
|
96dc52 |
- */
|
|
|
96dc52 |
- if (oe->mapent) {
|
|
|
96dc52 |
- free(oe->mapent);
|
|
|
96dc52 |
- oe->mapent = NULL;
|
|
|
96dc52 |
- }
|
|
|
96dc52 |
- return ++left;
|
|
|
96dc52 |
- }
|
|
|
96dc52 |
- }
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- debug(ap->logopt, "umount offset %s", oe->key);
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- if (umount_autofs_offset(ap, oe)) {
|
|
|
96dc52 |
- warn(ap->logopt, "failed to umount offset");
|
|
|
96dc52 |
- left++;
|
|
|
96dc52 |
- } else {
|
|
|
96dc52 |
- struct stat st;
|
|
|
96dc52 |
- int ret;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- if (!(oe->flags & MOUNT_FLAG_DIR_CREATED))
|
|
|
96dc52 |
- return left;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- /*
|
|
|
96dc52 |
- * An error due to partial directory removal is
|
|
|
96dc52 |
- * ok so only try and remount the offset if the
|
|
|
96dc52 |
- * actual mount point still exists.
|
|
|
96dc52 |
- */
|
|
|
96dc52 |
- ret = rmdir_path_offset(ap, oe);
|
|
|
96dc52 |
- if (ret == -1 && !stat(oe->key, &st)) {
|
|
|
96dc52 |
- ret = do_mount_autofs_offset(ap, oe);
|
|
|
96dc52 |
- if (ret)
|
|
|
96dc52 |
- left++;
|
|
|
96dc52 |
- /* But we did origianlly create this */
|
|
|
96dc52 |
- oe->flags |= MOUNT_FLAG_DIR_CREATED;
|
|
|
96dc52 |
- }
|
|
|
96dc52 |
- }
|
|
|
96dc52 |
- return left;
|
|
|
96dc52 |
-}
|
|
|
96dc52 |
-
|
|
|
96dc52 |
-int mount_multi_triggers(struct autofs_point *ap, struct mapent *me,
|
|
|
96dc52 |
- const char *root, unsigned int start, const char *base)
|
|
|
96dc52 |
-{
|
|
|
96dc52 |
- char path[PATH_MAX + 1];
|
|
|
96dc52 |
- char *offset = path;
|
|
|
96dc52 |
- struct mapent *oe;
|
|
|
96dc52 |
- struct list_head *pos = NULL;
|
|
|
96dc52 |
- unsigned int root_len = strlen(root);
|
|
|
96dc52 |
- int mounted;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- mounted = 0;
|
|
|
96dc52 |
- offset = cache_get_offset(base, offset, start, &me->multi_list, &pos;;
|
|
|
96dc52 |
- while (offset) {
|
|
|
96dc52 |
- char key[PATH_MAX + 1];
|
|
|
96dc52 |
- int key_len = root_len + strlen(offset);
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- if (key_len > PATH_MAX) {
|
|
|
96dc52 |
- warn(ap->logopt, "path loo long");
|
|
|
96dc52 |
- goto cont;
|
|
|
96dc52 |
- }
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- /* The root offset is always mounted seperately so the
|
|
|
96dc52 |
- * offset path will always be root + offset.
|
|
|
96dc52 |
- */
|
|
|
96dc52 |
- strcpy(key, root);
|
|
|
96dc52 |
- strcat(key, offset);
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- oe = cache_lookup_distinct(me->mc, key);
|
|
|
96dc52 |
- if (!oe || !oe->mapent)
|
|
|
96dc52 |
- goto cont;
|
|
|
96dc52 |
- if (oe->age != MM_ROOT(me)->age) {
|
|
|
96dc52 |
- /* Best effort */
|
|
|
96dc52 |
- do_umount_offset(ap, oe, root, start);
|
|
|
96dc52 |
- goto cont;
|
|
|
96dc52 |
- }
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- mounted += do_mount_autofs_offset(ap, oe);
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- /*
|
|
|
96dc52 |
- * If re-constructing a multi-mount it's necessary to walk
|
|
|
96dc52 |
- * into nested mounts, unlike the usual "mount only what's
|
|
|
96dc52 |
- * needed as you go" behavior.
|
|
|
96dc52 |
- */
|
|
|
96dc52 |
- if (ap->state == ST_READMAP && ap->flags & MOUNT_FLAG_REMOUNT) {
|
|
|
96dc52 |
- if (oe->ioctlfd != -1 ||
|
|
|
96dc52 |
- is_mounted(oe->key, MNTS_REAL))
|
|
|
96dc52 |
- mount_multi_triggers(ap, oe, key, key_len, base);
|
|
|
96dc52 |
- }
|
|
|
96dc52 |
-cont:
|
|
|
96dc52 |
- offset = cache_get_offset(base,
|
|
|
96dc52 |
- offset, start, &me->multi_list, &pos;;
|
|
|
96dc52 |
- }
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- return mounted;
|
|
|
96dc52 |
-}
|
|
|
96dc52 |
-
|
|
|
96dc52 |
-int umount_multi_triggers(struct autofs_point *ap, struct mapent *me, char *root, const char *base)
|
|
|
96dc52 |
-{
|
|
|
96dc52 |
- int left, start;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- start = strlen(root);
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- left = do_umount_multi_triggers(ap, me, root, start, base);
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- if (!left && IS_MM_ROOT(me)) {
|
|
|
96dc52 |
- /*
|
|
|
96dc52 |
- * Special case.
|
|
|
96dc52 |
- * If we can't umount the root container then we can't
|
|
|
96dc52 |
- * delete the offsets from the cache and we need to put
|
|
|
96dc52 |
- * the offset triggers back.
|
|
|
96dc52 |
- */
|
|
|
96dc52 |
- if (is_mounted(root, MNTS_REAL)) {
|
|
|
96dc52 |
- info(ap->logopt, "unmounting dir = %s", root);
|
|
|
96dc52 |
- if (umount_ent(ap, root) &&
|
|
|
96dc52 |
- is_mounted(root, MNTS_REAL)) {
|
|
|
96dc52 |
- if (mount_multi_triggers(ap, me, root, start, "/") < 0)
|
|
|
96dc52 |
- warn(ap->logopt,
|
|
|
96dc52 |
- "failed to remount offset triggers");
|
|
|
96dc52 |
- return ++left;
|
|
|
96dc52 |
- }
|
|
|
96dc52 |
- }
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- /* check for mounted mount entry and remove it if found */
|
|
|
96dc52 |
- mnts_remove_mount(root, MNTS_MOUNTED);
|
|
|
96dc52 |
- }
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- return left;
|
|
|
96dc52 |
-}
|
|
|
96dc52 |
diff --git a/modules/parse_sun.c b/modules/parse_sun.c
|
|
|
96dc52 |
index d6ef48b8..ef74eda9 100644
|
|
|
96dc52 |
--- a/modules/parse_sun.c
|
|
|
96dc52 |
+++ b/modules/parse_sun.c
|
|
|
96dc52 |
@@ -1074,62 +1074,6 @@ next:
|
|
|
96dc52 |
return (p - ent);
|
|
|
96dc52 |
}
|
|
|
96dc52 |
|
|
|
96dc52 |
-static void cleanup_multi_triggers(struct autofs_point *ap,
|
|
|
96dc52 |
- struct mapent *me, const char *root, int start,
|
|
|
96dc52 |
- const char *base)
|
|
|
96dc52 |
-{
|
|
|
96dc52 |
- char path[PATH_MAX + 1];
|
|
|
96dc52 |
- char offset[PATH_MAX + 1];
|
|
|
96dc52 |
- char *poffset = offset;
|
|
|
96dc52 |
- struct mapent *oe;
|
|
|
96dc52 |
- struct list_head *mm_root, *pos;
|
|
|
96dc52 |
- const char o_root[] = "/";
|
|
|
96dc52 |
- const char *mm_base;
|
|
|
96dc52 |
- unsigned int root_len;
|
|
|
96dc52 |
- unsigned int mm_base_len;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- mm_root = &me->multi->multi_list;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- if (!base)
|
|
|
96dc52 |
- mm_base = o_root;
|
|
|
96dc52 |
- else
|
|
|
96dc52 |
- mm_base = base;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- pos = NULL;
|
|
|
96dc52 |
- root_len = strlen(root);
|
|
|
96dc52 |
- mm_base_len = strlen(mm_base);
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- /* Make sure "none" of the offsets have an active mount. */
|
|
|
96dc52 |
- while ((poffset = cache_get_offset(mm_base, poffset, start, mm_root, &pos))) {
|
|
|
96dc52 |
- unsigned int path_len = root_len + strlen(poffset);
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- if (mm_base_len > 1)
|
|
|
96dc52 |
- path_len += mm_base_len;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- if (path_len > PATH_MAX) {
|
|
|
96dc52 |
- warn(ap->logopt, "path loo long");
|
|
|
96dc52 |
- continue;
|
|
|
96dc52 |
- }
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- strcpy(path, root);
|
|
|
96dc52 |
- if (mm_base_len > 1)
|
|
|
96dc52 |
- strcat(path, mm_base);
|
|
|
96dc52 |
- strcat(path, poffset);
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- oe = cache_lookup_distinct(me->mc, path);
|
|
|
96dc52 |
- /* root offset is a special case */
|
|
|
96dc52 |
- if (!oe || !oe->mapent || (strlen(oe->key) - start) == 1)
|
|
|
96dc52 |
- continue;
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- if (umount(path)) {
|
|
|
96dc52 |
- error(ap->logopt, "error recovering from mount fail");
|
|
|
96dc52 |
- error(ap->logopt, "cannot umount offset %s", path);
|
|
|
96dc52 |
- }
|
|
|
96dc52 |
- }
|
|
|
96dc52 |
-
|
|
|
96dc52 |
- return;
|
|
|
96dc52 |
-}
|
|
|
96dc52 |
-
|
|
|
96dc52 |
static int mount_subtree(struct autofs_point *ap, struct mapent_cache *mc,
|
|
|
96dc52 |
const char *name, char *loc, char *options, void *ctxt)
|
|
|
96dc52 |
{
|