|
|
1c5f92 |
autofs-5.1.5 - refactor unlink_active_mounts() in direct_c
|
|
|
1c5f92 |
|
|
|
1c5f92 |
From: Ian Kent <raven@themaw.net>
|
|
|
1c5f92 |
|
|
|
1c5f92 |
In daemon/direct.c:unlink_active_mounts() the tree_get_mnt_list() call
|
|
|
1c5f92 |
returns 1 for a non-empty list which amounts to a mounted check and then
|
|
|
1c5f92 |
handles the case where the map is being read.
|
|
|
1c5f92 |
|
|
|
1c5f92 |
But the check that's carried out is to distinguish between a readmap
|
|
|
1c5f92 |
and a mount activity which should be handled by the caller instead of
|
|
|
1c5f92 |
burying the check away in the unlink_active_mounts() function.
|
|
|
1c5f92 |
|
|
|
1c5f92 |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
1c5f92 |
---
|
|
|
1c5f92 |
CHANGELOG | 1
|
|
|
1c5f92 |
daemon/direct.c | 63 +++++++++++++++++++++++++++-----------------------------
|
|
|
1c5f92 |
2 files changed, 32 insertions(+), 32 deletions(-)
|
|
|
1c5f92 |
|
|
|
1c5f92 |
--- autofs-5.1.4.orig/CHANGELOG
|
|
|
1c5f92 |
+++ autofs-5.1.4/CHANGELOG
|
|
|
1c5f92 |
@@ -68,6 +68,7 @@ xx/xx/2018 autofs-5.1.5
|
|
|
1c5f92 |
- always use PROC_MOUNTS to make mount lists.
|
|
|
1c5f92 |
- add glibc getmntent_r().
|
|
|
1c5f92 |
- use local getmntent_r in table_is_mounted().
|
|
|
1c5f92 |
+- refactor unlink_active_mounts() in direct.c.
|
|
|
1c5f92 |
|
|
|
1c5f92 |
19/12/2017 autofs-5.1.4
|
|
|
1c5f92 |
- fix spec file url.
|
|
|
1c5f92 |
--- autofs-5.1.4.orig/daemon/direct.c
|
|
|
1c5f92 |
+++ autofs-5.1.4/daemon/direct.c
|
|
|
1c5f92 |
@@ -298,37 +298,12 @@ static int unlink_mount_tree(struct auto
|
|
|
1c5f92 |
|
|
|
1c5f92 |
static int unlink_active_mounts(struct autofs_point *ap, struct mnt_list *mnts, struct mapent *me)
|
|
|
1c5f92 |
{
|
|
|
1c5f92 |
- struct ioctl_ops *ops = get_ioctl_ops();
|
|
|
1c5f92 |
struct list_head list;
|
|
|
1c5f92 |
|
|
|
1c5f92 |
INIT_LIST_HEAD(&list);
|
|
|
1c5f92 |
|
|
|
1c5f92 |
- if (tree_get_mnt_list(mnts, &list, me->key, 1)) {
|
|
|
1c5f92 |
- if (ap->state == ST_READMAP) {
|
|
|
1c5f92 |
- time_t tout = get_exp_timeout(ap, me->source);
|
|
|
1c5f92 |
- int save_ioctlfd, ioctlfd;
|
|
|
1c5f92 |
-
|
|
|
1c5f92 |
- save_ioctlfd = ioctlfd = me->ioctlfd;
|
|
|
1c5f92 |
-
|
|
|
1c5f92 |
- if (ioctlfd == -1)
|
|
|
1c5f92 |
- ops->open(ap->logopt,
|
|
|
1c5f92 |
- &ioctlfd, me->dev, me->key);
|
|
|
1c5f92 |
-
|
|
|
1c5f92 |
- if (ioctlfd < 0) {
|
|
|
1c5f92 |
- error(ap->logopt,
|
|
|
1c5f92 |
- "failed to create ioctl fd for %s",
|
|
|
1c5f92 |
- me->key);
|
|
|
1c5f92 |
- return 0;
|
|
|
1c5f92 |
- }
|
|
|
1c5f92 |
-
|
|
|
1c5f92 |
- ops->timeout(ap->logopt, ioctlfd, tout);
|
|
|
1c5f92 |
-
|
|
|
1c5f92 |
- if (save_ioctlfd == -1)
|
|
|
1c5f92 |
- ops->close(ap->logopt, ioctlfd);
|
|
|
1c5f92 |
-
|
|
|
1c5f92 |
- return 0;
|
|
|
1c5f92 |
- }
|
|
|
1c5f92 |
- }
|
|
|
1c5f92 |
+ if (!tree_get_mnt_list(mnts, &list, me->key, 1))
|
|
|
1c5f92 |
+ return 1;
|
|
|
1c5f92 |
|
|
|
1c5f92 |
if (!unlink_mount_tree(ap, &list)) {
|
|
|
1c5f92 |
debug(ap->logopt,
|
|
|
1c5f92 |
@@ -371,16 +346,40 @@ int do_mount_autofs_direct(struct autofs
|
|
|
1c5f92 |
if (ret == 0)
|
|
|
1c5f92 |
return -1;
|
|
|
1c5f92 |
} else {
|
|
|
1c5f92 |
+ if (ap->state == ST_READMAP && is_mounted(me->key, MNTS_ALL)) {
|
|
|
1c5f92 |
+ time_t tout = get_exp_timeout(ap, me->source);
|
|
|
1c5f92 |
+ int save_ioctlfd, ioctlfd;
|
|
|
1c5f92 |
+
|
|
|
1c5f92 |
+ save_ioctlfd = ioctlfd = me->ioctlfd;
|
|
|
1c5f92 |
+
|
|
|
1c5f92 |
+ if (ioctlfd == -1)
|
|
|
1c5f92 |
+ ops->open(ap->logopt,
|
|
|
1c5f92 |
+ &ioctlfd, me->dev, me->key);
|
|
|
1c5f92 |
+
|
|
|
1c5f92 |
+ if (ioctlfd < 0) {
|
|
|
1c5f92 |
+ error(ap->logopt,
|
|
|
1c5f92 |
+ "failed to create ioctl fd for %s",
|
|
|
1c5f92 |
+ me->key);
|
|
|
1c5f92 |
+ return 0;
|
|
|
1c5f92 |
+ }
|
|
|
1c5f92 |
+
|
|
|
1c5f92 |
+ ops->timeout(ap->logopt, ioctlfd, tout);
|
|
|
1c5f92 |
+
|
|
|
1c5f92 |
+ if (save_ioctlfd == -1)
|
|
|
1c5f92 |
+ ops->close(ap->logopt, ioctlfd);
|
|
|
1c5f92 |
+
|
|
|
1c5f92 |
+ return 0;
|
|
|
1c5f92 |
+ }
|
|
|
1c5f92 |
+
|
|
|
1c5f92 |
/*
|
|
|
1c5f92 |
- * A return of 0 indicates we're re-reading the map.
|
|
|
1c5f92 |
* A return of 1 indicates we successfully unlinked
|
|
|
1c5f92 |
- * the mount tree if there was one. A return of -1
|
|
|
1c5f92 |
- * inducates we failed to unlink the mount tree so
|
|
|
1c5f92 |
+ * the mount tree if there was one. A return of 0
|
|
|
1c5f92 |
+ * indicates we failed to unlink the mount tree so
|
|
|
1c5f92 |
* we have to return a failure.
|
|
|
1c5f92 |
*/
|
|
|
1c5f92 |
ret = unlink_active_mounts(ap, mnts, me);
|
|
|
1c5f92 |
- if (ret == -1 || ret == 0)
|
|
|
1c5f92 |
- return ret;
|
|
|
1c5f92 |
+ if (!ret)
|
|
|
1c5f92 |
+ return -1;
|
|
|
1c5f92 |
|
|
|
1c5f92 |
if (me->ioctlfd != -1) {
|
|
|
1c5f92 |
error(ap->logopt, "active direct mount %s", me->key);
|