Conversation
Separates the calculation of the FAT image's logical size from its total file size. The `logical_size` now represents the actual content and overhead, rounded up to the nearest sector, and is ensured to be at least one sector. This is the size reported back by the function in sectors. The `total_size` is explicitly the final image file size, which ensures it meets the minimum requirements for FAT16 formatting (16MB). The FAT type determination is based on this `total_size`. This change improves clarity by distinguishing between the actual data capacity and the physical file size required by the FAT format.
This commit introduces a new integration test, `test_iso_integrity_and_boot_modes`, to enhance the robustness of ISO generation. The test performs the following verifications: - Builds an ISO with both BIOS (El Torito) and UEFI boot components. - Verifies the ISO's integrity using `md5sum`. - Confirms the presence and correct configuration of the El Torito boot entry using `isoinfo -d`. - Extracts the BIOS boot image from the generated ISO and asserts the presence of the `0xAA55` boot signature, ensuring proper BIOS boot sector creation. This helps ensure that the generated ISOs are valid and correctly configured for multiple boot environments.
Summary of ChangesHello @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 refines the internal logic for calculating FAT image sizes, ensuring more accurate representation of the logical content size within generated ISOs. Additionally, it significantly enhances the project's test suite by introducing a robust integration test that validates the integrity and bootability of ISO images across both BIOS and UEFI environments, thereby improving the overall reliability of the ISO generation process. Highlights
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request refactors the FAT image size calculation and adds a new integration test for ISO integrity and boot modes. The refactoring in fat.rs correctly separates the logical image size from the total file size. However, it introduces a redundant check that can be removed. The new integration test in tests/integration.rs is a great addition for ensuring robustness, but it contains a critical logic error that will cause it to always fail, and it also misses an opportunity to handle command failures robustly. My review includes suggestions to fix these issues in the test to make it reliable and to clean up the code in fat.rs.
| if logical_size == 0 { | ||
| logical_size = SECTOR_SIZE; | ||
| } |
There was a problem hiding this comment.
This check for logical_size == 0 is unreachable. content_size is derived from file metadata lengths and will be non-negative. Since FAT_OVERHEAD is a positive constant, the sum content_size + FAT_OVERHEAD will always be greater than zero. Consequently, logical_size, which is calculated by rounding this sum up to the nearest sector size, can never be zero. This block of code can be safely removed to simplify the logic.
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>
`fat::create_fat_image` now returns the logical size of the created FAT image in 512-byte sectors. `iso::builder::build_iso` uses this logical size to calculate the ESP size in ISO (2048-byte) sectors for the ISO builder's internal tracking. When creating the UEFI boot catalog entry, `iso::builder_utils::create_uefi_esp_boot_entry` now correctly converts the ESP size from ISO sectors back to 512-byte sectors, as required by the boot catalog specification. This ensures consistent and accurate handling of the EFI System Partition (ESP) size throughout the ISO creation process, resolving discrepancies between 512-byte and 2048-byte sector units and ensuring the boot catalog correctly reflects the ESP's logical size. The `build_iso` function now also returns the logical FAT image size in 512-byte sectors.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a significant refactoring that improves the ISO building logic and test structure. Key changes include clarifying FAT image size calculations, making the IsoBuilder more flexible by accepting a File handle, and reorganizing integration tests into focused modules. These changes enhance maintainability and appear to fix an underlying issue with how ESP size is calculated. My review focuses on a critical overflow vulnerability and a minor code cleanup suggestion.
| &mut self, | ||
| iso_path: &Path, | ||
| iso_file: &mut File, // Accept File handle directly | ||
| _iso_path: &Path, // Renamed to _iso_path to silence unused variable warning |
Adds a new verification step to the `test_iso_integrity_and_boot_modes` integration test. This step inspects the raw ISO image bytes to confirm the presence and correctness of the GPT (GUID Partition Table) header. It specifically asserts the "EFI PART" signature and the 1.0 revision (0x00010000) of the GPT header. This improves the robustness of UEFI ISO integrity checks, ensuring generated images correctly implement the GPT structure required for UEFI boot compatibility.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a significant refactoring to the ISO building process, primarily focusing on correcting the calculation of FAT image sizes and improving the flexibility of the IsoBuilder. The changes correctly distinguish between the logical and physical size of the FAT image, fixการคำนวณขนาดพาร์ติชัน UEFI ESP ใน boot catalog, และจัดระเบียบการทดสอบ integration ใหม่ให้เป็นโมดูลที่แยกจากกัน ซึ่งเป็นการปรับปรุงที่ยอดเยี่ยม
การตรวจสอบของฉันพบปัญหาเล็กน้อยบางประการ: พารามิเตอร์ที่ไม่ได้ใช้งานในฟังก์ชัน build, ตรรกะการตรวจสอบที่ไม่ถูกต้องซึ่งอาจนำไปสู่ overflow, และการยืนยันที่ไม่ถูกต้องในการทดสอบซึ่งไม่พิจารณาการปัดเศษขนาด โดยรวมแล้ว การเปลี่ยนแปลงเหล่านี้เป็นการปรับปรุงที่แข็งแกร่งสำหรับ codebase
| &mut self, | ||
| iso_path: &Path, | ||
| iso_file: &mut File, // Accept File handle directly | ||
| _iso_path: &Path, // Renamed to _iso_path to silence unused variable warning |
There was a problem hiding this comment.
ลายเซ็นฟังก์ชัน build ได้รับการปรับปรุงให้ยอมรับ &mut File ซึ่งเป็นการปรับปรุงที่ดี อย่างไรก็ตาม พารามิเตอร์ _iso_path ไม่ได้ถูกใช้งานแล้วและควรถูกลบออกเพื่อทำให้ลายเซ็นฟังก์ชันสะอาดขึ้น การเปลี่ยนแปลงนี้จะต้องถูกส่งต่อไปยังตำแหน่งที่เรียกใช้ใน build_iso ด้วย
| &mut self, | |
| iso_path: &Path, | |
| iso_file: &mut File, // Accept File handle directly | |
| _iso_path: &Path, // Renamed to _iso_path to silence unused variable warning | |
| iso_file: &mut File, // Accept File handle directly | |
| esp_lba: Option<u32>, |
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
/gemini summary |
Summary of ChangesThis pull request significantly refines the core logic for generating ISO images, focusing on more accurate FAT image size calculations and a cleaner Highlights
Changelog
Activity
|
Change details
Build / Test Results