Blame SOURCES/autofs-5.1.7-pass-root-length-to-mount_fullpath.patch

beb904
autofs-5.1.7 - pass root length to mount_fullpath()
beb904
beb904
From: Ian Kent <raven@themaw.net>
beb904
beb904
The length of root may already be known, add a parameter to allow
beb904
passing it to mount_fullpath() so a strlen() call can be avoided.
beb904
beb904
Signed-off-by: Ian Kent <raven@themaw.net>
beb904
---
beb904
 CHANGELOG               |    1 +
beb904
 include/mounts.h        |    2 +-
beb904
 lib/mounts.c            |   11 +++++++----
beb904
 modules/mount_bind.c    |    2 +-
beb904
 modules/mount_changer.c |    2 +-
beb904
 modules/mount_ext2.c    |    2 +-
beb904
 modules/mount_generic.c |    2 +-
beb904
 modules/mount_nfs.c     |    2 +-
beb904
 modules/parse_sun.c     |    4 ++--
beb904
 9 files changed, 16 insertions(+), 12 deletions(-)
beb904
beb904
--- autofs-5.1.4.orig/CHANGELOG
beb904
+++ autofs-5.1.4/CHANGELOG
beb904
@@ -44,6 +44,7 @@
beb904
 - remove obsolete functions.
beb904
 - remove redundant local var from sun_mount().
beb904
 - use mount_fullpath() in one spot in parse_mount().
beb904
+- pass root length to mount_fullpath().
beb904
 
beb904
 xx/xx/2018 autofs-5.1.5
beb904
 - fix flag file permission.
beb904
--- autofs-5.1.4.orig/include/mounts.h
beb904
+++ autofs-5.1.4/include/mounts.h
beb904
@@ -131,7 +131,7 @@ int check_nfs_mount_version(struct nfs_m
beb904
 extern unsigned int nfs_mount_uses_string_options;
beb904
 
beb904
 int mount_fullpath(char *fullpath, size_t max_len,
beb904
-		   const char *root, const char *name);
beb904
+		   const char *root, size_t root_len, const char *name);
beb904
 
beb904
 struct amd_entry;
beb904
 
beb904
--- autofs-5.1.4.orig/lib/mounts.c
beb904
+++ autofs-5.1.4/lib/mounts.c
beb904
@@ -362,11 +362,14 @@ int check_nfs_mount_version(struct nfs_m
beb904
 #endif
beb904
 
beb904
 int mount_fullpath(char *fullpath, size_t max_len,
beb904
-		   const char *root, const char *name)
beb904
+		   const char *root, size_t root_len, const char *name)
beb904
 {
beb904
 	int last, len;
beb904
 
beb904
-	last = strlen(root) - 1;
beb904
+	if (root_len)
beb904
+		last = root_len - 1;
beb904
+	else
beb904
+		last = strlen(root) - 1;
beb904
 
beb904
 	/* Root offset of multi-mount or direct or offset mount.
beb904
 	 * Direct or offset mount, name (or root) is absolute path.
beb904
@@ -1685,7 +1688,7 @@ void tree_mapent_cleanup_offsets(struct
beb904
 	else {
beb904
 		char mp[PATH_MAX + 1];
beb904
 
beb904
-		if (!mount_fullpath(mp, PATH_MAX, ap->path, oe->key))
beb904
+		if (!mount_fullpath(mp, PATH_MAX, ap->path, ap->len, oe->key))
beb904
 			error(ap->logopt, "mount path is too long");
beb904
 		else
beb904
 			tree_mapent_umount_mount(ap, mp);
beb904
@@ -1922,7 +1925,7 @@ int tree_mapent_umount_offsets(struct ma
beb904
 		 * one of these keys is the root of a multi-mount the mount
beb904
 		 * path must be constructed.
beb904
 		 */
beb904
-		if (!mount_fullpath(mp, PATH_MAX, ap->path, oe->key)) {
beb904
+		if (!mount_fullpath(mp, PATH_MAX, ap->path, ap->len, oe->key)) {
beb904
 			error(ap->logopt, "mount path is too long");
beb904
 			return 0;
beb904
 		}
beb904
--- autofs-5.1.4.orig/modules/mount_bind.c
beb904
+++ autofs-5.1.4/modules/mount_bind.c
beb904
@@ -122,7 +122,7 @@ int mount_mount(struct autofs_point *ap,
beb904
 		}
beb904
 	}
beb904
 
beb904
-	len = mount_fullpath(fullpath, PATH_MAX, root, name);
beb904
+	len = mount_fullpath(fullpath, PATH_MAX, root, 0, name);
beb904
 	if (!len) {
beb904
 		error(ap->logopt,
beb904
 		      MODPREFIX "mount point path too long");
beb904
--- autofs-5.1.4.orig/modules/mount_changer.c
beb904
+++ autofs-5.1.4/modules/mount_changer.c
beb904
@@ -59,7 +59,7 @@ int mount_mount(struct autofs_point *ap,
beb904
 
beb904
 	fstype = "iso9660";
beb904
 
beb904
-	len = mount_fullpath(fullpath, PATH_MAX, root, name);
beb904
+	len = mount_fullpath(fullpath, PATH_MAX, root, 0, name);
beb904
 	if (!len) {
beb904
 		error(ap->logopt,
beb904
 		      MODPREFIX "mount point path too long");
beb904
--- autofs-5.1.4.orig/modules/mount_ext2.c
beb904
+++ autofs-5.1.4/modules/mount_ext2.c
beb904
@@ -55,7 +55,7 @@ int mount_mount(struct autofs_point *ap,
beb904
 	if (defaults_get_mount_verbose())
beb904
 		mountlog = &log_info;
beb904
 
beb904
-	len = mount_fullpath(fullpath, PATH_MAX, root, name);
beb904
+	len = mount_fullpath(fullpath, PATH_MAX, root, 0, name);
beb904
 	if (!len) {
beb904
 		error(ap->logopt,
beb904
 		      MODPREFIX "mount point path too long");
beb904
--- autofs-5.1.4.orig/modules/mount_generic.c
beb904
+++ autofs-5.1.4/modules/mount_generic.c
beb904
@@ -54,7 +54,7 @@ int mount_mount(struct autofs_point *ap,
beb904
 	if (defaults_get_mount_verbose())
beb904
 		mountlog = &log_info;
beb904
 
beb904
-	len = mount_fullpath(fullpath, PATH_MAX, root, name);
beb904
+	len = mount_fullpath(fullpath, PATH_MAX, root, 0, name);
beb904
 	if (!len) {
beb904
 		error(ap->logopt,
beb904
 		      MODPREFIX "mount point path too long");
beb904
--- autofs-5.1.4.orig/modules/mount_nfs.c
beb904
+++ autofs-5.1.4/modules/mount_nfs.c
beb904
@@ -213,7 +213,7 @@ int mount_mount(struct autofs_point *ap,
beb904
 	}
beb904
 
beb904
 	/* Construct mount point directory */
beb904
-	len = mount_fullpath(fullpath, PATH_MAX, root, name);
beb904
+	len = mount_fullpath(fullpath, PATH_MAX, root, 0, name);
beb904
 	if (!len) {
beb904
 		error(ap->logopt,
beb904
 		      MODPREFIX "mount point path too long");
beb904
--- autofs-5.1.4.orig/modules/parse_sun.c
beb904
+++ autofs-5.1.4/modules/parse_sun.c
beb904
@@ -1091,7 +1091,7 @@ static int mount_subtree(struct autofs_p
beb904
 		struct mapent *ro;
beb904
 		size_t len;
beb904
 
beb904
-		len = mount_fullpath(key, PATH_MAX, ap->path, me->key);
beb904
+		len = mount_fullpath(key, PATH_MAX, ap->path, ap->len, me->key);
beb904
 		if (!len) {
beb904
 			warn(ap->logopt, "path loo long");
beb904
 			return 1;
beb904
@@ -1361,7 +1361,7 @@ dont_expand:
beb904
 		time_t age;
beb904
 		int l;
beb904
 
beb904
-		m_root_len = mount_fullpath(m_root, PATH_MAX, ap->path, name);
beb904
+		m_root_len = mount_fullpath(m_root, PATH_MAX, ap->path, ap->len, name);
beb904
 		if (!m_root_len) {
beb904
 			error(ap->logopt,
beb904
 			      MODPREFIX "multi-mount root path too long");