Function has_valid_mbr

Source
pub fn has_valid_mbr(device: &Device) -> bool
Expand 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 signature
  • false - Device doesn’t contain a valid MBR or cannot be read

§Examples

extern crate alloc;
use file_system::*;

let device = create_device!(Memory_device_type::<512>::new(4 * 1024 * 1024));

if Has_valid_mbr(&device) {
    println!("Device has a valid MBR");
} else {
    println!("Device needs to be partitioned");
}