|
|
96dc52 |
autofs-5.1.7 - add a len field to struct autofs_point
|
|
|
96dc52 |
|
|
|
96dc52 |
From: Ian Kent <raven@themaw.net>
|
|
|
96dc52 |
|
|
|
96dc52 |
Add a path length field to struct autofs_point since the path length
|
|
|
96dc52 |
is needed at various times avoiding additional strlen() calls.
|
|
|
96dc52 |
|
|
|
96dc52 |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
96dc52 |
---
|
|
|
96dc52 |
CHANGELOG | 1 +
|
|
|
96dc52 |
daemon/lookup.c | 2 +-
|
|
|
96dc52 |
daemon/master.c | 1 +
|
|
|
96dc52 |
include/automount.h | 1 +
|
|
|
96dc52 |
lib/mounts.c | 6 +++---
|
|
|
96dc52 |
modules/parse_amd.c | 4 ++--
|
|
|
96dc52 |
modules/parse_sun.c | 4 ++--
|
|
|
96dc52 |
7 files changed, 11 insertions(+), 8 deletions(-)
|
|
|
96dc52 |
|
|
|
96dc52 |
diff --git a/CHANGELOG b/CHANGELOG
|
|
|
96dc52 |
index 60924b3f..0dae6761 100644
|
|
|
96dc52 |
--- a/CHANGELOG
|
|
|
96dc52 |
+++ b/CHANGELOG
|
|
|
96dc52 |
@@ -30,6 +30,7 @@
|
|
|
96dc52 |
- rename tree implementation functions.
|
|
|
96dc52 |
- add some multi-mount macros.
|
|
|
96dc52 |
- remove unused functions cache_dump_multi() and cache_dump_cache().
|
|
|
96dc52 |
+- add a len field to struct autofs_point.
|
|
|
96dc52 |
|
|
|
96dc52 |
25/01/2021 autofs-5.1.7
|
|
|
96dc52 |
- make bind mounts propagation slave by default.
|
|
|
96dc52 |
diff --git a/daemon/lookup.c b/daemon/lookup.c
|
|
|
96dc52 |
index 8c9a82b5..5116b927 100644
|
|
|
96dc52 |
--- a/daemon/lookup.c
|
|
|
96dc52 |
+++ b/daemon/lookup.c
|
|
|
96dc52 |
@@ -843,7 +843,7 @@ static int lookup_amd_instance(struct autofs_point *ap,
|
|
|
96dc52 |
return NSS_STATUS_UNKNOWN;
|
|
|
96dc52 |
}
|
|
|
96dc52 |
|
|
|
96dc52 |
- m_key = malloc(strlen(ap->path) + strlen(MM_ROOT(me)->key) + 2);
|
|
|
96dc52 |
+ m_key = malloc(ap->len + strlen(MM_ROOT(me)->key) + 2);
|
|
|
96dc52 |
if (!m_key) {
|
|
|
96dc52 |
error(ap->logopt,
|
|
|
96dc52 |
"failed to allocate storage for search key");
|
|
|
96dc52 |
diff --git a/daemon/master.c b/daemon/master.c
|
|
|
96dc52 |
index da527a61..022fb9dd 100644
|
|
|
96dc52 |
--- a/daemon/master.c
|
|
|
96dc52 |
+++ b/daemon/master.c
|
|
|
96dc52 |
@@ -86,6 +86,7 @@ int master_add_autofs_point(struct master_mapent *entry, unsigned logopt,
|
|
|
96dc52 |
free(ap);
|
|
|
96dc52 |
return 0;
|
|
|
96dc52 |
}
|
|
|
96dc52 |
+ ap->len = strlen(ap->path);
|
|
|
96dc52 |
ap->pref = NULL;
|
|
|
96dc52 |
|
|
|
96dc52 |
ap->entry = entry;
|
|
|
96dc52 |
diff --git a/include/automount.h b/include/automount.h
|
|
|
96dc52 |
index e917515b..34485859 100644
|
|
|
96dc52 |
--- a/include/automount.h
|
|
|
96dc52 |
+++ b/include/automount.h
|
|
|
96dc52 |
@@ -548,6 +548,7 @@ struct kernel_mod_version {
|
|
|
96dc52 |
struct autofs_point {
|
|
|
96dc52 |
pthread_t thid;
|
|
|
96dc52 |
char *path; /* Mount point name */
|
|
|
96dc52 |
+ size_t len; /* Length of mount point name */
|
|
|
96dc52 |
mode_t mode; /* Mount point mode */
|
|
|
96dc52 |
char *pref; /* amd prefix */
|
|
|
96dc52 |
int pipefd; /* File descriptor for pipe */
|
|
|
96dc52 |
diff --git a/lib/mounts.c b/lib/mounts.c
|
|
|
96dc52 |
index f6f20fc0..b478ecb4 100644
|
|
|
96dc52 |
--- a/lib/mounts.c
|
|
|
96dc52 |
+++ b/lib/mounts.c
|
|
|
96dc52 |
@@ -1158,7 +1158,7 @@ struct mnt_list *mnts_add_mount(struct autofs_point *ap,
|
|
|
96dc52 |
if (!mp)
|
|
|
96dc52 |
goto fail;
|
|
|
96dc52 |
} else {
|
|
|
96dc52 |
- int len = strlen(ap->path) + strlen(name) + 2;
|
|
|
96dc52 |
+ int len = ap->len + strlen(name) + 2;
|
|
|
96dc52 |
|
|
|
96dc52 |
mp = malloc(len);
|
|
|
96dc52 |
if (!mp)
|
|
|
96dc52 |
@@ -2495,9 +2495,9 @@ static int rmdir_path_offset(struct autofs_point *ap, struct mapent *oe)
|
|
|
96dc52 |
dir = strdup(oe->key);
|
|
|
96dc52 |
|
|
|
96dc52 |
if (ap->flags & MOUNT_FLAG_GHOST)
|
|
|
96dc52 |
- split = strlen(ap->path) + strlen(MM_ROOT(oe)->key) + 1;
|
|
|
96dc52 |
+ split = ap->len + strlen(MM_ROOT(oe)->key) + 1;
|
|
|
96dc52 |
else
|
|
|
96dc52 |
- split = strlen(ap->path);
|
|
|
96dc52 |
+ split = ap->len;
|
|
|
96dc52 |
|
|
|
96dc52 |
dir[split] = '\0';
|
|
|
96dc52 |
path = &dir[split + 1];
|
|
|
96dc52 |
diff --git a/modules/parse_amd.c b/modules/parse_amd.c
|
|
|
96dc52 |
index d3e8a450..5a9079d6 100644
|
|
|
96dc52 |
--- a/modules/parse_amd.c
|
|
|
96dc52 |
+++ b/modules/parse_amd.c
|
|
|
96dc52 |
@@ -147,7 +147,7 @@ static struct substvar *add_lookup_vars(struct autofs_point *ap,
|
|
|
96dc52 |
struct mapent *me;
|
|
|
96dc52 |
int len;
|
|
|
96dc52 |
|
|
|
96dc52 |
- len = strlen(ap->path) + 1 + key_len + 1;
|
|
|
96dc52 |
+ len = ap->len + 1 + key_len + 1;
|
|
|
96dc52 |
if (len > PATH_MAX) {
|
|
|
96dc52 |
error(ap->logopt, MODPREFIX
|
|
|
96dc52 |
"error: lookup key is greater than PATH_MAX");
|
|
|
96dc52 |
@@ -1319,7 +1319,7 @@ static int do_host_mount(struct autofs_point *ap, const char *name,
|
|
|
96dc52 |
char *target;
|
|
|
96dc52 |
size_t len;
|
|
|
96dc52 |
|
|
|
96dc52 |
- len = strlen(ap->path) + strlen(entry->rhost) + 2;
|
|
|
96dc52 |
+ len = ap->len + strlen(entry->rhost) + 2;
|
|
|
96dc52 |
target = malloc(len);
|
|
|
96dc52 |
if (!target) {
|
|
|
96dc52 |
warn(ap->logopt, MODPREFIX
|
|
|
96dc52 |
diff --git a/modules/parse_sun.c b/modules/parse_sun.c
|
|
|
96dc52 |
index b11c6693..b1f64ca0 100644
|
|
|
96dc52 |
--- a/modules/parse_sun.c
|
|
|
96dc52 |
+++ b/modules/parse_sun.c
|
|
|
96dc52 |
@@ -1154,7 +1154,7 @@ static int mount_subtree(struct autofs_point *ap, struct mapent_cache *mc,
|
|
|
96dc52 |
mm_root = mm_key;
|
|
|
96dc52 |
start = strlen(mm_key);
|
|
|
96dc52 |
} else {
|
|
|
96dc52 |
- start = strlen(ap->path) + strlen(mm_key) + 1;
|
|
|
96dc52 |
+ start = ap->len + strlen(mm_key) + 1;
|
|
|
96dc52 |
mm_root = alloca(start + 3);
|
|
|
96dc52 |
strcpy(mm_root, ap->path);
|
|
|
96dc52 |
strcat(mm_root, "/");
|
|
|
96dc52 |
@@ -1477,7 +1477,7 @@ dont_expand:
|
|
|
96dc52 |
}
|
|
|
96dc52 |
strcpy(m_root, name);
|
|
|
96dc52 |
} else {
|
|
|
96dc52 |
- m_root_len = strlen(ap->path) + name_len + 1;
|
|
|
96dc52 |
+ m_root_len = ap->len + name_len + 1;
|
|
|
96dc52 |
m_root = alloca(m_root_len + 1);
|
|
|
96dc52 |
if (!m_root) {
|
|
|
96dc52 |
char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
|