@@ -82,11 +82,11 @@ pub struct Region {
8282
8383 /// The absolute end position of this region in bytes
8484 pub end : u64 ,
85+
86+ /// The partition ID of this region if it represents a partition
87+ pub partition_id : Option < u32 > ,
8588}
8689
87- /// Default alignment for partition boundaries (1MiB)
88- ///
89- /// Most modern storage devices and partition tables work best with
9090/// partitions aligned to 1MiB boundaries. This helps ensure optimal
9191/// performance and compatibility.
9292pub const PARTITION_ALIGNMENT : u64 = 1024 * 1024 ;
@@ -98,7 +98,11 @@ pub const PARTITION_ALIGNMENT: u64 = 1024 * 1024;
9898impl Region {
9999 /// Create a new region with the given bounds
100100 pub fn new ( start : u64 , end : u64 ) -> Self {
101- Self { start, end }
101+ Self {
102+ start,
103+ end,
104+ partition_id : None ,
105+ }
102106 }
103107
104108 /// Get the size of this region in bytes
@@ -229,7 +233,9 @@ impl Planner {
229233 let mut max_id = 0u32 ;
230234
231235 for part in device. partitions ( ) {
232- original_regions. push ( Region :: new ( part. start , part. end ) ) ;
236+ let mut region = Region :: new ( part. start , part. end ) ;
237+ region. partition_id = Some ( part. number ) ;
238+ original_regions. push ( region) ;
233239 original_partition_ids. push ( part. number ) ;
234240 max_id = max_id. max ( part. number ) ;
235241 }
@@ -311,6 +317,7 @@ impl Planner {
311317 layout. push ( Region {
312318 start : * start,
313319 end : * end,
320+ partition_id : Some ( * partition_id) ,
314321 } ) ;
315322 }
316323 }
0 commit comments