Skip to content

Commit 103bf77

Browse files
committed
partitioning: Store table attributes in superset
We'll need to extend the partition attributes in order to permit filesystem storage/modification. Signed-off-by: Ikey Doherty <[email protected]>
1 parent cda3d00 commit 103bf77

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

crates/partitioning/src/attributes.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use gpt::partition_types;
66
use uuid::Uuid;
77

8-
/// Represents the attributes of a GPT partition
8+
/// Represents the table attributes of a GPT partition
99
#[derive(Debug, Clone)]
1010
pub struct GptAttributes {
1111
/// The type GUID that identifies the partition type
@@ -28,21 +28,27 @@ impl Default for GptAttributes {
2828

2929
/// Represents attributes specific to different partition table types
3030
#[derive(Debug, Clone)]
31-
pub enum PartitionAttributes {
31+
pub enum TableAttributes {
3232
/// GPT partition attributes
3333
Gpt(GptAttributes),
3434
//Mbr(MbrAttributes),
3535
}
3636

37-
impl PartitionAttributes {
37+
impl TableAttributes {
3838
/// Returns a reference to the GPT attributes if this is a GPT partition
3939
///
4040
/// # Returns
4141
/// - `Some(&GptAttributes)` if this is a GPT partition
4242
/// - `None` if this is not a GPT partition
4343
pub fn as_gpt(&self) -> Option<&GptAttributes> {
4444
match self {
45-
PartitionAttributes::Gpt(attr) => Some(attr),
45+
TableAttributes::Gpt(attr) => Some(attr),
4646
}
4747
}
4848
}
49+
50+
/// Represents the attributes of a partition
51+
#[derive(Debug, Clone)]
52+
pub struct PartitionAttributes {
53+
pub table: TableAttributes,
54+
}

crates/partitioning/src/writer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ impl<'a> DiskWriter<'a> {
146146
} => {
147147
let start_lba = *start / 512;
148148
let size_lba = (*end - *start) / 512;
149-
let (part_type, part_name) = match attributes.as_ref().and_then(|a| a.as_gpt()) {
149+
let (part_type, part_name) = match attributes.as_ref().and_then(|a| a.table.as_gpt()) {
150150
Some(GptAttributes { type_guid, name, .. }) => {
151151
(type_guid.clone(), name.clone().unwrap_or_default())
152152
}

crates/provisioning/src/commands/create_partition.rs

+11-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//
44
// SPDX-License-Identifier: MPL-2.0
55

6-
use partitioning::{gpt::partition_types, GptAttributes, PartitionAttributes};
6+
use partitioning::{gpt::partition_types, GptAttributes, PartitionAttributes, TableAttributes};
77

88
use crate::{
99
get_kdl_entry, get_kdl_property, get_property_str, Constraints, Context, Filesystem, FromKdlProperty, FromKdlType,
@@ -34,14 +34,16 @@ pub struct Command {
3434

3535
impl Command {
3636
pub fn attributes(&self) -> PartitionAttributes {
37-
PartitionAttributes::Gpt(GptAttributes {
38-
type_guid: match &self.partition_type {
39-
Some(p) => p.as_guid(),
40-
None => partition_types::BASIC,
41-
},
42-
name: self.partition_type.as_ref().map(|p| p.to_string()),
43-
uuid: None,
44-
})
37+
PartitionAttributes {
38+
table: TableAttributes::Gpt(GptAttributes {
39+
type_guid: match &self.partition_type {
40+
Some(p) => p.as_guid(),
41+
None => partition_types::BASIC,
42+
},
43+
name: self.partition_type.as_ref().map(|p| p.to_string()),
44+
uuid: None,
45+
}),
46+
}
4547
}
4648
}
4749

0 commit comments

Comments
 (0)