Function scan_mbr_partitions

Source
pub fn scan_mbr_partitions(
    device: &Device,
) -> Result<Vec<(usize, PartitionEntry)>>
Expand description

Scan a device for MBR and return partition information.

This function reads the MBR from a device and extracts information about all valid partitions. It returns a vector of tuples containing the partition index and the partition entry for each valid partition found.

§Arguments

  • Device - The storage device to scan for MBR partitions

§Returns

  • Ok(Vec<(usize, Partition_entry_type)>) - List of valid partitions with their indices
  • Err(Error) - Error reading MBR or device access failure

§Examples

extern crate alloc;
use file_system::*;

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

match Scan_mbr_partitions(&device) {
    Ok(partitions) => {
        println!("Found {} valid partitions", partitions.len());
        for (index, partition) in partitions {
            println!("Partition {}: {:?}", index, partition.get_partition_type());
        }
    }
    Err(e) => println!("Failed to scan partitions: {}", e),
}