Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions crates/lib/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2409,15 +2409,15 @@ pub(crate) async fn install_to_filesystem(
tracing::debug!("Root mount: {} {:?}", root_info.mount_spec, root_info.kargs);

let boot_is_mount = {
let root_dev = rootfs_fd.dir_metadata()?.dev();
let boot_dev = target_rootfs_fd
.symlink_metadata_optional(BOOT)?
.ok_or_else(|| {
anyhow!("No /{BOOT} directory found in root; this is is currently required")
})?
.dev();
tracing::debug!("root_dev={root_dev} boot_dev={boot_dev}");
root_dev != boot_dev
if let Some(boot_metadata) = target_rootfs_fd.symlink_metadata_optional(BOOT)? {
let root_dev = rootfs_fd.dir_metadata()?.dev();
let boot_dev = boot_metadata.dev();
tracing::debug!("root_dev={root_dev} boot_dev={boot_dev}");
root_dev != boot_dev
} else {
tracing::debug!("No /{BOOT} directory found");
false
}
};
Comment on lines 2411 to 2421
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change is correct, but we can make it slightly more efficient and clear. By moving the root_dev calculation inside the if let block, we avoid computing it if /boot doesn't exist. This also allows removing the outer block, making the code a bit more direct.

    let boot_is_mount = if let Some(boot_metadata) = target_rootfs_fd.symlink_metadata_optional(BOOT)? {
        let root_dev = rootfs_fd.dir_metadata()?.dev();
        let boot_dev = boot_metadata.dev();
        tracing::debug!("root_dev={root_dev} boot_dev={boot_dev}");
        root_dev != boot_dev
    } else {
        tracing::debug!("No /{BOOT} directory found");
        false
    };

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied this change.

// Find the UUID of /boot because we need it for GRUB.
let boot_uuid = if boot_is_mount {
Expand Down