mount-util: shortcut things after generating top-level bind mount

Instead of marking the bind mount read-only right-away, let's just
restart the loop, so that we'll pick it up like any other mount and then
remount like that.
This commit is contained in:
Lennart Poettering
2021-03-26 11:39:37 +01:00
parent d6bfab118d
commit 5c5753b9ea
+11 -20
View File
@@ -307,34 +307,25 @@ int bind_remount_recursive_with_mountinfo(
return r;
}
/* If we have no submounts to process anymore and if
* the root is either already done, or an autofs, we
* are done */
if (set_isempty(todo) &&
(top_autofs || set_contains(done, prefix)))
return 0;
/* Check if the top-level directory was among what we have seen so far. For that check both
* 'done' and 'todo'. Also check 'top_autofs' because if the top-level dir is an autofs we'll
* not include it in either set but will set this bool. */
if (!set_contains(done, prefix) &&
!set_contains(todo, prefix)) {
!(top_autofs || set_contains(todo, prefix))) {
/* The prefix directory itself is not yet a mount, make it one. */
r = mount_nofollow(prefix, prefix, NULL, MS_BIND|MS_REC, NULL);
if (r < 0)
return r;
orig_flags = 0;
(void) get_mount_flags(table, prefix, &orig_flags);
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, prefix);
if (r < 0)
return r;
/* Immediately rescan, so that we pick up the new mount's flags */
continue;
}
/* If we have no submounts to process anymore, we are done */
if (set_isempty(todo))
return 0;
while ((x = set_steal_first(todo))) {
r = set_consume(done, x);