|
|
9a499a |
autofs-5.1.7 - eliminate some strlen calls in offset handling
|
|
|
9a499a |
|
|
|
9a499a |
From: Ian Kent <raven@themaw.net>
|
|
|
9a499a |
|
|
|
9a499a |
There are a number of places where strlen() is used to re-calculate
|
|
|
9a499a |
the length of a string. Eliminate some of those by calculating the
|
|
|
9a499a |
length once and passing it to the functions that do the re-calculation.
|
|
|
9a499a |
|
|
|
9a499a |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
9a499a |
---
|
|
|
9a499a |
CHANGELOG | 1 +
|
|
|
9a499a |
lib/mounts.c | 30 +++++++++++++++++-------------
|
|
|
9a499a |
2 files changed, 18 insertions(+), 13 deletions(-)
|
|
|
9a499a |
|
|
|
9a499a |
--- autofs-5.1.4.orig/CHANGELOG
|
|
|
9a499a |
+++ autofs-5.1.4/CHANGELOG
|
|
|
9a499a |
@@ -20,6 +20,7 @@
|
|
|
9a499a |
- fix inconsistent locking in parse_mount().
|
|
|
9a499a |
- remove unused mount offset list lock functions.
|
|
|
9a499a |
- eliminate count_mounts() from expire_proc_indirect().
|
|
|
9a499a |
+- eliminate some strlen calls in offset handling.
|
|
|
9a499a |
|
|
|
9a499a |
xx/xx/2018 autofs-5.1.5
|
|
|
9a499a |
- fix flag file permission.
|
|
|
9a499a |
--- autofs-5.1.4.orig/lib/mounts.c
|
|
|
9a499a |
+++ autofs-5.1.4/lib/mounts.c
|
|
|
9a499a |
@@ -2534,10 +2534,12 @@ static int rmdir_path_offset(struct auto
|
|
|
9a499a |
return ret;
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
-static int do_umount_offset(struct autofs_point *ap, struct mapent *oe, const char *root);
|
|
|
9a499a |
+static int do_umount_offset(struct autofs_point *ap,
|
|
|
9a499a |
+ struct mapent *oe, const char *root, int start);
|
|
|
9a499a |
|
|
|
9a499a |
static int do_umount_multi_triggers(struct autofs_point *ap,
|
|
|
9a499a |
- struct mapent *me, const char *root, const char *base)
|
|
|
9a499a |
+ struct mapent *me, const char *root,
|
|
|
9a499a |
+ int start, const char *base)
|
|
|
9a499a |
{
|
|
|
9a499a |
char path[PATH_MAX + 1];
|
|
|
9a499a |
char *offset;
|
|
|
9a499a |
@@ -2545,12 +2547,11 @@ static int do_umount_multi_triggers(stru
|
|
|
9a499a |
struct list_head *mm_root, *pos;
|
|
|
9a499a |
const char o_root[] = "/";
|
|
|
9a499a |
const char *mm_base;
|
|
|
9a499a |
- int left, start;
|
|
|
9a499a |
+ int left;
|
|
|
9a499a |
unsigned int root_len;
|
|
|
9a499a |
unsigned int mm_base_len;
|
|
|
9a499a |
|
|
|
9a499a |
left = 0;
|
|
|
9a499a |
- start = strlen(root);
|
|
|
9a499a |
|
|
|
9a499a |
mm_root = &me->multi->multi_list;
|
|
|
9a499a |
|
|
|
9a499a |
@@ -2586,13 +2587,14 @@ static int do_umount_multi_triggers(stru
|
|
|
9a499a |
if (!oe || (strlen(oe->key) - start) == 1)
|
|
|
9a499a |
continue;
|
|
|
9a499a |
|
|
|
9a499a |
- left += do_umount_offset(ap, oe, root);
|
|
|
9a499a |
+ left += do_umount_offset(ap, oe, root, start);
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
return left;
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
-static int do_umount_offset(struct autofs_point *ap, struct mapent *oe, const char *root)
|
|
|
9a499a |
+static int do_umount_offset(struct autofs_point *ap,
|
|
|
9a499a |
+ struct mapent *oe, const char *root, int start)
|
|
|
9a499a |
{
|
|
|
9a499a |
char *oe_base;
|
|
|
9a499a |
int left = 0;
|
|
|
9a499a |
@@ -2601,8 +2603,8 @@ static int do_umount_offset(struct autof
|
|
|
9a499a |
* Check for and umount subtree offsets resulting from
|
|
|
9a499a |
* nonstrict mount fail.
|
|
|
9a499a |
*/
|
|
|
9a499a |
- oe_base = oe->key + strlen(root);
|
|
|
9a499a |
- left += do_umount_multi_triggers(ap, oe, root, oe_base);
|
|
|
9a499a |
+ oe_base = oe->key + start;
|
|
|
9a499a |
+ left += do_umount_multi_triggers(ap, oe, root, start, oe_base);
|
|
|
9a499a |
|
|
|
9a499a |
/*
|
|
|
9a499a |
* If an offset that has an active mount has been removed
|
|
|
9a499a |
@@ -2706,7 +2708,7 @@ int mount_multi_triggers(struct autofs_p
|
|
|
9a499a |
goto cont;
|
|
|
9a499a |
if (oe->age != me->multi->age) {
|
|
|
9a499a |
/* Best effort */
|
|
|
9a499a |
- do_umount_offset(ap, oe, root);
|
|
|
9a499a |
+ do_umount_offset(ap, oe, root, start);
|
|
|
9a499a |
goto cont;
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
@@ -2720,7 +2722,7 @@ int mount_multi_triggers(struct autofs_p
|
|
|
9a499a |
if (ap->state == ST_READMAP && ap->flags & MOUNT_FLAG_REMOUNT) {
|
|
|
9a499a |
if (oe->ioctlfd != -1 ||
|
|
|
9a499a |
is_mounted(oe->key, MNTS_REAL))
|
|
|
9a499a |
- mount_multi_triggers(ap, oe, key, strlen(key), base);
|
|
|
9a499a |
+ mount_multi_triggers(ap, oe, key, key_len, base);
|
|
|
9a499a |
}
|
|
|
9a499a |
cont:
|
|
|
9a499a |
offset = cache_get_offset(base,
|
|
|
9a499a |
@@ -2732,9 +2734,11 @@ cont:
|
|
|
9a499a |
|
|
|
9a499a |
int umount_multi_triggers(struct autofs_point *ap, struct mapent *me, char *root, const char *base)
|
|
|
9a499a |
{
|
|
|
9a499a |
- int left;
|
|
|
9a499a |
+ int left, start;
|
|
|
9a499a |
+
|
|
|
9a499a |
+ start = strlen(root);
|
|
|
9a499a |
|
|
|
9a499a |
- left = do_umount_multi_triggers(ap, me, root, base);
|
|
|
9a499a |
+ left = do_umount_multi_triggers(ap, me, root, start, base);
|
|
|
9a499a |
|
|
|
9a499a |
if (!left && me->multi == me) {
|
|
|
9a499a |
/*
|
|
|
9a499a |
@@ -2747,7 +2751,7 @@ int umount_multi_triggers(struct autofs_
|
|
|
9a499a |
info(ap->logopt, "unmounting dir = %s", root);
|
|
|
9a499a |
if (umount_ent(ap, root) &&
|
|
|
9a499a |
is_mounted(root, MNTS_REAL)) {
|
|
|
9a499a |
- if (mount_multi_triggers(ap, me, root, strlen(root), "/") < 0)
|
|
|
9a499a |
+ if (mount_multi_triggers(ap, me, root, start, "/") < 0)
|
|
|
9a499a |
warn(ap->logopt,
|
|
|
9a499a |
"failed to remount offset triggers");
|
|
|
9a499a |
return ++left;
|