api: disks: only return UUID of partitions if it actually is one

Some filesystems like FAT don't include a concept of UUIDs.
Instead, tools like blkid tools like blkid derive these
identifiers based on certain filesystem metadata, such as
volume serial numbers or other unique information. This does
however not follow the format specified in RFC 9562[1].

[1] https://datatracker.ietf.org/doc/html/rfc9562

Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
This commit is contained in:
Hannes Laimer 2024-11-25 17:22:13 +01:00 committed by Thomas Lamprecht
parent 18d4c4fc35
commit 09155de386

View File

@ -898,7 +898,10 @@ fn get_partitions_info(
let mut uuid = None;
if let Some(devpath) = devpath.as_ref() {
for info in lsblk_infos.iter().filter(|i| i.path.eq(devpath)) {
uuid = info.uuid.clone();
uuid = info
.uuid
.clone()
.filter(|uuid| pbs_api_types::UUID_REGEX.is_match(uuid));
used = match info.partition_type.as_deref() {
Some("21686148-6449-6e6f-744e-656564454649") => PartitionUsageType::BIOS,
Some("c12a7328-f81f-11d2-ba4b-00a0c93ec93b") => PartitionUsageType::EFI,