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