pub fn create_basic_mbr(
disk_signature: u32,
partition_type: PartitionKind,
total_sectors: u32,
) -> Result<Mbr>
Expand description
Create a basic MBR with a single partition covering most of the disk.
This function creates a simple MBR structure with one partition that uses most of the available disk space. It leaves 2048 sectors at the beginning for proper alignment, which is standard practice for modern storage devices.
§Arguments
Disk_signature
- Unique 32-bit signature for the diskPartition_type
- Type of partition to create (e.g., FAT32, Linux, etc.)Total_sectors
- Total number of sectors available on the disk
§Returns
Ok(MBR_type)
- Successfully created MBR with single partitionErr(Error::InvalidParameter)
- Disk is too small for a partition
§Examples
use file_system::*;
// Create MBR for a 4MB device (8192 sectors)
let mbr = MBR_type::Create_basic(0x12345678, Partition_type_type::Fat32_lba, 8192).unwrap();
// The MBR will have one FAT32 partition starting at sector 2048
let partitions = mbr.get_valid_partitions();
assert_eq!(partitions.len(), 1);
assert_eq!(partitions[0].get_start_lba(), 2048);