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

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