Merge pull request #30332 from bluca/softreboot_pivot_in_place

switch-root: also check that mount IDs are the same, not just inodes
This commit is contained in:
Luca Boccassi
2023-12-06 21:01:13 +00:00
committed by GitHub
4 changed files with 62 additions and 31 deletions
+3 -3
View File
@@ -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;
}