mirror of
https://git.proxmox.com/git/proxmox-backup
synced 2025-06-14 15:40:16 +00:00
add partition entry value getters to Disk
The ID_PART_ENTRY_* values describe what kind of partition this is and thus can be used to implement the `.is_partition()` method which we use in the next patch to avoid calling out to `lsblk`. Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
d7e95d62e4
commit
7dddf742b8
@ -214,6 +214,12 @@ struct DiskInfo {
|
||||
serial: OnceCell<Option<OsString>>,
|
||||
// for perl: #[serde(skip_serializing)]
|
||||
partition_table_type: OnceCell<Option<OsString>>,
|
||||
// for perl: #[serde(skip_serializing)]
|
||||
partition_entry_scheme: OnceCell<Option<OsString>>,
|
||||
// for perl: #[serde(skip_serializing)]
|
||||
partition_entry_uuid: OnceCell<Option<OsString>>,
|
||||
// for perl: #[serde(skip_serializing)]
|
||||
partition_entry_type: OnceCell<Option<OsString>>,
|
||||
gpt: OnceCell<bool>,
|
||||
// ???
|
||||
bus: OnceCell<Option<OsString>>,
|
||||
@ -412,6 +418,50 @@ impl Disk {
|
||||
})
|
||||
}
|
||||
|
||||
/// Get the partitioning scheme of which this device is a partition.
|
||||
pub fn partition_entry_scheme(&self) -> Option<&OsStr> {
|
||||
self.info
|
||||
.partition_entry_scheme
|
||||
.get_or_init(|| {
|
||||
self.device
|
||||
.property_value("ID_PART_ENTRY_SCHEME")
|
||||
.map(|v| v.to_owned())
|
||||
})
|
||||
.as_ref()
|
||||
.map(OsString::as_os_str)
|
||||
}
|
||||
|
||||
/// Check if this is a partition.
|
||||
pub fn is_partition(&self) -> bool {
|
||||
self.partition_entry_scheme().is_some()
|
||||
}
|
||||
|
||||
/// Get the type of partition entry (ie. type UUID from the entry in the GPT partition table).
|
||||
pub fn partition_entry_type(&self) -> Option<&OsStr> {
|
||||
self.info
|
||||
.partition_entry_type
|
||||
.get_or_init(|| {
|
||||
self.device
|
||||
.property_value("ID_PART_ENTRY_TYPE")
|
||||
.map(|v| v.to_owned())
|
||||
})
|
||||
.as_ref()
|
||||
.map(OsString::as_os_str)
|
||||
}
|
||||
|
||||
/// Get the partition entry UUID (ie. the UUID from the entry in the GPT partition table).
|
||||
pub fn partition_entry_uuid(&self) -> Option<&OsStr> {
|
||||
self.info
|
||||
.partition_entry_uuid
|
||||
.get_or_init(|| {
|
||||
self.device
|
||||
.property_value("ID_PART_ENTRY_UUID")
|
||||
.map(|v| v.to_owned())
|
||||
})
|
||||
.as_ref()
|
||||
.map(OsString::as_os_str)
|
||||
}
|
||||
|
||||
/// Get the bus type used for this disk.
|
||||
pub fn bus(&self) -> Option<&OsStr> {
|
||||
self.info
|
||||
|
Loading…
Reference in New Issue
Block a user