|
|
9a499a |
autofs-5.1.7 - add tree_mapent_traverse_subtree()
|
|
|
9a499a |
|
|
|
9a499a |
From: Ian Kent <raven@themaw.net>
|
|
|
9a499a |
|
|
|
9a499a |
Add function tree_mapent_traverse_subtree() that enumerates offsets from
|
|
|
9a499a |
a given base node bounded by subtree nesting points.
|
|
|
9a499a |
|
|
|
9a499a |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
9a499a |
---
|
|
|
9a499a |
CHANGELOG | 1 +
|
|
|
9a499a |
lib/mounts.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
9a499a |
2 files changed, 48 insertions(+)
|
|
|
9a499a |
|
|
|
9a499a |
--- autofs-5.1.4.orig/CHANGELOG
|
|
|
9a499a |
+++ autofs-5.1.4/CHANGELOG
|
|
|
9a499a |
@@ -35,6 +35,7 @@
|
|
|
9a499a |
- add mapent tree implementation.
|
|
|
9a499a |
- add tree_mapent_add_node().
|
|
|
9a499a |
- add tree_mapent_delete_offsets().
|
|
|
9a499a |
+- add tree_mapent_traverse_subtree().
|
|
|
9a499a |
|
|
|
9a499a |
xx/xx/2018 autofs-5.1.5
|
|
|
9a499a |
- fix flag file permission.
|
|
|
9a499a |
--- autofs-5.1.4.orig/lib/mounts.c
|
|
|
9a499a |
+++ autofs-5.1.4/lib/mounts.c
|
|
|
9a499a |
@@ -1528,6 +1528,53 @@ int tree_mapent_add_node(struct mapent_c
|
|
|
9a499a |
return 1;
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
+static inline int tree_mapent_is_root(struct mapent *oe)
|
|
|
9a499a |
+{
|
|
|
9a499a |
+ /* Offset "/" is a special case, it's looked up and mounted
|
|
|
9a499a |
+ * seperately because the offset tree may or may not have a
|
|
|
9a499a |
+ * real mount at the base and the triggers inside it need to
|
|
|
9a499a |
+ * be mounted in either case. Also the order requires the
|
|
|
9a499a |
+ * offset at the top of the (sub)tree to be handled after
|
|
|
9a499a |
+ * the traversal.
|
|
|
9a499a |
+ */
|
|
|
9a499a |
+ return (oe->key[oe->len - 1] == '/' ||
|
|
|
9a499a |
+ MAPENT_ROOT(oe) == MAPENT_NODE(oe));
|
|
|
9a499a |
+}
|
|
|
9a499a |
+
|
|
|
9a499a |
+struct traverse_subtree_context {
|
|
|
9a499a |
+ struct autofs_point *ap;
|
|
|
9a499a |
+ struct tree_node *base;
|
|
|
9a499a |
+ int strict;
|
|
|
9a499a |
+};
|
|
|
9a499a |
+
|
|
|
9a499a |
+static int tree_mapent_traverse_subtree(struct tree_node *n, tree_work_fn_t work, void *ptr)
|
|
|
9a499a |
+{
|
|
|
9a499a |
+ struct traverse_subtree_context *ctxt = ptr;
|
|
|
9a499a |
+ struct mapent *oe = MAPENT(n);
|
|
|
9a499a |
+ int ret = 1;
|
|
|
9a499a |
+
|
|
|
9a499a |
+ if (n->left) {
|
|
|
9a499a |
+ ret = tree_mapent_traverse_subtree(n->left, work, ctxt);
|
|
|
9a499a |
+ if (!ret && ctxt->strict)
|
|
|
9a499a |
+ goto done;
|
|
|
9a499a |
+ }
|
|
|
9a499a |
+
|
|
|
9a499a |
+ /* Node is not multi-mount root and is part of current subtree */
|
|
|
9a499a |
+ if (!tree_mapent_is_root(oe) && MAPENT_PARENT(oe) == ctxt->base) {
|
|
|
9a499a |
+ ret = work(n, ctxt);
|
|
|
9a499a |
+ if (!ret && ctxt->strict)
|
|
|
9a499a |
+ goto done;
|
|
|
9a499a |
+ }
|
|
|
9a499a |
+
|
|
|
9a499a |
+ if (n->right) {
|
|
|
9a499a |
+ ret = tree_mapent_traverse_subtree(n->right, work, ctxt);
|
|
|
9a499a |
+ if (!ret && ctxt->strict)
|
|
|
9a499a |
+ goto done;
|
|
|
9a499a |
+ }
|
|
|
9a499a |
+done:
|
|
|
9a499a |
+ return ret;
|
|
|
9a499a |
+}
|
|
|
9a499a |
+
|
|
|
9a499a |
static int tree_mapent_delete_offset_tree(struct tree_node *root)
|
|
|
9a499a |
{
|
|
|
9a499a |
struct mapent *me = MAPENT(root);
|