zanesterling / fatr

A FAT12 parsing and manipulation tool
MIT License
1 stars 0 forks source link

fat: Parse BIOS Parameters #4

Closed kallisti5 closed 7 years ago

kallisti5 commented 7 years ago
kallisti5 commented 7 years ago

kallisti5@nyx fatr :) $ ./target/debug/fatr ls ~/fat12.img BIOSParam { bytes_per_sector: 512, sectors_per_cluster: 4, reserved_sectors: 512, fat_count: 0, max_roots: 8192, sectors: 1784, media_id: 0, sectors_per_fat: 0 }

kallisti5@nyx fatr :) $ ./target/debug/fatr ls ~/fat16.img BIOSParam { bytes_per_sector: 512, sectors_per_cluster: 4, reserved_sectors: 512, fat_count: 0, max_roots: 0, sectors: 16632, media_id: 0, sectors_per_fat: 0 }

Example output. Now that we know the bytes_per_sector, fatr could start calculating those sector sizes more dynamically.

I'm not sure how far you want this project to go, but this is the only native Rust FAT create out there :-)

zanesterling commented 7 years ago

I probably won't actively work on this crate. I built it for a one-off operating systems project I was working on a while back. I'd be happy to add you as a collab on the repo and an owner on the crate, though, if you want to tinker with it 😄

kallisti5 commented 7 years ago

Heh, i'd be happy with that. I'd still like some code review for as long as you have the free time since this is your project. Given how cleanly this was written, i'd bet (basic) FAT16 support as well as FAT12 wouldn't be impossible.

kallisti5 commented 7 years ago

Ok. Everything should be covered in this latest commit. I've removed the unsafe code as well and switched to the ByteOrder crate.

kallisti5@nyx fat :( $ ../../target/debug/fatr ls ~/fat12.img 
BIOSParam { bytes_per_sector: 512, sectors_per_cluster: 4, reserved_sectors: 1, fat_count: 2, max_roots: 512, sectors: 8192, media_id: 248, sectors_per_fat: 6 }
kallisti5@nyx fat :) $ ../../target/debug/fatr ls ~/fat16.img 
BIOSParam { bytes_per_sector: 512, sectors_per_cluster: 4, reserved_sectors: 4, fat_count: 2, max_roots: 512, sectors: 65536, media_id: 248, sectors_per_fat: 64 }
kallisti5@nyx fat :) $ ../../target/debug/fatr ls ~/fat32.img 
BIOSParam { bytes_per_sector: 512, sectors_per_cluster: 1, reserved_sectors: 32, fat_count: 2, max_roots: 0, sectors: 524288, media_id: 248, sectors_per_fat: 4033 }