Skip to content
/* /*
* Copyright (c) 2021, Luca Fulchir <luker@fenrirproject.org> * Copyright (c) 2021-2022, Luca Fulchir <luker@fenrirproject.org>
* *
* This file is part of dfim. * This file is part of dfim.
* *
......
/* /*
* Copyright (c) 2021, Luca Fulchir <luker@fenrirproject.org> * Copyright (c) 2021-2022, Luca Fulchir <luker@fenrirproject.org>
* *
* This file is part of dfim. * This file is part of dfim.
* *
......
/* /*
* Copyright (c) 2021, Luca Fulchir <luker@fenrirproject.org> * Copyright (c) 2021-2022, Luca Fulchir <luker@fenrirproject.org>
* *
* This file is part of dfim. * This file is part of dfim.
* *
......
/* /*
* Copyright (c) 2021, Luca Fulchir <luker@fenrirproject.org> * Copyright (c) 2021-2022, Luca Fulchir <luker@fenrirproject.org>
* *
* This file is part of dfim. * This file is part of dfim.
* *
...@@ -223,7 +223,12 @@ impl GPT { ...@@ -223,7 +223,12 @@ impl GPT {
}; };
let p = Partition { let p = Partition {
label: disk_p.name.clone(), label: disk_p.name.clone(),
number: *num, number: ::std::num::NonZeroU32::new(*num).ok_or(
::std::io::Error::new(
::std::io::ErrorKind::InvalidData,
"Found partition id 0 on drive",
),
)?,
part_type: PartId::UUID( part_type: PartId::UUID(
::uuid::Uuid::parse_str(&disk_p.part_type_guid.guid) ::uuid::Uuid::parse_str(&disk_p.part_type_guid.guid)
.unwrap(), .unwrap(),
...@@ -282,7 +287,11 @@ impl GPT { ...@@ -282,7 +287,11 @@ impl GPT {
assert!(false, "Partition without sys number?"); assert!(false, "Partition without sys number?");
continue; continue;
} }
Some(partnum) => partnum as u32, Some(partnum) => ::std::num::NonZeroU32::new(partnum as u32)
.ok_or(::std::io::Error::new(
::std::io::ErrorKind::InvalidData,
"dev num 0 but we can't have partition 0",
))?,
}; };
let p = match cfg.partitions.iter().find(|x| x.number == partnum) { let p = match cfg.partitions.iter().find(|x| x.number == partnum) {
Some(p) => p, Some(p) => p,
...@@ -414,7 +423,7 @@ impl super::TargetApply for GPT { ...@@ -414,7 +423,7 @@ impl super::TargetApply for GPT {
flags: conf_p.flag_bits(), flags: conf_p.flag_bits(),
name: conf_p.label.clone(), name: conf_p.label.clone(),
}; };
disk_parts.insert(conf_p.number, p); disk_parts.insert(conf_p.number.get(), p);
} }
match disk.update_partitions_embedded(disk_parts, self.0.max_partitions) match disk.update_partitions_embedded(disk_parts, self.0.max_partitions)
......