|
|
6bbd11 |
autofs-5.0.8 - change walk_tree() to take ap
|
|
|
6bbd11 |
|
|
|
6bbd11 |
From: Ian Kent <raven@themaw.net>
|
|
|
6bbd11 |
|
|
|
6bbd11 |
Change walk_tree() to take an autofs_point pointer instead of
|
|
|
6bbd11 |
logopt.
|
|
|
6bbd11 |
---
|
|
|
6bbd11 |
CHANGELOG | 1 +
|
|
|
6bbd11 |
daemon/automount.c | 49 +++++++++++++++++++++++++++++--------------------
|
|
|
6bbd11 |
daemon/direct.c | 2 +-
|
|
|
6bbd11 |
daemon/indirect.c | 6 +++---
|
|
|
6bbd11 |
include/automount.h | 4 ++--
|
|
|
6bbd11 |
5 files changed, 36 insertions(+), 26 deletions(-)
|
|
|
6bbd11 |
|
|
|
6bbd11 |
--- autofs-5.0.7.orig/CHANGELOG
|
|
|
6bbd11 |
+++ autofs-5.0.7/CHANGELOG
|
|
|
6bbd11 |
@@ -90,6 +90,7 @@
|
|
|
6bbd11 |
- fix master map type check.
|
|
|
6bbd11 |
- fix bad mkdir permission on create.
|
|
|
6bbd11 |
- fix macro_addvar() and move init to main thread.
|
|
|
6bbd11 |
+- change walk_tree() to take ap.
|
|
|
6bbd11 |
|
|
|
6bbd11 |
25/07/2012 autofs-5.0.7
|
|
|
6bbd11 |
=======================
|
|
|
6bbd11 |
--- autofs-5.0.7.orig/daemon/automount.c
|
|
|
6bbd11 |
+++ autofs-5.0.7/daemon/automount.c
|
|
|
6bbd11 |
@@ -254,10 +254,12 @@ int rmdir_path(struct autofs_point *ap,
|
|
|
6bbd11 |
/* Like ftw, except fn gets called twice: before a directory is
|
|
|
6bbd11 |
entered, and after. If the before call returns 0, the directory
|
|
|
6bbd11 |
isn't entered. */
|
|
|
6bbd11 |
-static int walk_tree(const char *base, int (*fn) (unsigned logopt,
|
|
|
6bbd11 |
+static int walk_tree(const char *base, int (*fn) (struct autofs_point *ap,
|
|
|
6bbd11 |
const char *file,
|
|
|
6bbd11 |
const struct stat * st,
|
|
|
6bbd11 |
- int, void *), int incl, unsigned logopt, void *arg)
|
|
|
6bbd11 |
+ int, void *), int incl,
|
|
|
6bbd11 |
+ struct autofs_point *ap,
|
|
|
6bbd11 |
+ void *arg)
|
|
|
6bbd11 |
{
|
|
|
6bbd11 |
char buf[PATH_MAX + 1];
|
|
|
6bbd11 |
struct stat st, *pst = &st;
|
|
|
6bbd11 |
@@ -270,7 +272,7 @@ static int walk_tree(const char *base, i
|
|
|
6bbd11 |
ret = 0;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
|
|
|
6bbd11 |
- if (ret != -1 && (fn) (logopt, base, pst, 0, arg)) {
|
|
|
6bbd11 |
+ if (ret != -1 && (fn) (ap, base, pst, 0, arg)) {
|
|
|
6bbd11 |
if (S_ISDIR(st.st_mode)) {
|
|
|
6bbd11 |
struct dirent **de;
|
|
|
6bbd11 |
int n;
|
|
|
6bbd11 |
@@ -298,18 +300,20 @@ static int walk_tree(const char *base, i
|
|
|
6bbd11 |
return -1;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
|
|
|
6bbd11 |
- walk_tree(buf, fn, 1, logopt, arg);
|
|
|
6bbd11 |
+ walk_tree(buf, fn, 1, ap, arg);
|
|
|
6bbd11 |
free(de[n]);
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
free(de);
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
if (incl)
|
|
|
6bbd11 |
- (fn) (logopt, base, pst, 1, arg);
|
|
|
6bbd11 |
+ (fn) (ap, base, pst, 1, arg);
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
return 0;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
|
|
|
6bbd11 |
-static int rm_unwanted_fn(unsigned logopt, const char *file, const struct stat *st, int when, void *arg)
|
|
|
6bbd11 |
+static int rm_unwanted_fn(struct autofs_point *ap,
|
|
|
6bbd11 |
+ const char *file, const struct stat *st,
|
|
|
6bbd11 |
+ int when, void *arg)
|
|
|
6bbd11 |
{
|
|
|
6bbd11 |
dev_t dev = *(dev_t *) arg;
|
|
|
6bbd11 |
char buf[MAX_ERR_BUF];
|
|
|
6bbd11 |
@@ -325,38 +329,40 @@ static int rm_unwanted_fn(unsigned logop
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
|
|
|
6bbd11 |
if (lstat(file, &newst)) {
|
|
|
6bbd11 |
- crit(logopt, "unable to stat file, possible race condition");
|
|
|
6bbd11 |
+ crit(ap->logopt,
|
|
|
6bbd11 |
+ "unable to stat file, possible race condition");
|
|
|
6bbd11 |
return 0;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
|
|
|
6bbd11 |
if (newst.st_dev != dev) {
|
|
|
6bbd11 |
- crit(logopt, "file %s has the wrong device, possible race condition",
|
|
|
6bbd11 |
+ crit(ap->logopt,
|
|
|
6bbd11 |
+ "file %s has the wrong device, possible race condition",
|
|
|
6bbd11 |
file);
|
|
|
6bbd11 |
return 0;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
|
|
|
6bbd11 |
if (S_ISDIR(newst.st_mode)) {
|
|
|
6bbd11 |
- debug(logopt, "removing directory %s", file);
|
|
|
6bbd11 |
+ debug(ap->logopt, "removing directory %s", file);
|
|
|
6bbd11 |
if (rmdir(file)) {
|
|
|
6bbd11 |
char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
|
|
|
6bbd11 |
- warn(logopt,
|
|
|
6bbd11 |
+ warn(ap->logopt,
|
|
|
6bbd11 |
"unable to remove directory %s: %s", file, estr);
|
|
|
6bbd11 |
return 0;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
} else if (S_ISREG(newst.st_mode)) {
|
|
|
6bbd11 |
- crit(logopt, "attempting to remove files from a mounted "
|
|
|
6bbd11 |
+ crit(ap->logopt, "attempting to remove files from a mounted "
|
|
|
6bbd11 |
"directory. file %s", file);
|
|
|
6bbd11 |
return 0;
|
|
|
6bbd11 |
} else if (S_ISLNK(newst.st_mode)) {
|
|
|
6bbd11 |
- debug(logopt, "removing symlink %s", file);
|
|
|
6bbd11 |
+ debug(ap->logopt, "removing symlink %s", file);
|
|
|
6bbd11 |
unlink(file);
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
return 1;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
|
|
|
6bbd11 |
-void rm_unwanted(unsigned logopt, const char *path, int incl, dev_t dev)
|
|
|
6bbd11 |
+void rm_unwanted(struct autofs_point *ap, const char *path, int incl)
|
|
|
6bbd11 |
{
|
|
|
6bbd11 |
- walk_tree(path, rm_unwanted_fn, incl, logopt, &dev;;
|
|
|
6bbd11 |
+ walk_tree(path, rm_unwanted_fn, incl, ap, &ap->dev);
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
|
|
|
6bbd11 |
struct counter_args {
|
|
|
6bbd11 |
@@ -364,7 +370,8 @@ struct counter_args {
|
|
|
6bbd11 |
dev_t dev;
|
|
|
6bbd11 |
};
|
|
|
6bbd11 |
|
|
|
6bbd11 |
-static int counter_fn(unsigned logopt, const char *file, const struct stat *st, int when, void *arg)
|
|
|
6bbd11 |
+static int counter_fn(struct autofs_point *ap, const char *file,
|
|
|
6bbd11 |
+ const struct stat *st, int when, void *arg)
|
|
|
6bbd11 |
{
|
|
|
6bbd11 |
struct counter_args *counter = (struct counter_args *) arg;
|
|
|
6bbd11 |
|
|
|
6bbd11 |
@@ -378,14 +385,14 @@ static int counter_fn(unsigned logopt, c
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
|
|
|
6bbd11 |
/* Count mounted filesystems and symlinks */
|
|
|
6bbd11 |
-int count_mounts(unsigned logopt, const char *path, dev_t dev)
|
|
|
6bbd11 |
+int count_mounts(struct autofs_point *ap, const char *path, dev_t dev)
|
|
|
6bbd11 |
{
|
|
|
6bbd11 |
struct counter_args counter;
|
|
|
6bbd11 |
|
|
|
6bbd11 |
counter.count = 0;
|
|
|
6bbd11 |
counter.dev = dev;
|
|
|
6bbd11 |
|
|
|
6bbd11 |
- if (walk_tree(path, counter_fn, 0, logopt, &counter) == -1)
|
|
|
6bbd11 |
+ if (walk_tree(path, counter_fn, 0, ap, &counter) == -1)
|
|
|
6bbd11 |
return -1;
|
|
|
6bbd11 |
|
|
|
6bbd11 |
return counter.count;
|
|
|
6bbd11 |
@@ -409,9 +416,9 @@ static void check_rm_dirs(struct autofs_
|
|
|
6bbd11 |
(ap->state == ST_SHUTDOWN_PENDING ||
|
|
|
6bbd11 |
ap->state == ST_SHUTDOWN_FORCE ||
|
|
|
6bbd11 |
ap->state == ST_SHUTDOWN))
|
|
|
6bbd11 |
- rm_unwanted(ap->logopt, path, incl, ap->dev);
|
|
|
6bbd11 |
+ rm_unwanted(ap, path, incl);
|
|
|
6bbd11 |
else if ((ap->flags & MOUNT_FLAG_GHOST) && (ap->type == LKP_INDIRECT))
|
|
|
6bbd11 |
- rm_unwanted(ap->logopt, path, 0, ap->dev);
|
|
|
6bbd11 |
+ rm_unwanted(ap, path, 0);
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
|
|
|
6bbd11 |
/* Try to purge cache entries kept around due to existing mounts */
|
|
|
6bbd11 |
@@ -553,7 +560,9 @@ int umount_multi(struct autofs_point *ap
|
|
|
6bbd11 |
left += umount_subtree_mounts(ap, path, is_autofs_fs);
|
|
|
6bbd11 |
|
|
|
6bbd11 |
/* Delete detritus like unwanted mountpoints and symlinks */
|
|
|
6bbd11 |
- if (left == 0 && ap->state != ST_READMAP) {
|
|
|
6bbd11 |
+ if (left == 0 &&
|
|
|
6bbd11 |
+ ap->state != ST_READMAP &&
|
|
|
6bbd11 |
+ !count_mounts(ap, path, ap->dev)) {
|
|
|
6bbd11 |
update_map_cache(ap, path);
|
|
|
6bbd11 |
check_rm_dirs(ap, path, incl);
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
--- autofs-5.0.7.orig/daemon/direct.c
|
|
|
6bbd11 |
+++ autofs-5.0.7/daemon/direct.c
|
|
|
6bbd11 |
@@ -912,7 +912,7 @@ void *expire_proc_direct(void *arg)
|
|
|
6bbd11 |
cache_writelock(me->mc);
|
|
|
6bbd11 |
if (me->ioctlfd != -1 &&
|
|
|
6bbd11 |
fstat(me->ioctlfd, &st) != -1 &&
|
|
|
6bbd11 |
- !count_mounts(ap->logopt, next->path, st.st_dev)) {
|
|
|
6bbd11 |
+ !count_mounts(ap, next->path, st.st_dev)) {
|
|
|
6bbd11 |
ops->close(ap->logopt, me->ioctlfd);
|
|
|
6bbd11 |
me->ioctlfd = -1;
|
|
|
6bbd11 |
cache_unlock(me->mc);
|
|
|
6bbd11 |
--- autofs-5.0.7.orig/daemon/indirect.c
|
|
|
6bbd11 |
+++ autofs-5.0.7/daemon/indirect.c
|
|
|
6bbd11 |
@@ -365,7 +365,7 @@ force_umount:
|
|
|
6bbd11 |
} else {
|
|
|
6bbd11 |
info(ap->logopt, "umounted indirect mount %s", mountpoint);
|
|
|
6bbd11 |
if (ap->submount)
|
|
|
6bbd11 |
- rm_unwanted(ap->logopt, mountpoint, 1, ap->dev);
|
|
|
6bbd11 |
+ rm_unwanted(ap, mountpoint, 1);
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
|
|
|
6bbd11 |
return rv;
|
|
|
6bbd11 |
@@ -476,7 +476,7 @@ void *expire_proc_indirect(void *arg)
|
|
|
6bbd11 |
|
|
|
6bbd11 |
/* Check for manual umount */
|
|
|
6bbd11 |
if (fstat(me->ioctlfd, &st) == -1 ||
|
|
|
6bbd11 |
- !count_mounts(ap->logopt, me->key, st.st_dev)) {
|
|
|
6bbd11 |
+ !count_mounts(ap, me->key, st.st_dev)) {
|
|
|
6bbd11 |
ops->close(ap->logopt, me->ioctlfd);
|
|
|
6bbd11 |
me->ioctlfd = -1;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
@@ -538,7 +538,7 @@ void *expire_proc_indirect(void *arg)
|
|
|
6bbd11 |
* so we need to umount or unlink them here.
|
|
|
6bbd11 |
*/
|
|
|
6bbd11 |
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state);
|
|
|
6bbd11 |
- retries = (count_mounts(ap->logopt, ap->path, ap->dev) + 1);
|
|
|
6bbd11 |
+ retries = (count_mounts(ap, ap->path, ap->dev) + 1);
|
|
|
6bbd11 |
while (retries--) {
|
|
|
6bbd11 |
ret = ops->expire(ap->logopt, ap->ioctlfd, ap->path, now);
|
|
|
6bbd11 |
if (ret)
|
|
|
6bbd11 |
--- autofs-5.0.7.orig/include/automount.h
|
|
|
6bbd11 |
+++ autofs-5.0.7/include/automount.h
|
|
|
6bbd11 |
@@ -526,8 +526,8 @@ int handle_packet_expire_indirect(struct
|
|
|
6bbd11 |
int handle_packet_expire_direct(struct autofs_point *ap, autofs_packet_expire_direct_t *pkt);
|
|
|
6bbd11 |
int handle_packet_missing_indirect(struct autofs_point *ap, autofs_packet_missing_indirect_t *pkt);
|
|
|
6bbd11 |
int handle_packet_missing_direct(struct autofs_point *ap, autofs_packet_missing_direct_t *pkt);
|
|
|
6bbd11 |
-void rm_unwanted(unsigned logopt, const char *path, int incl, dev_t dev);
|
|
|
6bbd11 |
-int count_mounts(unsigned logopt, const char *path, dev_t dev);
|
|
|
6bbd11 |
+void rm_unwanted(struct autofs_point *ap, const char *path, int incl);
|
|
|
6bbd11 |
+int count_mounts(struct autofs_point *ap, const char *path, dev_t dev);
|
|
|
6bbd11 |
|
|
|
6bbd11 |
#define mounts_mutex_lock(ap) \
|
|
|
6bbd11 |
do { \
|