Skip to content

Support ISO9660#23

Merged
p14c31355 merged 10 commits intomainfrom
develop
Sep 21, 2025
Merged

Support ISO9660#23
p14c31355 merged 10 commits intomainfrom
develop

Conversation

@p14c31355
Copy link
Copy Markdown
Owner

Pull Request

Change details

  • New feature
  • Refactoring
  • Bug fix
  • CI / Build settings correction
  • Documentation update

Build / Test Results

$ cargo check     #
$ cargo test      #

@p14c31355 p14c31355 self-assigned this Sep 21, 2025
@p14c31355 p14c31355 added the enhancement New feature or request label Sep 21, 2025
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @p14c31355, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the ISO9660 image creation utility by addressing a checksum bug in the El Torito boot catalog and introducing support for BIOS boot images. It also includes API refactoring for better clarity and maintainability, ensuring the generated ISOs are more compliant and versatile for various boot environments.

Highlights

  • El Torito Boot Catalog Checksum Correction: Fixed a bug in the checksum calculation for the El Torito boot catalog, ensuring proper ISO9660 compliance by correctly summing the first 15 words (bytes 0 to 27).
  • BIOS Boot Image Support: Added new functionality to include BIOS boot images in the generated ISO, expanding boot compatibility alongside existing UEFI support.
  • Refactored ISO Creation API: The main ISO creation function create_custom_iso was renamed to create_disk_and_iso for clarity, and the write_volume_descriptors function was streamlined by centralizing the LBA_BOOT_CATALOG constant and standardizing descriptor writing order.
  • Improved Integration Tests: The integration tests were refactored to use a helper function for file setup and now correctly construct and pass an IsoImage struct, making them more robust and aligned with the intended API usage.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the ISO creation logic and adds support for ISO9660 BIOS boot. The changes include renaming the main ISO creation function, improving the volume descriptor writing logic, and updating tests.

My review has identified a critical bug in the boot catalog checksum calculation that needs to be addressed. I've also found some incorrect comments in the volume descriptor code and a configuration issue in one of the integration tests. The refactoring of the volume descriptor writing is a good improvement that fixes a potential bug in the previous implementation.

Comment thread src/iso/boot_catalog.rs Outdated
Comment thread tests/integration.rs Outdated
Comment thread src/iso/volume_descriptor.rs Outdated
p14c31355 and others added 3 commits September 22, 2025 00:04
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@p14c31355
Copy link
Copy Markdown
Owner Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for ISO9660, including refactoring and bug fixes. The changes are generally good, especially the fixes to the volume descriptor writing order and the integration test. I've identified a few areas for improvement related to API clarity and code simplification in tests. My specific comments are detailed below.

Comment thread src/iso/builder.rs Outdated
Comment thread tests/integration.rs Outdated
Comment thread tests/integration.rs Outdated
Comment on lines +16 to +32
fn setup_integration_test_files(
temp_dir: &Path,
) -> io::Result<(PathBuf, PathBuf, PathBuf, PathBuf)> {
// Create dummy files needed for the ISO image
let bellows_path = temp_dir.join("bellows.efi");
std::fs::write(&bellows_path, b"dummy bellows.efi")?;

let kernel_path = temp_dir.join("kernel.efi");
std::fs::write(&kernel_path, b"dummy kernel.efi")?;

let fat_img_path = temp_dir.join("fat.img"); // This is for the UEFI FAT image
std::fs::write(&fat_img_path, b"dummy fat.img")?;

let iso_path = temp_dir.join("test.iso");

Ok((bellows_path, kernel_path, fat_img_path, iso_path))
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The setup_integration_test_files function creates kernel_path and fat_img_path files, but they are not used in test_create_disk_and_iso, as indicated by the _ prefixes on line 39. This creates unnecessary files and can be confusing. The function should be simplified to only create the files that are actually needed for the test.

fn setup_integration_test_files(
    temp_dir: &Path,
) -> io::Result<(PathBuf, PathBuf)> {
    // Create dummy files needed for the ISO image
    let bellows_path = temp_dir.join("bellows.efi");
    std::fs::write(&bellows_path, b"dummy bellows.efi")?;

    let iso_path = temp_dir.join("test.iso");

    Ok((bellows_path, iso_path))
}

Comment thread tests/integration.rs Outdated
Comment on lines +39 to +40
let (bellows_path, _kernel_path, _fat_img_path, iso_path) =
setup_integration_test_files(temp_dir.path())?;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Following the simplification of setup_integration_test_files, this call site should be updated to match the new return type and destructure only the used variables.

    let (bellows_path, iso_path) =
        setup_integration_test_files(temp_dir.path())?;

p14c31355 and others added 5 commits September 22, 2025 00:07
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@p14c31355
Copy link
Copy Markdown
Owner Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces significant refactoring to support ISO9660 image creation, including renaming the primary function to build_iso and adding API documentation. The changes also include bug fixes, such as correctly ordering volume descriptor writes and ensuring the BIOS boot image is included in the final ISO. While the changes are a good step forward, I've noted a couple of areas where the API could be made clearer and less redundant for the end-user.

Comment thread API.md
Comment on lines +59 to +63
pub struct BiosBootInfo {
pub boot_catalog: PathBuf,
pub boot_image: PathBuf,
pub destination_in_iso: String,
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The boot_catalog field within the BiosBootInfo struct appears to be unused in the implementation. The boot catalog is generated internally by the library, and its properties aren't configurable via this field. Including it in the public API can be misleading for users. Consider removing it to simplify the API and avoid confusion.

Comment thread src/iso/builder.rs
Comment on lines +509 to +515
// Handle BIOS boot image
if let Some(bios_boot_info) = &image.boot_info.bios_boot {
iso_builder.add_file(
&bios_boot_info.destination_in_iso,
bios_boot_info.boot_image.clone(),
)?;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

This logic correctly adds the BIOS boot image to the ISO. However, it introduces redundancy if the user also includes the boot image in the files vector of the IsoImage struct, as demonstrated in the API.md example. This would cause the file to be processed twice.

To improve the API's clarity and prevent this, I recommend documenting that boot images are handled automatically and should not be included in the main files list. The example in API.md should be updated to reflect this, by removing the boot image from the files vector.

@p14c31355 p14c31355 merged commit 11f96f1 into main Sep 21, 2025
1 check passed
@p14c31355
Copy link
Copy Markdown
Owner Author

/gemini summary

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

This pull request significantly enhances the ISO image creation utility by adding robust support for ISO9660, including both UEFI and BIOS boot mechanisms. It addresses a crucial checksum bug in the El Torito boot catalog and refactors the API for improved clarity and maintainability, ensuring the generated ISOs are compliant and versatile across different boot environments.

Highlights

  • ISO9660 and UEFI/BIOS Boot Support: Introduces comprehensive support for creating bootable ISO9660 images, including both UEFI and BIOS boot capabilities.
  • El Torito Boot Catalog Checksum Fix: Corrects a critical bug in the checksum calculation for the El Torito boot catalog, ensuring proper ISO9660 compliance.
  • API Refactoring and Documentation: Renames the primary ISO creation function to 'build_iso' for clarity, streamlines volume descriptor writing, and adds new API documentation ('API.md') with usage examples.
  • Improved Integration Tests: Refactors integration tests to align with the new 'build_iso' API and simplify test file setup, enhancing test robustness.
Changelog
  • API.md
    • Added new API documentation for the 'build_iso' function and its configuration structs ('IsoImage', 'IsoImageFile', 'BootInfo', 'BiosBootInfo', 'UefiBootInfo'), complete with an example.
  • src/iso/boot_catalog.rs
    • Added a clarifying comment for the checksum calculation logic.
  • src/iso/builder.rs
    • Removed 'LBA_BOOT_CATALOG' import as it's now handled in 'volume_descriptor.rs'.
    • Updated 'write_volume_descriptors' call to reflect changes in its signature.
    • Renamed 'create_custom_iso' to 'build_iso'.
    • Implemented logic to add BIOS boot images to the ISO.
  • src/iso/volume_descriptor.rs
    • Imported 'LBA_BOOT_CATALOG'.
    • Modified 'write_volume_descriptors' to remove the 'boot_catalog_lba' parameter and explicitly define the order and LBA of the Primary, Boot Record, and Terminator volume descriptors.
  • src/lib.rs
    • Re-exported 'build_iso' from 'iso::builder'.
    • Updated internal test calls to use 'build_iso'.
  • tests/integration.rs
    • Introduced 'setup_integration_test_files' helper function.
    • Adapted 'test_create_disk_and_iso' to use 'build_iso' with the 'IsoImage' configuration, focusing on UEFI boot.
    • Simplified test file creation to only include necessary files.
Activity
  • gemini-code-assist[bot] provided an initial summary of the changes.
  • p14c31355 requested '/gemini review' twice and '/gemini summary' once.
  • gemini-code-assist[bot] posted a critical review comment on 'src/iso/boot_catalog.rs' regarding incorrect checksum calculation logic and a misleading comment.
  • gemini-code-assist[bot] posted a high priority review comment on 'API.md' example concerning an incorrect 'destination_in_iso' for 'UefiBootInfo'.
  • gemini-code-assist[bot] posted a medium priority review comment on 'src/iso/volume_descriptor.rs' about incorrect LBA comments for Boot Record and Terminator.
  • gemini-code-assist[bot] posted a medium priority review comment on 'src/iso/builder.rs' suggesting renaming 'create_custom_iso' to 'build_iso'.
  • gemini-code-assist[bot] posted multiple medium priority review comments on 'tests/integration.rs' regarding a confusing comment, unused files in the helper function, and updating the call site.
  • gemini-code-assist[bot] posted a medium priority review comment on 'API.md' example about the 'boot_catalog' field in 'BiosBootInfo' being unused and potential redundancy in file inclusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant