summaryrefslogtreecommitdiffstats
path: root/rsnix/src/fat.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rsnix/src/fat.rs')
-rw-r--r--rsnix/src/fat.rs25
1 files changed, 23 insertions, 2 deletions
diff --git a/rsnix/src/fat.rs b/rsnix/src/fat.rs
index 70fa688..616a08f 100644
--- a/rsnix/src/fat.rs
+++ b/rsnix/src/fat.rs
@@ -838,9 +838,30 @@ pub fn remove(parent_dir_cluster: u32, name: &str) -> Result<(), ()> {
838 838
839// --- mount ------------------------------------------------------------------- 839// --- mount -------------------------------------------------------------------
840 840
841/// Parse the BPB, cache the FAT and validate the volume. Returns true if 841/// Try to mount a FAT32 volume on every attached disk, in port order, and
842/// a usable FAT32 volume is mounted. 842/// keep the first one that validates. Returns true if a usable FAT32
843/// volume is mounted.
843pub fn init() -> bool { 844pub fn init() -> bool {
845 let disks = crate::ahci::disk_count();
846 if disks == 0 {
847 crate::serial_println!("fat: no disk");
848 return false;
849 }
850 for d in 0..disks {
851 if !crate::ahci::select(d) {
852 continue;
853 }
854 if try_mount() {
855 return true;
856 }
857 crate::serial_println!("fat: no FAT32 volume on disk {}", d);
858 }
859 false
860}
861
862/// Parse the BPB of the selected disk, cache the FAT and validate the
863/// volume.
864fn try_mount() -> bool {
844 let mut bpb = [0u8; SECTOR]; 865 let mut bpb = [0u8; SECTOR];
845 if read_sector(0, &mut bpb).is_err() { 866 if read_sector(0, &mut bpb).is_err() {
846 crate::serial_println!("fat: no disk"); 867 crate::serial_println!("fat: no disk");