|
|
beb904 |
autofs-5.1.7 - add a len field to struct autofs_point
|
|
|
beb904 |
|
|
|
beb904 |
From: Ian Kent <raven@themaw.net>
|
|
|
beb904 |
|
|
|
beb904 |
Add a path length field to struct autofs_point since the path length
|
|
|
beb904 |
is needed at various times avoiding additional strlen() calls.
|
|
|
beb904 |
|
|
|
beb904 |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
beb904 |
---
|
|
|
beb904 |
CHANGELOG | 1 +
|
|
|
beb904 |
daemon/lookup.c | 2 +-
|
|
|
beb904 |
daemon/master.c | 1 +
|
|
|
beb904 |
include/automount.h | 1 +
|
|
|
beb904 |
lib/mounts.c | 6 +++---
|
|
|
beb904 |
modules/parse_amd.c | 4 ++--
|
|
|
beb904 |
modules/parse_sun.c | 4 ++--
|
|
|
beb904 |
7 files changed, 11 insertions(+), 8 deletions(-)
|
|
|
beb904 |
|
|
|
beb904 |
--- autofs-5.1.4.orig/CHANGELOG
|
|
|
beb904 |
+++ autofs-5.1.4/CHANGELOG
|
|
|
beb904 |
@@ -30,6 +30,7 @@
|
|
|
beb904 |
- fix program map multi-mount lookup after mount fail.
|
|
|
beb904 |
- add some multi-mount macros.
|
|
|
beb904 |
- remove unused functions cache_dump_multi() and cache_dump_cache().
|
|
|
beb904 |
+- add a len field to struct autofs_point.
|
|
|
beb904 |
|
|
|
beb904 |
xx/xx/2018 autofs-5.1.5
|
|
|
beb904 |
- fix flag file permission.
|
|
|
beb904 |
--- autofs-5.1.4.orig/daemon/lookup.c
|
|
|
beb904 |
+++ autofs-5.1.4/daemon/lookup.c
|
|
|
beb904 |
@@ -851,7 +851,7 @@ static int lookup_amd_instance(struct au
|
|
|
beb904 |
return NSS_STATUS_UNKNOWN;
|
|
|
beb904 |
}
|
|
|
beb904 |
|
|
|
beb904 |
- m_key = malloc(strlen(ap->path) + strlen(MM_ROOT(me)->key) + 2);
|
|
|
beb904 |
+ m_key = malloc(ap->len + strlen(MM_ROOT(me)->key) + 2);
|
|
|
beb904 |
if (!m_key) {
|
|
|
beb904 |
error(ap->logopt,
|
|
|
beb904 |
"failed to allocate storage for search key");
|
|
|
beb904 |
--- autofs-5.1.4.orig/daemon/master.c
|
|
|
beb904 |
+++ autofs-5.1.4/daemon/master.c
|
|
|
beb904 |
@@ -86,6 +86,7 @@ int master_add_autofs_point(struct maste
|
|
|
beb904 |
free(ap);
|
|
|
beb904 |
return 0;
|
|
|
beb904 |
}
|
|
|
beb904 |
+ ap->len = strlen(ap->path);
|
|
|
beb904 |
ap->pref = NULL;
|
|
|
beb904 |
|
|
|
beb904 |
ap->entry = entry;
|
|
|
beb904 |
--- autofs-5.1.4.orig/include/automount.h
|
|
|
beb904 |
+++ autofs-5.1.4/include/automount.h
|
|
|
beb904 |
@@ -547,6 +547,7 @@ struct kernel_mod_version {
|
|
|
beb904 |
struct autofs_point {
|
|
|
beb904 |
pthread_t thid;
|
|
|
beb904 |
char *path; /* Mount point name */
|
|
|
beb904 |
+ size_t len; /* Length of mount point name */
|
|
|
beb904 |
mode_t mode; /* Mount point mode */
|
|
|
beb904 |
char *pref; /* amd prefix */
|
|
|
beb904 |
int pipefd; /* File descriptor for pipe */
|
|
|
beb904 |
--- autofs-5.1.4.orig/lib/mounts.c
|
|
|
beb904 |
+++ autofs-5.1.4/lib/mounts.c
|
|
|
beb904 |
@@ -1158,7 +1158,7 @@ struct mnt_list *mnts_add_mount(struct a
|
|
|
beb904 |
if (!mp)
|
|
|
beb904 |
goto fail;
|
|
|
beb904 |
} else {
|
|
|
beb904 |
- int len = strlen(ap->path) + strlen(name) + 2;
|
|
|
beb904 |
+ int len = ap->len + strlen(name) + 2;
|
|
|
beb904 |
|
|
|
beb904 |
mp = malloc(len);
|
|
|
beb904 |
if (!mp)
|
|
|
beb904 |
@@ -2489,9 +2489,9 @@ static int rmdir_path_offset(struct auto
|
|
|
beb904 |
dir = strdup(oe->key);
|
|
|
beb904 |
|
|
|
beb904 |
if (ap->flags & MOUNT_FLAG_GHOST)
|
|
|
beb904 |
- split = strlen(ap->path) + strlen(MM_ROOT(oe)->key) + 1;
|
|
|
beb904 |
+ split = ap->len + strlen(MM_ROOT(oe)->key) + 1;
|
|
|
beb904 |
else
|
|
|
beb904 |
- split = strlen(ap->path);
|
|
|
beb904 |
+ split = ap->len;
|
|
|
beb904 |
|
|
|
beb904 |
dir[split] = '\0';
|
|
|
beb904 |
path = &dir[split + 1];
|
|
|
beb904 |
--- autofs-5.1.4.orig/modules/parse_amd.c
|
|
|
beb904 |
+++ autofs-5.1.4/modules/parse_amd.c
|
|
|
beb904 |
@@ -147,7 +147,7 @@ static struct substvar *add_lookup_vars(
|
|
|
beb904 |
struct mapent *me;
|
|
|
beb904 |
int len;
|
|
|
beb904 |
|
|
|
beb904 |
- len = strlen(ap->path) + 1 + key_len + 1;
|
|
|
beb904 |
+ len = ap->len + 1 + key_len + 1;
|
|
|
beb904 |
if (len > PATH_MAX) {
|
|
|
beb904 |
error(ap->logopt, MODPREFIX
|
|
|
beb904 |
"error: lookup key is greater than PATH_MAX");
|
|
|
beb904 |
@@ -1319,7 +1319,7 @@ static int do_host_mount(struct autofs_p
|
|
|
beb904 |
char *target;
|
|
|
beb904 |
size_t len;
|
|
|
beb904 |
|
|
|
beb904 |
- len = strlen(ap->path) + strlen(entry->rhost) + 2;
|
|
|
beb904 |
+ len = ap->len + strlen(entry->rhost) + 2;
|
|
|
beb904 |
target = malloc(len);
|
|
|
beb904 |
if (!target) {
|
|
|
beb904 |
warn(ap->logopt, MODPREFIX
|
|
|
beb904 |
--- autofs-5.1.4.orig/modules/parse_sun.c
|
|
|
beb904 |
+++ autofs-5.1.4/modules/parse_sun.c
|
|
|
beb904 |
@@ -1156,7 +1156,7 @@ static int mount_subtree(struct autofs_p
|
|
|
beb904 |
mm_root = mm_key;
|
|
|
beb904 |
start = strlen(mm_key);
|
|
|
beb904 |
} else {
|
|
|
beb904 |
- start = strlen(ap->path) + strlen(mm_key) + 1;
|
|
|
beb904 |
+ start = ap->len + strlen(mm_key) + 1;
|
|
|
beb904 |
mm_root = alloca(start + 3);
|
|
|
beb904 |
strcpy(mm_root, ap->path);
|
|
|
beb904 |
strcat(mm_root, "/");
|
|
|
beb904 |
@@ -1479,7 +1479,7 @@ dont_expand:
|
|
|
beb904 |
}
|
|
|
beb904 |
strcpy(m_root, name);
|
|
|
beb904 |
} else {
|
|
|
beb904 |
- m_root_len = strlen(ap->path) + name_len + 1;
|
|
|
beb904 |
+ m_root_len = ap->len + name_len + 1;
|
|
|
beb904 |
m_root = alloca(m_root_len + 1);
|
|
|
beb904 |
if (!m_root) {
|
|
|
beb904 |
char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
|