pub fn find_partitions_by_type(
mbr: &Mbr,
partition_type: PartitionKind,
) -> Vec<(usize, &PartitionEntry)>
Expand description
Find partitions of a specific type within an MBR.
This function searches through all partitions in an MBR and returns references to those that match the specified partition type. This is useful for locating specific types of partitions (e.g., FAT32, Linux, etc.) without creating partition devices.
§Arguments
Mbr
- The MBR structure to search throughPartition_type
- The specific partition type to find
§Returns
A vector of tuples containing the partition index and reference to the partition entry for each matching partition.
§Examples
extern crate alloc;
use file_system::*;
let device = create_device!(Memory_device_type::<512>::new(4 * 1024 * 1024));
// Create an MBR with FAT32 partition
let mut mbr = MBR_type::New_with_signature(0x12345678);
mbr.Add_partition(Partition_type_type::Fat32_lba, 2048, 1024, true).unwrap();
mbr.Write_to_device(&device).unwrap();
// Read it back and find FAT32 partitions
let mbr = MBR_type::Read_from_device(&device).unwrap();
let fat32_partitions = mbr.Find_partitions_by_type(Partition_type_type::Fat32_lba);
println!("Found {} FAT32 partitions", fat32_partitions.len());