diff --git a/bios/stage-2/src/fat.rs b/bios/stage-2/src/fat.rs index 9ce41d6f..0f24e0b4 100644 --- a/bios/stage-2/src/fat.rs +++ b/bios/stage-2/src/fat.rs @@ -48,16 +48,14 @@ impl Bpb { let root_cluster; let fat_size_32; - if (total_sectors_16 == 0) && (total_sectors_32 != 0) { + if fat_size_16 == 0 { // FAT32 fat_size_32 = u32::from_le_bytes(raw[36..40].try_into().unwrap()); root_cluster = u32::from_le_bytes(raw[44..48].try_into().unwrap()); - } else if (total_sectors_16 != 0) && (total_sectors_32 == 0) { + } else { // FAT12 or FAT16 fat_size_32 = 0; root_cluster = 0; - } else { - panic!("ExactlyOneTotalSectorsFieldMustBeZero"); } Self { diff --git a/tests/ramdisk.rs b/tests/ramdisk.rs index 08c86f9b..6c23615a 100644 --- a/tests/ramdisk.rs +++ b/tests/ramdisk.rs @@ -1,6 +1,8 @@ use std::path::Path; use bootloader_test_runner::run_test_kernel_with_ramdisk; +use tempfile::NamedTempFile; + static RAMDISK_PATH: &str = "tests/ramdisk.txt"; #[test] @@ -26,3 +28,15 @@ fn memory_map() { Some(Path::new(RAMDISK_PATH)), ); } + +#[test] +fn large_ramdisk() { + // Create a large file to act as the RAM disk. + let ramdisk = NamedTempFile::new().unwrap(); + ramdisk.as_file().set_len(1024 * 1024 * 16).unwrap(); + + run_test_kernel_with_ramdisk( + env!("CARGO_BIN_FILE_TEST_KERNEL_RAMDISK_basic_boot"), + Some(ramdisk.as_ref()), + ); +}