|
|
49b67f |
autofs-5.1.7 - add tree_mapent_cleanup_offsets()
|
|
|
49b67f |
|
|
|
49b67f |
From: Ian Kent <raven@themaw.net>
|
|
|
49b67f |
|
|
|
49b67f |
Add function tree_mapent_cleanup_offsets() to the mapent tree handling
|
|
|
49b67f |
implementation.
|
|
|
49b67f |
|
|
|
49b67f |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
49b67f |
---
|
|
|
49b67f |
CHANGELOG | 1 +
|
|
|
49b67f |
include/mounts.h | 1 +
|
|
|
49b67f |
lib/mounts.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
|
|
|
49b67f |
3 files changed, 47 insertions(+)
|
|
|
49b67f |
|
|
|
49b67f |
--- autofs-5.1.4.orig/CHANGELOG
|
|
|
49b67f |
+++ autofs-5.1.4/CHANGELOG
|
|
|
49b67f |
@@ -37,6 +37,7 @@
|
|
|
49b67f |
- add tree_mapent_delete_offsets().
|
|
|
49b67f |
- add tree_mapent_traverse_subtree().
|
|
|
49b67f |
- fix mount_fullpath().
|
|
|
49b67f |
+- add tree_mapent_cleanup_offsets().
|
|
|
49b67f |
|
|
|
49b67f |
xx/xx/2018 autofs-5.1.5
|
|
|
49b67f |
- fix flag file permission.
|
|
|
49b67f |
--- autofs-5.1.4.orig/include/mounts.h
|
|
|
49b67f |
+++ autofs-5.1.4/include/mounts.h
|
|
|
49b67f |
@@ -171,6 +171,7 @@ void mnts_set_mounted_mount(struct autof
|
|
|
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 tree_mapent_delete_offsets(struct mapent_cache *mc, const char *key);
|
|
|
49b67f |
+void tree_mapent_cleanup_offsets(struct mapent *oe);
|
|
|
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/mounts.c
|
|
|
49b67f |
+++ autofs-5.1.4/lib/mounts.c
|
|
|
49b67f |
@@ -1647,6 +1647,51 @@ int tree_mapent_delete_offsets(struct ma
|
|
|
49b67f |
return 1;
|
|
|
49b67f |
}
|
|
|
49b67f |
|
|
|
49b67f |
+static void tree_mapent_umount_mount(struct autofs_point *ap, const char *mp)
|
|
|
49b67f |
+{
|
|
|
49b67f |
+ if (is_mounted(mp, MNTS_ALL)) {
|
|
|
49b67f |
+ if (umount(mp)) {
|
|
|
49b67f |
+ error(ap->logopt, "error recovering from mount fail");
|
|
|
49b67f |
+ error(ap->logopt, "cannot umount %s", mp);
|
|
|
49b67f |
+ }
|
|
|
49b67f |
+ }
|
|
|
49b67f |
+}
|
|
|
49b67f |
+
|
|
|
49b67f |
+static int tree_mapent_cleanup_offsets_work(struct tree_node *n, void *ptr)
|
|
|
49b67f |
+{
|
|
|
49b67f |
+ struct mapent *oe = MAPENT(n);
|
|
|
49b67f |
+ struct traverse_subtree_context *ctxt = ptr;
|
|
|
49b67f |
+
|
|
|
49b67f |
+ tree_mapent_umount_mount(ctxt->ap, oe->key);
|
|
|
49b67f |
+
|
|
|
49b67f |
+ return 1;
|
|
|
49b67f |
+}
|
|
|
49b67f |
+
|
|
|
49b67f |
+void tree_mapent_cleanup_offsets(struct mapent *oe)
|
|
|
49b67f |
+{
|
|
|
49b67f |
+ struct tree_node *base = MAPENT_NODE(oe);
|
|
|
49b67f |
+ struct traverse_subtree_context ctxt = {
|
|
|
49b67f |
+ .ap = oe->mc->ap,
|
|
|
49b67f |
+ .base = base,
|
|
|
49b67f |
+ .strict = 0,
|
|
|
49b67f |
+ };
|
|
|
49b67f |
+ struct autofs_point *ap = oe->mc->ap;
|
|
|
49b67f |
+
|
|
|
49b67f |
+ tree_mapent_traverse_subtree(base, tree_mapent_cleanup_offsets_work, &ctxt);
|
|
|
49b67f |
+
|
|
|
49b67f |
+ /* Cleanup base mount after offsets have been cleaned up */
|
|
|
49b67f |
+ if (*oe->key == '/')
|
|
|
49b67f |
+ tree_mapent_umount_mount(ap, oe->key);
|
|
|
49b67f |
+ else {
|
|
|
49b67f |
+ char mp[PATH_MAX + 1];
|
|
|
49b67f |
+
|
|
|
49b67f |
+ if (!mount_fullpath(mp, PATH_MAX, ap->path, oe->key))
|
|
|
49b67f |
+ error(ap->logopt, "mount path is too long");
|
|
|
49b67f |
+ else
|
|
|
49b67f |
+ tree_mapent_umount_mount(ap, mp);
|
|
|
49b67f |
+ }
|
|
|
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
|