summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2021-03-24 13:49:06 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-05-07 11:57:23 +0200
commitca7bd6183c2d0e88289725a5e516072be6d7dade (patch)
treea8fae4b260edcf7ba857fd67ff886c22037acdc5
parent0ae299022a0d7a05e6bc044f5e54f534f6cc6dbf (diff)
downloadsystemd-ca7bd6183c2d0e88289725a5e516072be6d7dade.tar.gz
path: drop simplification of path in bind_remount_recursive_with_mountinfo()
We only use path-aware comparisons and hashops, hence no need to simplify, we can use the path as it is. (cherry picked from commit c6111b85f77fa6207c0ac50a99cf5d05c2aa33c9)
-rw-r--r--src/shared/mount-util.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/src/shared/mount-util.c b/src/shared/mount-util.c
index b9f46784db..5a3d4b18d0 100644
--- a/src/shared/mount-util.c
+++ b/src/shared/mount-util.c
@@ -203,7 +203,6 @@ int bind_remount_recursive_with_mountinfo(
FILE *proc_self_mountinfo) {
_cleanup_set_free_free_ Set *done = NULL;
- _cleanup_free_ char *simplified = NULL;
unsigned n_tries = 0;
int r;
@@ -222,12 +221,6 @@ int bind_remount_recursive_with_mountinfo(
* If the "deny_list" parameter is specified it may contain a list of subtrees to exclude from the
* remount operation. Note that we'll ignore the deny list for the top-level path. */
- simplified = strdup(prefix);
- if (!simplified)
- return -ENOMEM;
-
- path_simplify(simplified, false);
-
done = set_new(&path_hash_ops);
if (!done)
return -ENOMEM;
@@ -268,26 +261,26 @@ int bind_remount_recursive_with_mountinfo(
if (!path || !type)
continue;
- if (!path_startswith(path, simplified))
+ if (!path_startswith(path, prefix))
continue;
/* Ignore this mount if it is deny-listed, but only if it isn't the top-level mount
* we shall operate on. */
- if (!path_equal(path, simplified)) {
+ if (!path_equal(path, prefix)) {
bool deny_listed = false;
char **i;
STRV_FOREACH(i, deny_list) {
- if (path_equal(*i, simplified))
+ if (path_equal(*i, prefix))
continue;
- if (!path_startswith(*i, simplified))
+ if (!path_startswith(*i, prefix))
continue;
if (path_startswith(path, *i)) {
deny_listed = true;
log_debug("Not remounting %s deny-listed by %s, called for %s",
- path, *i, simplified);
+ path, *i, prefix);
break;
}
}
@@ -302,7 +295,7 @@ int bind_remount_recursive_with_mountinfo(
* already triggered, then we will find
* another entry for this. */
if (streq(type, "autofs")) {
- top_autofs = top_autofs || path_equal(path, simplified);
+ top_autofs = top_autofs || path_equal(path, prefix);
continue;
}
@@ -317,26 +310,26 @@ int bind_remount_recursive_with_mountinfo(
* the root is either already done, or an autofs, we
* are done */
if (set_isempty(todo) &&
- (top_autofs || set_contains(done, simplified)))
+ (top_autofs || set_contains(done, prefix)))
return 0;
- if (!set_contains(done, simplified) &&
- !set_contains(todo, simplified)) {
+ if (!set_contains(done, prefix) &&
+ !set_contains(todo, prefix)) {
/* The prefix directory itself is not yet a mount, make it one. */
- r = mount_nofollow(simplified, simplified, NULL, MS_BIND|MS_REC, NULL);
+ r = mount_nofollow(prefix, prefix, NULL, MS_BIND|MS_REC, NULL);
if (r < 0)
return r;
orig_flags = 0;
- (void) get_mount_flags(table, simplified, &orig_flags);
+ (void) get_mount_flags(table, prefix, &orig_flags);
- r = mount_nofollow(NULL, simplified, NULL, (orig_flags & ~flags_mask)|MS_BIND|MS_REMOUNT|new_flags, NULL);
+ r = mount_nofollow(NULL, prefix, NULL, (orig_flags & ~flags_mask)|MS_BIND|MS_REMOUNT|new_flags, NULL);
if (r < 0)
return r;
log_debug("Made top-level directory %s a mount point.", prefix);
- r = set_put_strdup(&done, simplified);
+ r = set_put_strdup(&done, prefix);
if (r < 0)
return r;
}