Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 2 additions & 4 deletions bios/stage-2/src/fat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 14 additions & 0 deletions tests/ramdisk.rs
Original file line number Diff line number Diff line change
@@ -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]
Expand All @@ -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()),
);
}
Loading