|
|
80b5cf |
autofs-5.1.6 - fix unlink mounts umount order
|
|
|
80b5cf |
|
|
|
80b5cf |
From: Ian Kent <raven@themaw.net>
|
|
|
80b5cf |
|
|
|
80b5cf |
The recent changes to mount table handling to support the "ignore"
|
|
|
80b5cf |
autofs pseudo option resulted in the incorrect umount order being used
|
|
|
80b5cf |
in the unlink_mount_tree() function.
|
|
|
80b5cf |
|
|
|
80b5cf |
To fix this change unlink_mount_tree() to use the existing get_mnt_list()
|
|
|
80b5cf |
function to construct a correctly ordered list for the umounts.
|
|
|
80b5cf |
|
|
|
80b5cf |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
80b5cf |
---
|
|
|
80b5cf |
CHANGELOG | 1 +
|
|
|
80b5cf |
lib/mounts.c | 39 +++++++++------------------------------
|
|
|
80b5cf |
2 files changed, 10 insertions(+), 30 deletions(-)
|
|
|
80b5cf |
|
|
|
80b5cf |
--- autofs-5.0.7.orig/CHANGELOG
|
|
|
80b5cf |
+++ autofs-5.0.7/CHANGELOG
|
|
|
80b5cf |
@@ -356,6 +356,7 @@
|
|
|
80b5cf |
- fix quoted string length calc in expandsunent().
|
|
|
80b5cf |
- fix autofs mount options construction.
|
|
|
80b5cf |
- fix direct mount unlink_mount_tree() path.
|
|
|
80b5cf |
+- fix unlink mounts umount order.
|
|
|
80b5cf |
|
|
|
80b5cf |
25/07/2012 autofs-5.0.7
|
|
|
80b5cf |
=======================
|
|
|
80b5cf |
--- autofs-5.0.7.orig/lib/mounts.c
|
|
|
80b5cf |
+++ autofs-5.0.7/lib/mounts.c
|
|
|
80b5cf |
@@ -952,42 +952,21 @@ local_getmntent_r(FILE *tab, struct mnte
|
|
|
80b5cf |
|
|
|
80b5cf |
int unlink_mount_tree(struct autofs_point *ap, const char *mp)
|
|
|
80b5cf |
{
|
|
|
80b5cf |
- FILE *tab;
|
|
|
80b5cf |
- struct mntent *mnt;
|
|
|
80b5cf |
- struct mntent mnt_wrk;
|
|
|
80b5cf |
- char buf[PATH_MAX * 3];
|
|
|
80b5cf |
- unsigned int mp_len = strlen(mp);
|
|
|
80b5cf |
+ struct mnt_list *mnts, *mnt;
|
|
|
80b5cf |
int rv, ret = 1;
|
|
|
80b5cf |
|
|
|
80b5cf |
- tab = open_fopen_r(_PROC_MOUNTS);
|
|
|
80b5cf |
- if (!tab) {
|
|
|
80b5cf |
- char *estr = strerror_r(errno, buf, PATH_MAX - 1);
|
|
|
80b5cf |
- logerr("fopen: %s", estr);
|
|
|
80b5cf |
+ mnts = get_mnt_list(mp, 1);
|
|
|
80b5cf |
+ if (!mnts)
|
|
|
80b5cf |
return 0;
|
|
|
80b5cf |
- }
|
|
|
80b5cf |
-
|
|
|
80b5cf |
- while ((mnt = local_getmntent_r(tab, &mnt_wrk, buf, PATH_MAX * 3))) {
|
|
|
80b5cf |
- unsigned int mnt_dir_len;
|
|
|
80b5cf |
- int is_autofs;
|
|
|
80b5cf |
-
|
|
|
80b5cf |
- if (strncmp(mnt->mnt_dir, mp, mp_len))
|
|
|
80b5cf |
- continue;
|
|
|
80b5cf |
-
|
|
|
80b5cf |
- mnt_dir_len = strlen(mnt->mnt_dir);
|
|
|
80b5cf |
- is_autofs = !strcmp(mnt->mnt_type, "autofs");
|
|
|
80b5cf |
-
|
|
|
80b5cf |
- if (mnt_dir_len == mp_len && !is_autofs) {
|
|
|
80b5cf |
- ret = 0;
|
|
|
80b5cf |
- break;
|
|
|
80b5cf |
- }
|
|
|
80b5cf |
|
|
|
80b5cf |
- if (is_autofs)
|
|
|
80b5cf |
- rv = umount2(mnt->mnt_dir, MNT_DETACH);
|
|
|
80b5cf |
+ for (mnt = mnts; mnt; mnt = mnt->next) {
|
|
|
80b5cf |
+ if (mnt->flags | MNTS_AUTOFS)
|
|
|
80b5cf |
+ rv = umount2(mnt->mp, MNT_DETACH);
|
|
|
80b5cf |
else
|
|
|
80b5cf |
- rv = spawn_umount(ap->logopt, "-l", mnt->mnt_dir, NULL);
|
|
|
80b5cf |
+ rv = spawn_umount(ap->logopt, "-l", mnt->mp, NULL);
|
|
|
80b5cf |
if (rv == -1) {
|
|
|
80b5cf |
debug(ap->logopt,
|
|
|
80b5cf |
- "can't unlink %s from mount tree", mnt->mnt_dir);
|
|
|
80b5cf |
+ "can't unlink %s from mount tree", mnt->mp);
|
|
|
80b5cf |
|
|
|
80b5cf |
switch (errno) {
|
|
|
80b5cf |
case EINVAL:
|
|
|
80b5cf |
@@ -1003,7 +982,7 @@ int unlink_mount_tree(struct autofs_poin
|
|
|
80b5cf |
}
|
|
|
80b5cf |
}
|
|
|
80b5cf |
}
|
|
|
80b5cf |
- fclose(tab);
|
|
|
80b5cf |
+ free_mnt_list(mnts);
|
|
|
80b5cf |
|
|
|
80b5cf |
return ret;
|
|
|
80b5cf |
}
|