|
|
9a499a |
autofs-5.1.7 - add tree_mapent_delete_offsets()
|
|
|
9a499a |
|
|
|
9a499a |
From: Ian Kent <raven@themaw.net>
|
|
|
9a499a |
|
|
|
9a499a |
Add function tree_mapent_delete_offsets() to the mapent tree handling
|
|
|
9a499a |
implementation.
|
|
|
9a499a |
|
|
|
9a499a |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
9a499a |
---
|
|
|
9a499a |
CHANGELOG | 1
|
|
|
9a499a |
include/mounts.h | 1
|
|
|
9a499a |
lib/mounts.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
9a499a |
3 files changed, 72 insertions(+)
|
|
|
9a499a |
|
|
|
9a499a |
--- autofs-5.1.4.orig/CHANGELOG
|
|
|
9a499a |
+++ autofs-5.1.4/CHANGELOG
|
|
|
9a499a |
@@ -34,6 +34,7 @@
|
|
|
9a499a |
- make tree implementation data independent.
|
|
|
9a499a |
- add mapent tree implementation.
|
|
|
9a499a |
- add tree_mapent_add_node().
|
|
|
9a499a |
+- add tree_mapent_delete_offsets().
|
|
|
9a499a |
|
|
|
9a499a |
xx/xx/2018 autofs-5.1.5
|
|
|
9a499a |
- fix flag file permission.
|
|
|
9a499a |
--- autofs-5.1.4.orig/include/mounts.h
|
|
|
9a499a |
+++ autofs-5.1.4/include/mounts.h
|
|
|
9a499a |
@@ -170,6 +170,7 @@ void mnts_put_expire_list(struct list_he
|
|
|
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 tree_mapent_delete_offsets(struct mapent_cache *mc, 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/mounts.c
|
|
|
9a499a |
+++ autofs-5.1.4/lib/mounts.c
|
|
|
9a499a |
@@ -1528,6 +1528,76 @@ int tree_mapent_add_node(struct mapent_c
|
|
|
9a499a |
return 1;
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
+static int tree_mapent_delete_offset_tree(struct tree_node *root)
|
|
|
9a499a |
+{
|
|
|
9a499a |
+ struct mapent *me = MAPENT(root);
|
|
|
9a499a |
+ unsigned int logopt = me->mc->ap->logopt;
|
|
|
9a499a |
+ int ret = CHE_OK;
|
|
|
9a499a |
+
|
|
|
9a499a |
+ if (root->left) {
|
|
|
9a499a |
+ ret = tree_mapent_delete_offset_tree(root->left);
|
|
|
9a499a |
+ if (!ret)
|
|
|
9a499a |
+ return 0;
|
|
|
9a499a |
+ root->left = NULL;
|
|
|
9a499a |
+ }
|
|
|
9a499a |
+ if (root->right) {
|
|
|
9a499a |
+ ret = tree_mapent_delete_offset_tree(root->right);
|
|
|
9a499a |
+ if (!ret)
|
|
|
9a499a |
+ return 0;
|
|
|
9a499a |
+ root->right = NULL;
|
|
|
9a499a |
+ }
|
|
|
9a499a |
+
|
|
|
9a499a |
+ /* Keep the owner of the multi-mount offset tree and clear
|
|
|
9a499a |
+ * the root and parent when done.
|
|
|
9a499a |
+ */
|
|
|
9a499a |
+ if (MAPENT_ROOT(me) != MAPENT_NODE(me)) {
|
|
|
9a499a |
+ struct tree_node *root = MAPENT_ROOT(me);
|
|
|
9a499a |
+
|
|
|
9a499a |
+ debug(logopt, "deleting offset key %s", me->key);
|
|
|
9a499a |
+
|
|
|
9a499a |
+ /* cache_delete won't delete an active offset */
|
|
|
9a499a |
+ MAPENT_SET_ROOT(me, NULL);
|
|
|
9a499a |
+ ret = cache_delete(me->mc, me->key);
|
|
|
9a499a |
+ if (ret != CHE_OK) {
|
|
|
9a499a |
+ MAPENT_SET_ROOT(me, root);
|
|
|
9a499a |
+ warn(logopt, "failed to delete offset %s", me->key);
|
|
|
9a499a |
+ }
|
|
|
9a499a |
+ } else {
|
|
|
9a499a |
+ MAPENT_SET_ROOT(me, NULL);
|
|
|
9a499a |
+ MAPENT_SET_PARENT(me, NULL);
|
|
|
9a499a |
+ }
|
|
|
9a499a |
+
|
|
|
9a499a |
+ return ret == CHE_OK ? 1 : 0;
|
|
|
9a499a |
+}
|
|
|
9a499a |
+
|
|
|
9a499a |
+int tree_mapent_delete_offsets(struct mapent_cache *mc, const char *key)
|
|
|
9a499a |
+{
|
|
|
9a499a |
+ unsigned int logopt = mc->ap->logopt;
|
|
|
9a499a |
+ struct mapent *me;
|
|
|
9a499a |
+
|
|
|
9a499a |
+ me = cache_lookup_distinct(mc, key);
|
|
|
9a499a |
+ if (!me) {
|
|
|
9a499a |
+ error(logopt,
|
|
|
9a499a |
+ "failed to find multi-mount root for key %s", key);
|
|
|
9a499a |
+ return 0;
|
|
|
9a499a |
+ }
|
|
|
9a499a |
+
|
|
|
9a499a |
+ /* Not offset list owner */
|
|
|
9a499a |
+ if (MAPENT_ROOT(me) != MAPENT_NODE(me)) {
|
|
|
9a499a |
+ error(logopt,
|
|
|
9a499a |
+ "mapent for key %s is not multi-mount owner", key);
|
|
|
9a499a |
+ return 0;
|
|
|
9a499a |
+ }
|
|
|
9a499a |
+
|
|
|
9a499a |
+ if (!tree_mapent_delete_offset_tree(MAPENT_ROOT(me))) {
|
|
|
9a499a |
+ error(logopt,
|
|
|
9a499a |
+ "could not delete map entry offsets for key %s", key);
|
|
|
9a499a |
+ return 0;
|
|
|
9a499a |
+ }
|
|
|
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
|