diff options
author | Luca Boccassi <bluca@debian.org> | 2023-12-05 16:43:12 +0100 |
---|---|---|
committer | Luca Boccassi <bluca@debian.org> | 2023-12-05 18:20:27 +0100 |
commit | f83a74dfb8210f0d67943912c539e51b989f85a4 (patch) | |
tree | 5207041a00c7286dd34e20661ed1119ab00ea293 /src/shared/switch-root.c | |
parent | basic: add fds_are_same_mount() helper (diff) | |
download | systemd-f83a74dfb8210f0d67943912c539e51b989f85a4.tar.xz systemd-f83a74dfb8210f0d67943912c539e51b989f85a4.zip |
switch-root: also check that mount IDs are the same, not just inodes
If /run/nextroot/ has been set up, use it, even if the inodes are
the same. It could be a verity device that is reused, but with
different sub-mounts or other differences. Or the same / tmpfs with
different /usr/ mounts. If it was explicitly set up we should use it.
Use the new helper to check that the mount IDs are also the same,
not just the inodes.
Diffstat (limited to 'src/shared/switch-root.c')
-rw-r--r-- | src/shared/switch-root.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/shared/switch-root.c b/src/shared/switch-root.c index b620156c75..787fb79afb 100644 --- a/src/shared/switch-root.c +++ b/src/shared/switch-root.c @@ -63,11 +63,11 @@ int switch_root(const char *new_root, if (new_root_fd < 0) return log_error_errno(errno, "Failed to open target directory '%s': %m", new_root); - r = inode_same_at(old_root_fd, "", new_root_fd, "", AT_EMPTY_PATH); + r = fds_are_same_mount(old_root_fd, new_root_fd); if (r < 0) - return log_error_errno(r, "Failed to determine if old and new root directory are the same: %m"); + return log_error_errno(r, "Failed to check if old and new root directory/mount are the same: %m"); if (r > 0) { - log_debug("Skipping switch root, as old and new root directory are the same."); + log_debug("Skipping switch root, as old and new root directories/mounts are the same."); return 0; } |