pub fn has_valid_mbr(device: &impl DirectBlockDevice) -> boolExpand description
Check if a device contains a valid MBR.
This function attempts to read an MBR from the device and validates its signature. It’s a quick way to determine if a device has been properly partitioned with MBR.
§Arguments
Device- The storage device to check
§Returns
true- Device contains a valid MBR with proper signaturefalse- Device doesn’t contain a valid MBR or cannot be read
§Examples
extern crate alloc;
use file_system::{MemoryDevice, mbr::{Mbr, has_valid_mbr}};
let device = MemoryDevice::<512>::new(4 * 1024 * 1024);
// Create and write an MBR
let mbr = Mbr::new_with_signature(0x12345678);
mbr.write_to_device(&device).unwrap();
if has_valid_mbr(&device) {
println!("Device has a valid MBR");
} else {
println!("Device needs to be partitioned");
}