|
|
96dc52 |
autofs-5.1.7 - pass root length to mount_fullpath()
|
|
|
96dc52 |
|
|
|
96dc52 |
From: Ian Kent <raven@themaw.net>
|
|
|
96dc52 |
|
|
|
96dc52 |
The length of root may already be known, add a parameter to allow
|
|
|
96dc52 |
passing it to mount_fullpath() so a strlen() call can be avoided.
|
|
|
96dc52 |
|
|
|
96dc52 |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
96dc52 |
---
|
|
|
96dc52 |
CHANGELOG | 1 +
|
|
|
96dc52 |
include/mounts.h | 2 +-
|
|
|
96dc52 |
lib/mounts.c | 11 +++++++----
|
|
|
96dc52 |
modules/mount_bind.c | 2 +-
|
|
|
96dc52 |
modules/mount_changer.c | 2 +-
|
|
|
96dc52 |
modules/mount_ext2.c | 2 +-
|
|
|
96dc52 |
modules/mount_generic.c | 2 +-
|
|
|
96dc52 |
modules/mount_nfs.c | 2 +-
|
|
|
96dc52 |
modules/parse_sun.c | 4 ++--
|
|
|
96dc52 |
9 files changed, 16 insertions(+), 12 deletions(-)
|
|
|
96dc52 |
|
|
|
96dc52 |
diff --git a/CHANGELOG b/CHANGELOG
|
|
|
96dc52 |
index 8494f0dc..1c9e2a2d 100644
|
|
|
96dc52 |
--- a/CHANGELOG
|
|
|
96dc52 |
+++ b/CHANGELOG
|
|
|
96dc52 |
@@ -44,6 +44,7 @@
|
|
|
96dc52 |
- remove obsolete functions.
|
|
|
96dc52 |
- remove redundant local var from sun_mount().
|
|
|
96dc52 |
- use mount_fullpath() in one spot in parse_mount().
|
|
|
96dc52 |
+- pass root length to mount_fullpath().
|
|
|
96dc52 |
|
|
|
96dc52 |
25/01/2021 autofs-5.1.7
|
|
|
96dc52 |
- make bind mounts propagation slave by default.
|
|
|
96dc52 |
diff --git a/include/mounts.h b/include/mounts.h
|
|
|
96dc52 |
index ec895e1c..d7980976 100644
|
|
|
96dc52 |
--- a/include/mounts.h
|
|
|
96dc52 |
+++ b/include/mounts.h
|
|
|
96dc52 |
@@ -131,7 +131,7 @@ int check_nfs_mount_version(struct nfs_mount_vers *, struct nfs_mount_vers *);
|
|
|
96dc52 |
extern unsigned int nfs_mount_uses_string_options;
|
|
|
96dc52 |
|
|
|
96dc52 |
int mount_fullpath(char *fullpath, size_t max_len,
|
|
|
96dc52 |
- const char *root, const char *name);
|
|
|
96dc52 |
+ const char *root, size_t root_len, const char *name);
|
|
|
96dc52 |
|
|
|
96dc52 |
struct amd_entry;
|
|
|
96dc52 |
|
|
|
96dc52 |
diff --git a/lib/mounts.c b/lib/mounts.c
|
|
|
96dc52 |
index c120d2a8..6b8e4c92 100644
|
|
|
96dc52 |
--- a/lib/mounts.c
|
|
|
96dc52 |
+++ b/lib/mounts.c
|
|
|
96dc52 |
@@ -362,11 +362,14 @@ int check_nfs_mount_version(struct nfs_mount_vers *vers,
|
|
|
96dc52 |
#endif
|
|
|
96dc52 |
|
|
|
96dc52 |
int mount_fullpath(char *fullpath, size_t max_len,
|
|
|
96dc52 |
- const char *root, const char *name)
|
|
|
96dc52 |
+ const char *root, size_t root_len, const char *name)
|
|
|
96dc52 |
{
|
|
|
96dc52 |
int last, len;
|
|
|
96dc52 |
|
|
|
96dc52 |
- last = strlen(root) - 1;
|
|
|
96dc52 |
+ if (root_len)
|
|
|
96dc52 |
+ last = root_len - 1;
|
|
|
96dc52 |
+ else
|
|
|
96dc52 |
+ last = strlen(root) - 1;
|
|
|
96dc52 |
|
|
|
96dc52 |
/* Root offset of multi-mount or direct or offset mount.
|
|
|
96dc52 |
* Direct or offset mount, name (or root) is absolute path.
|
|
|
96dc52 |
@@ -1685,7 +1688,7 @@ void tree_mapent_cleanup_offsets(struct mapent *oe)
|
|
|
96dc52 |
else {
|
|
|
96dc52 |
char mp[PATH_MAX + 1];
|
|
|
96dc52 |
|
|
|
96dc52 |
- if (!mount_fullpath(mp, PATH_MAX, ap->path, oe->key))
|
|
|
96dc52 |
+ if (!mount_fullpath(mp, PATH_MAX, ap->path, ap->len, oe->key))
|
|
|
96dc52 |
error(ap->logopt, "mount path is too long");
|
|
|
96dc52 |
else
|
|
|
96dc52 |
tree_mapent_umount_mount(ap, mp);
|
|
|
96dc52 |
@@ -1922,7 +1925,7 @@ int tree_mapent_umount_offsets(struct mapent *oe, int nonstrict)
|
|
|
96dc52 |
* one of these keys is the root of a multi-mount the mount
|
|
|
96dc52 |
* path must be constructed.
|
|
|
96dc52 |
*/
|
|
|
96dc52 |
- if (!mount_fullpath(mp, PATH_MAX, ap->path, oe->key)) {
|
|
|
96dc52 |
+ if (!mount_fullpath(mp, PATH_MAX, ap->path, ap->len, oe->key)) {
|
|
|
96dc52 |
error(ap->logopt, "mount path is too long");
|
|
|
96dc52 |
return 0;
|
|
|
96dc52 |
}
|
|
|
96dc52 |
diff --git a/modules/mount_bind.c b/modules/mount_bind.c
|
|
|
96dc52 |
index c17c6f18..7f64332b 100644
|
|
|
96dc52 |
--- a/modules/mount_bind.c
|
|
|
96dc52 |
+++ b/modules/mount_bind.c
|
|
|
96dc52 |
@@ -122,7 +122,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
|
|
|
96dc52 |
}
|
|
|
96dc52 |
}
|
|
|
96dc52 |
|
|
|
96dc52 |
- len = mount_fullpath(fullpath, PATH_MAX, root, name);
|
|
|
96dc52 |
+ len = mount_fullpath(fullpath, PATH_MAX, root, 0, name);
|
|
|
96dc52 |
if (!len) {
|
|
|
96dc52 |
error(ap->logopt,
|
|
|
96dc52 |
MODPREFIX "mount point path too long");
|
|
|
96dc52 |
diff --git a/modules/mount_changer.c b/modules/mount_changer.c
|
|
|
96dc52 |
index d02b5f45..8adb9f9a 100644
|
|
|
96dc52 |
--- a/modules/mount_changer.c
|
|
|
96dc52 |
+++ b/modules/mount_changer.c
|
|
|
96dc52 |
@@ -59,7 +59,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
|
|
|
96dc52 |
|
|
|
96dc52 |
fstype = "iso9660";
|
|
|
96dc52 |
|
|
|
96dc52 |
- len = mount_fullpath(fullpath, PATH_MAX, root, name);
|
|
|
96dc52 |
+ len = mount_fullpath(fullpath, PATH_MAX, root, 0, name);
|
|
|
96dc52 |
if (!len) {
|
|
|
96dc52 |
error(ap->logopt,
|
|
|
96dc52 |
MODPREFIX "mount point path too long");
|
|
|
96dc52 |
diff --git a/modules/mount_ext2.c b/modules/mount_ext2.c
|
|
|
96dc52 |
index 53e6ee10..f4002e58 100644
|
|
|
96dc52 |
--- a/modules/mount_ext2.c
|
|
|
96dc52 |
+++ b/modules/mount_ext2.c
|
|
|
96dc52 |
@@ -55,7 +55,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
|
|
|
96dc52 |
if (defaults_get_mount_verbose())
|
|
|
96dc52 |
mountlog = &log_info;
|
|
|
96dc52 |
|
|
|
96dc52 |
- len = mount_fullpath(fullpath, PATH_MAX, root, name);
|
|
|
96dc52 |
+ len = mount_fullpath(fullpath, PATH_MAX, root, 0, name);
|
|
|
96dc52 |
if (!len) {
|
|
|
96dc52 |
error(ap->logopt,
|
|
|
96dc52 |
MODPREFIX "mount point path too long");
|
|
|
96dc52 |
diff --git a/modules/mount_generic.c b/modules/mount_generic.c
|
|
|
96dc52 |
index c9deb7ae..8cd0f4ab 100644
|
|
|
96dc52 |
--- a/modules/mount_generic.c
|
|
|
96dc52 |
+++ b/modules/mount_generic.c
|
|
|
96dc52 |
@@ -54,7 +54,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
|
|
|
96dc52 |
if (defaults_get_mount_verbose())
|
|
|
96dc52 |
mountlog = &log_info;
|
|
|
96dc52 |
|
|
|
96dc52 |
- len = mount_fullpath(fullpath, PATH_MAX, root, name);
|
|
|
96dc52 |
+ len = mount_fullpath(fullpath, PATH_MAX, root, 0, name);
|
|
|
96dc52 |
if (!len) {
|
|
|
96dc52 |
error(ap->logopt,
|
|
|
96dc52 |
MODPREFIX "mount point path too long");
|
|
|
96dc52 |
diff --git a/modules/mount_nfs.c b/modules/mount_nfs.c
|
|
|
96dc52 |
index c70210f4..0314a78f 100644
|
|
|
96dc52 |
--- a/modules/mount_nfs.c
|
|
|
96dc52 |
+++ b/modules/mount_nfs.c
|
|
|
96dc52 |
@@ -213,7 +213,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
|
|
|
96dc52 |
}
|
|
|
96dc52 |
|
|
|
96dc52 |
/* Construct mount point directory */
|
|
|
96dc52 |
- len = mount_fullpath(fullpath, PATH_MAX, root, name);
|
|
|
96dc52 |
+ len = mount_fullpath(fullpath, PATH_MAX, root, 0, name);
|
|
|
96dc52 |
if (!len) {
|
|
|
96dc52 |
error(ap->logopt,
|
|
|
96dc52 |
MODPREFIX "mount point path too long");
|
|
|
96dc52 |
diff --git a/modules/parse_sun.c b/modules/parse_sun.c
|
|
|
96dc52 |
index d3fc6c7f..b1c2611c 100644
|
|
|
96dc52 |
--- a/modules/parse_sun.c
|
|
|
96dc52 |
+++ b/modules/parse_sun.c
|
|
|
96dc52 |
@@ -1089,7 +1089,7 @@ static int mount_subtree(struct autofs_point *ap, struct mapent_cache *mc,
|
|
|
96dc52 |
struct mapent *ro;
|
|
|
96dc52 |
size_t len;
|
|
|
96dc52 |
|
|
|
96dc52 |
- len = mount_fullpath(key, PATH_MAX, ap->path, me->key);
|
|
|
96dc52 |
+ len = mount_fullpath(key, PATH_MAX, ap->path, ap->len, me->key);
|
|
|
96dc52 |
if (!len) {
|
|
|
96dc52 |
warn(ap->logopt, "path loo long");
|
|
|
96dc52 |
return 1;
|
|
|
96dc52 |
@@ -1359,7 +1359,7 @@ dont_expand:
|
|
|
96dc52 |
time_t age;
|
|
|
96dc52 |
int l;
|
|
|
96dc52 |
|
|
|
96dc52 |
- m_root_len = mount_fullpath(m_root, PATH_MAX, ap->path, name);
|
|
|
96dc52 |
+ m_root_len = mount_fullpath(m_root, PATH_MAX, ap->path, ap->len, name);
|
|
|
96dc52 |
if (!m_root_len) {
|
|
|
96dc52 |
error(ap->logopt,
|
|
|
96dc52 |
MODPREFIX "multi-mount root path too long");
|