Skip to content

Commit 1f5721b

Browse files
committed
partitions: ignore NVRAM partitions in to_vec()
The previous approach was broken, since offset() drops the high bits. Instead, look at the partition kind, and ignore NVRAM. Add debug prints. Signed-off-by: Daniel Maslowski <[email protected]>
1 parent 6397127 commit 1f5721b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/part/partitions.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,21 @@ impl Partitions {
188188
use log::debug;
189189
fn copy_parts(parts: &Vec<&dyn Partition>, data: &mut Vec<u8>) {
190190
for p in parts {
191+
let e = p.entry();
191192
let offset = p.entry().offset();
192-
if offset == 0xffff_ffff {
193+
let f = e.flags;
194+
if f.kind() == PartitionKind::NVRAM {
195+
debug!("Ignore {e}");
193196
continue;
194197
}
195198
let raw_part = p.data().as_bytes();
196199
let size = raw_part.len();
197200
let end = offset + size;
198201
if end <= data.len() {
202+
debug!("Copy {e}");
199203
data[offset..end].copy_from_slice(raw_part);
204+
} else {
205+
debug!("Out of bounds: {e}");
200206
}
201207
}
202208
}

0 commit comments

Comments
 (0)