|
|
49b67f |
autofs-5.1.7 - add tree_mapent_add_node()
|
|
|
49b67f |
|
|
|
49b67f |
From: Ian Kent <raven@themaw.net>
|
|
|
49b67f |
|
|
|
49b67f |
Add function tree_mapent_add_node() to the mapent tree handling
|
|
|
49b67f |
implementation.
|
|
|
49b67f |
|
|
|
49b67f |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
49b67f |
---
|
|
|
49b67f |
CHANGELOG | 1 +
|
|
|
49b67f |
include/automount.h | 1 +
|
|
|
49b67f |
include/mounts.h | 1 +
|
|
|
49b67f |
lib/cache.c | 5 ++---
|
|
|
49b67f |
lib/mounts.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
49b67f |
5 files changed, 52 insertions(+), 3 deletions(-)
|
|
|
49b67f |
|
|
|
49b67f |
--- autofs-5.1.4.orig/CHANGELOG
|
|
|
49b67f |
+++ autofs-5.1.4/CHANGELOG
|
|
|
49b67f |
@@ -33,6 +33,7 @@
|
|
|
49b67f |
- add a len field to struct autofs_point.
|
|
|
49b67f |
- make tree implementation data independent.
|
|
|
49b67f |
- add mapent tree implementation.
|
|
|
49b67f |
+- add tree_mapent_add_node().
|
|
|
49b67f |
|
|
|
49b67f |
xx/xx/2018 autofs-5.1.5
|
|
|
49b67f |
- fix flag file permission.
|
|
|
49b67f |
--- autofs-5.1.4.orig/include/automount.h
|
|
|
49b67f |
+++ autofs-5.1.4/include/automount.h
|
|
|
49b67f |
@@ -215,6 +215,7 @@ struct mapent *cache_partial_match_wild(
|
|
|
49b67f |
int cache_add(struct mapent_cache *mc, struct map_source *ms, const char *key, const char *mapent, time_t age);
|
|
|
49b67f |
int cache_update_offset(struct mapent_cache *mc, const char *mkey, const char *key, const char *mapent, time_t age);
|
|
|
49b67f |
void cache_update_negative(struct mapent_cache *mc, struct map_source *ms, const char *key, time_t timeout);
|
|
|
49b67f |
+struct mapent *cache_get_offset_parent(struct mapent_cache *mc, const char *key);
|
|
|
49b67f |
int cache_set_offset_parent(struct mapent_cache *mc, const char *offset);
|
|
|
49b67f |
int cache_update(struct mapent_cache *mc, struct map_source *ms, const char *key, const char *mapent, time_t age);
|
|
|
49b67f |
int cache_delete(struct mapent_cache *mc, const char *key);
|
|
|
49b67f |
--- autofs-5.1.4.orig/include/mounts.h
|
|
|
49b67f |
+++ autofs-5.1.4/include/mounts.h
|
|
|
49b67f |
@@ -169,6 +169,7 @@ void mnts_get_expire_list(struct list_he
|
|
|
49b67f |
void mnts_put_expire_list(struct list_head *mnts);
|
|
|
49b67f |
void mnts_set_mounted_mount(struct autofs_point *ap, const char *name, unsigned int flags);
|
|
|
49b67f |
struct tree_node *tree_mapent_root(struct mapent *me);
|
|
|
49b67f |
+int tree_mapent_add_node(struct mapent_cache *mc, const char *base, const char *key);
|
|
|
49b67f |
int unlink_mount_tree(struct autofs_point *ap, const char *mp);
|
|
|
49b67f |
void free_mnt_list(struct mnt_list *list);
|
|
|
49b67f |
int is_mounted(const char *mp, unsigned int type);
|
|
|
49b67f |
--- autofs-5.1.4.orig/lib/cache.c
|
|
|
49b67f |
+++ autofs-5.1.4/lib/cache.c
|
|
|
49b67f |
@@ -719,8 +719,7 @@ void cache_update_negative(struct mapent
|
|
|
49b67f |
}
|
|
|
49b67f |
|
|
|
49b67f |
|
|
|
49b67f |
-static struct mapent *get_offset_parent(struct mapent_cache *mc,
|
|
|
49b67f |
- const char *key)
|
|
|
49b67f |
+struct mapent *cache_get_offset_parent(struct mapent_cache *mc, const char *key)
|
|
|
49b67f |
{
|
|
|
49b67f |
struct mapent *me;
|
|
|
49b67f |
char *parent, *tail;
|
|
|
49b67f |
@@ -766,7 +765,7 @@ int cache_set_offset_parent(struct mapen
|
|
|
49b67f |
if (!IS_MM(this))
|
|
|
49b67f |
return 0;
|
|
|
49b67f |
|
|
|
49b67f |
- parent = get_offset_parent(mc, offset);
|
|
|
49b67f |
+ parent = cache_get_offset_parent(mc, offset);
|
|
|
49b67f |
if (parent)
|
|
|
49b67f |
this->parent = parent;
|
|
|
49b67f |
else
|
|
|
49b67f |
--- autofs-5.1.4.orig/lib/mounts.c
|
|
|
49b67f |
+++ autofs-5.1.4/lib/mounts.c
|
|
|
49b67f |
@@ -1481,6 +1481,53 @@ static void tree_mapent_free(struct tree
|
|
|
49b67f |
n->right = NULL;
|
|
|
49b67f |
}
|
|
|
49b67f |
|
|
|
49b67f |
+int tree_mapent_add_node(struct mapent_cache *mc,
|
|
|
49b67f |
+ const char *root, const char *key)
|
|
|
49b67f |
+{
|
|
|
49b67f |
+ unsigned int logopt = mc->ap->logopt;
|
|
|
49b67f |
+ struct tree_node *tree, *n;
|
|
|
49b67f |
+ struct mapent *base;
|
|
|
49b67f |
+ struct mapent *parent;
|
|
|
49b67f |
+ struct mapent *me;
|
|
|
49b67f |
+
|
|
|
49b67f |
+ base = cache_lookup_distinct(mc, root);
|
|
|
49b67f |
+ if (!base) {
|
|
|
49b67f |
+ error(logopt,
|
|
|
49b67f |
+ "failed to find multi-mount root for key %s", key);
|
|
|
49b67f |
+ return 0;
|
|
|
49b67f |
+ }
|
|
|
49b67f |
+
|
|
|
49b67f |
+ if (MAPENT_ROOT(base) != MAPENT_NODE(base)) {
|
|
|
49b67f |
+ error(logopt,
|
|
|
49b67f |
+ "failed to find multi-mount root of offset tree",
|
|
|
49b67f |
+ key);
|
|
|
49b67f |
+ return 0;
|
|
|
49b67f |
+ }
|
|
|
49b67f |
+ tree = MAPENT_ROOT(base);
|
|
|
49b67f |
+
|
|
|
49b67f |
+ me = cache_lookup_distinct(mc, key);
|
|
|
49b67f |
+ if (!me) {
|
|
|
49b67f |
+ error(logopt,
|
|
|
49b67f |
+ "failed to find key %s of multi-mount", key);
|
|
|
49b67f |
+ return 0;
|
|
|
49b67f |
+ }
|
|
|
49b67f |
+
|
|
|
49b67f |
+ n = tree_add_node(tree, me);
|
|
|
49b67f |
+ if (!n)
|
|
|
49b67f |
+ return 0;
|
|
|
49b67f |
+
|
|
|
49b67f |
+ MAPENT_SET_ROOT(me, tree)
|
|
|
49b67f |
+
|
|
|
49b67f |
+ /* Set the subtree parent */
|
|
|
49b67f |
+ parent = cache_get_offset_parent(mc, key);
|
|
|
49b67f |
+ if (!parent)
|
|
|
49b67f |
+ MAPENT_SET_PARENT(me, tree)
|
|
|
49b67f |
+ else
|
|
|
49b67f |
+ MAPENT_SET_PARENT(me, MAPENT_NODE(parent))
|
|
|
49b67f |
+
|
|
|
49b67f |
+ return 1;
|
|
|
49b67f |
+}
|
|
|
49b67f |
+
|
|
|
49b67f |
/* From glibc decode_name() */
|
|
|
49b67f |
/* Since the values in a line are separated by spaces, a name cannot
|
|
|
49b67f |
* contain a space. Therefore some programs encode spaces in names
|