autofs-5.1.5 - use mp instead of path in mnt_list entries
From: Ian Kent <raven@themaw.net>
Use the simpler, more instructive mp instead of path in the
mnt_list structure.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1
daemon/direct.c | 18 +++++++-------
daemon/indirect.c | 22 ++++++++---------
include/mounts.h | 4 +--
lib/mounts.c | 68 +++++++++++++++++++++++++++---------------------------
5 files changed, 57 insertions(+), 56 deletions(-)
--- autofs-5.0.7.orig/CHANGELOG
+++ autofs-5.0.7/CHANGELOG
@@ -338,6 +338,7 @@
- use ignore option for offset mounts as well.
- add config option for "ignore" mount option
- use bit flags for autofs mount types in mnt_list.
+- use mp instead of path in mnt_list entries.
25/07/2012 autofs-5.0.7
=======================
--- autofs-5.0.7.orig/daemon/direct.c
+++ autofs-5.0.7/daemon/direct.c
@@ -272,12 +272,12 @@ static int unlink_mount_tree(struct auto
mnt = list_entry(p, struct mnt_list, list);
if (mnt->flags & MNTS_AUTOFS)
- rv = umount2(mnt->path, MNT_DETACH);
+ rv = umount2(mnt->mp, MNT_DETACH);
else
- rv = spawn_umount(ap->logopt, "-l", mnt->path, NULL);
+ rv = spawn_umount(ap->logopt, "-l", mnt->mp, NULL);
if (rv == -1) {
debug(ap->logopt,
- "can't unlink %s from mount tree", mnt->path);
+ "can't unlink %s from mount tree", mnt->mp);
switch (errno) {
case EINVAL:
@@ -906,7 +906,7 @@ void *expire_proc_direct(void *arg)
*/
pthread_cleanup_push(master_source_lock_cleanup, ap->entry);
master_source_readlock(ap->entry);
- me = lookup_source_mapent(ap, next->path, LKP_DISTINCT);
+ me = lookup_source_mapent(ap, next->mp, LKP_DISTINCT);
pthread_cleanup_pop(1);
if (!me)
continue;
@@ -923,7 +923,7 @@ void *expire_proc_direct(void *arg)
*/
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state);
if (next->flags & MNTS_INDIRECT) {
- master_notify_submount(ap, next->path, ap->state);
+ master_notify_submount(ap, next->mp, ap->state);
pthread_setcancelstate(cur_state, NULL);
continue;
}
@@ -954,7 +954,7 @@ void *expire_proc_direct(void *arg)
cache_writelock(me->mc);
if (me->ioctlfd != -1 &&
fstat(me->ioctlfd, &st) != -1 &&
- !count_mounts(ap, next->path, st.st_dev)) {
+ !count_mounts(ap, next->mp, st.st_dev)) {
ops->close(ap->logopt, me->ioctlfd);
me->ioctlfd = -1;
cache_unlock(me->mc);
@@ -965,7 +965,7 @@ void *expire_proc_direct(void *arg)
ioctlfd = me->ioctlfd;
- ret = ops->expire(ap->logopt, ioctlfd, next->path, now);
+ ret = ops->expire(ap->logopt, ioctlfd, next->mp, now);
if (ret) {
left++;
pthread_setcancelstate(cur_state, NULL);
@@ -988,10 +988,10 @@ void *expire_proc_direct(void *arg)
if (ap->state == ST_EXPIRE || ap->state == ST_PRUNE)
pthread_testcancel();
- debug(ap->logopt, "send expire to trigger %s", next->path);
+ debug(ap->logopt, "send expire to trigger %s", next->mp);
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state);
- ret = ops->expire(ap->logopt, ioctlfd, next->path, now);
+ ret = ops->expire(ap->logopt, ioctlfd, next->mp, now);
if (ret)
left++;
pthread_setcancelstate(cur_state, NULL);
--- autofs-5.0.7.orig/daemon/indirect.c
+++ autofs-5.0.7/daemon/indirect.c
@@ -49,12 +49,12 @@ static int unlink_mount_tree(struct auto
this = mnts;
while (this) {
if (this->flags & MNTS_AUTOFS)
- rv = umount2(this->path, MNT_DETACH);
+ rv = umount2(this->mp, MNT_DETACH);
else
- rv = spawn_umount(ap->logopt, "-l", this->path, NULL);
+ rv = spawn_umount(ap->logopt, "-l", this->mp, NULL);
if (rv == -1) {
debug(ap->logopt,
- "can't unlink %s from mount tree", this->path);
+ "can't unlink %s from mount tree", this->mp);
switch (errno) {
case EINVAL:
@@ -442,7 +442,7 @@ void *expire_proc_indirect(void *arg)
*/
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state);
if (next->flags & MNTS_INDIRECT)
- master_notify_submount(ap, next->path, ap->state);
+ master_notify_submount(ap, next->mp, ap->state);
else if (next->flags & MNTS_OFFSET) {
struct map_source *map;
struct mapent_cache *mc = NULL;
@@ -450,13 +450,13 @@ void *expire_proc_indirect(void *arg)
struct stat st;
/* It's got a mount, deal with in the outer loop */
- if (is_mounted(_PATH_MOUNTED, next->path, MNTS_REAL)) {
+ if (is_mounted(_PATH_MOUNTED, next->mp, MNTS_REAL)) {
pthread_setcancelstate(cur_state, NULL);
continue;
}
/* Don't touch submounts */
- if (master_find_submount(ap, next->path)) {
+ if (master_find_submount(ap, next->mp)) {
pthread_setcancelstate(cur_state, NULL);
continue;
}
@@ -467,7 +467,7 @@ void *expire_proc_indirect(void *arg)
while (map) {
mc = map->mc;
cache_writelock(mc);
- me = cache_lookup_distinct(mc, next->path);
+ me = cache_lookup_distinct(mc, next->mp);
if (me)
break;
cache_unlock(mc);
@@ -509,7 +509,7 @@ void *expire_proc_indirect(void *arg)
* If the mount corresponds to an offset trigger then
* the key is the path, otherwise it's the last component.
*/
- ind_key = strrchr(next->path, '/');
+ ind_key = strrchr(next->mp, '/');
if (ind_key)
ind_key++;
@@ -522,7 +522,7 @@ void *expire_proc_indirect(void *arg)
*/
pthread_cleanup_push(master_source_lock_cleanup, ap->entry);
master_source_readlock(ap->entry);
- me = lookup_source_mapent(ap, next->path, LKP_DISTINCT);
+ me = lookup_source_mapent(ap, next->mp, LKP_DISTINCT);
if (!me && ind_key)
me = lookup_source_mapent(ap, ind_key, LKP_NORMAL);
pthread_cleanup_pop(1);
@@ -534,10 +534,10 @@ void *expire_proc_indirect(void *arg)
cache_unlock(me->mc);
}
- debug(ap->logopt, "expire %s", next->path);
+ debug(ap->logopt, "expire %s", next->mp);
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state);
- ret = ops->expire(ap->logopt, ioctlfd, next->path, now);
+ ret = ops->expire(ap->logopt, ioctlfd, next->mp, now);
if (ret)
left++;
pthread_setcancelstate(cur_state, NULL);
--- autofs-5.0.7.orig/include/mounts.h
+++ autofs-5.0.7/include/mounts.h
@@ -52,7 +52,7 @@ extern const unsigned int t_offset;
struct mapent;
struct mnt_list {
- char *path;
+ char *mp;
unsigned int flags;
/*
* List operations ie. get_mnt_list.
@@ -101,7 +101,7 @@ int ext_mount_remove(struct list_head *,
int ext_mount_inuse(const char *);
struct mnt_list *get_mnt_list(const char *table, const char *path, int include);
void free_mnt_list(struct mnt_list *list);
-int is_mounted(const char *table, const char *path, unsigned int type);
+int is_mounted(const char *table, const char *mp, unsigned int type);
void tree_free_mnt_tree(struct mnt_list *tree);
struct mnt_list *tree_make_mnt_tree(const char *table, const char *path);
int tree_get_mnt_list(struct mnt_list *mnts, struct list_head *list, const char *path, int include);
--- autofs-5.0.7.orig/lib/mounts.c
+++ autofs-5.0.7/lib/mounts.c
@@ -818,8 +818,8 @@ struct mnt_list *get_mnt_list(const char
strncmp(mnt->mnt_dir, path, pathlen) != 0)
continue;
- /* Not a subdirectory of requested path ? */
- /* pathlen == 1 => everything is subdir */
+ /* Not a subdirectory of requested mp? */
+ /* mp_len == 1 => everything is subdir */
if (pathlen > 1 && len > pathlen &&
mnt->mnt_dir[pathlen] != '/')
continue;
@@ -835,7 +835,7 @@ struct mnt_list *get_mnt_list(const char
mptr = list;
last = NULL;
while (mptr) {
- if (len >= strlen(mptr->path))
+ if (len >= strlen(mptr->mp))
break;
last = mptr;
mptr = mptr->next;
@@ -848,13 +848,13 @@ struct mnt_list *get_mnt_list(const char
ent->next = mptr;
- ent->path = malloc(len + 1);
- if (!ent->path) {
+ ent->mp = malloc(len + 1);
+ if (!ent->mp) {
endmntent(tab);
free_mnt_list(list);
return NULL;
}
- strcpy(ent->path, mnt->mnt_dir);
+ strcpy(ent->mp, mnt->mnt_dir);
if (!strcmp(mnt->mnt_type, "autofs"))
ent->flags |= MNTS_AUTOFS;
@@ -886,23 +886,23 @@ void free_mnt_list(struct mnt_list *list
next = this->next;
- if (this->path)
- free(this->path);
+ if (this->mp)
+ free(this->mp);
free(this);
}
}
-static int table_is_mounted(const char *table, const char *path, unsigned int type)
+static int table_is_mounted(const char *table, const char *mp, unsigned int type)
{
struct mntent *mnt;
struct mntent mnt_wrk;
char buf[PATH_MAX * 3];
- size_t pathlen = strlen(path);
+ size_t mp_len = strlen(mp);
FILE *tab;
int ret = 0;
- if (!path || !pathlen || pathlen >= PATH_MAX)
+ if (!mp || !mp_len || mp_len >= PATH_MAX)
return 0;
tab = open_setmntent_r(table);
@@ -929,7 +929,7 @@ static int table_is_mounted(const char *
continue;
}
- if (pathlen == len && !strncmp(path, mnt->mnt_dir, pathlen)) {
+ if (mp_len == len && !strncmp(mp, mnt->mnt_dir, mp_len)) {
ret = 1;
break;
}
@@ -939,12 +939,12 @@ static int table_is_mounted(const char *
return ret;
}
-static int ioctl_is_mounted(const char *path, unsigned int type)
+static int ioctl_is_mounted(const char *mp, unsigned int type)
{
struct ioctl_ops *ops = get_ioctl_ops();
unsigned int mounted;
- ops->ismountpoint(LOGOPT_NONE, -1, path, &mounted);
+ ops->ismountpoint(LOGOPT_NONE, -1, mp, &mounted);
if (mounted) {
switch (type) {
case MNTS_ALL:
@@ -958,14 +958,14 @@ static int ioctl_is_mounted(const char *
return 0;
}
-int is_mounted(const char *table, const char *path, unsigned int type)
+int is_mounted(const char *table, const char *mp, unsigned int type)
{
struct ioctl_ops *ops = get_ioctl_ops();
if (ops->ismountpoint)
- return ioctl_is_mounted(path, type);
+ return ioctl_is_mounted(mp, type);
else
- return table_is_mounted(table, path, type);
+ return table_is_mounted(table, mp, type);
}
/*
@@ -1000,12 +1000,12 @@ void tree_free_mnt_tree(struct mnt_list
list_del(&this->self);
- free(this->path);
+ free(this->mp);
free(this);
}
- free(tree->path);
+ free(tree->mp);
free(tree);
}
@@ -1056,14 +1056,14 @@ struct mnt_list *tree_make_mnt_tree(cons
INIT_LIST_HEAD(&ent->entries);
INIT_LIST_HEAD(&ent->sublist);
- ent->path = malloc(len + 1);
- if (!ent->path) {
+ ent->mp = malloc(len + 1);
+ if (!ent->mp) {
endmntent(tab);
free(ent);
tree_free_mnt_tree(tree);
return NULL;
}
- strcpy(ent->path, mnt->mnt_dir);
+ strcpy(ent->mp, mnt->mnt_dir);
if (!strcmp(mnt->mnt_type, "autofs"))
ent->flags |= MNTS_AUTOFS;
@@ -1079,8 +1079,8 @@ struct mnt_list *tree_make_mnt_tree(cons
mptr = tree;
while (mptr) {
- int elen = strlen(ent->path);
- int mlen = strlen(mptr->path);
+ int elen = strlen(ent->mp);
+ int mlen = strlen(mptr->mp);
if (elen < mlen) {
if (mptr->left) {
@@ -1100,7 +1100,7 @@ struct mnt_list *tree_make_mnt_tree(cons
}
}
- eq = strcmp(ent->path, mptr->path);
+ eq = strcmp(ent->mp, mptr->mp);
if (eq < 0) {
if (mptr->left)
mptr = mptr->left;
@@ -1140,7 +1140,7 @@ int tree_get_mnt_list(struct mnt_list *m
return 0;
plen = strlen(path);
- mlen = strlen(mnts->path);
+ mlen = strlen(mnts->mp);
if (mlen < plen)
return tree_get_mnt_list(mnts->right, list, path, include);
else {
@@ -1149,10 +1149,10 @@ int tree_get_mnt_list(struct mnt_list *m
tree_get_mnt_list(mnts->left, list, path, include);
if ((!include && mlen <= plen) ||
- strncmp(mnts->path, path, plen))
+ strncmp(mnts->mp, path, plen))
goto skip;
- if (plen > 1 && mlen > plen && mnts->path[plen] != '/')
+ if (plen > 1 && mlen > plen && mnts->mp[plen] != '/')
goto skip;
INIT_LIST_HEAD(&mnts->list);
@@ -1187,7 +1187,7 @@ int tree_get_mnt_sublist(struct mnt_list
return 0;
plen = strlen(path);
- mlen = strlen(mnts->path);
+ mlen = strlen(mnts->mp);
if (mlen < plen)
return tree_get_mnt_sublist(mnts->right, list, path, include);
else {
@@ -1196,10 +1196,10 @@ int tree_get_mnt_sublist(struct mnt_list
tree_get_mnt_sublist(mnts->left, list, path, include);
if ((!include && mlen <= plen) ||
- strncmp(mnts->path, path, plen))
+ strncmp(mnts->mp, path, plen))
goto skip;
- if (plen > 1 && mlen > plen && mnts->path[plen] != '/')
+ if (plen > 1 && mlen > plen && mnts->mp[plen] != '/')
goto skip;
INIT_LIST_HEAD(&mnts->sublist);
@@ -1231,7 +1231,7 @@ int tree_find_mnt_ents(struct mnt_list *
return 0;
plen = strlen(path);
- mlen = strlen(mnts->path);
+ mlen = strlen(mnts->mp);
if (mlen < plen)
return tree_find_mnt_ents(mnts->right, list, path);
else if (mlen > plen)
@@ -1241,7 +1241,7 @@ int tree_find_mnt_ents(struct mnt_list *
tree_find_mnt_ents(mnts->left, list, path);
- if (!strcmp(mnts->path, path)) {
+ if (!strcmp(mnts->mp, path)) {
INIT_LIST_HEAD(&mnts->entries);
list_add(&mnts->entries, list);
}
@@ -1252,7 +1252,7 @@ int tree_find_mnt_ents(struct mnt_list *
this = list_entry(p, struct mnt_list, self);
- if (!strcmp(this->path, path)) {
+ if (!strcmp(this->mp, path)) {
INIT_LIST_HEAD(&this->entries);
list_add(&this->entries, list);
}