fix recursive device_path algorithm
This commit is contained in:
parent
9f26c8f50d
commit
11c0ef4db8
2 changed files with 22 additions and 20 deletions
|
@ -9,28 +9,29 @@ fn recurse_device_path(
|
||||||
mut uuid: Option<u128>,
|
mut uuid: Option<u128>,
|
||||||
mut path: Option<String>,
|
mut path: Option<String>,
|
||||||
) -> (Option<u128>, Option<String>) {
|
) -> (Option<u128>, Option<String>) {
|
||||||
|
match dbg!(&a.info) {
|
||||||
|
DevicePathInfo::HardDrive {
|
||||||
|
partition_signature,
|
||||||
|
signature_type,
|
||||||
|
..
|
||||||
|
} => {
|
||||||
|
if matches!(signature_type, DevicePathInfoHardDriveSignatureType::Guid) {
|
||||||
|
let mut sig = [0u8; 16];
|
||||||
|
partition_signature
|
||||||
|
.as_slice()
|
||||||
|
.read_exact(&mut sig)
|
||||||
|
.expect("expected 128-bit Guid");
|
||||||
|
uuid = Some(fixup_uuid(u128::from_be_bytes(sig)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DevicePathInfo::FilePath { path: _path } => {
|
||||||
|
path = Some(_path.clone());
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
|
||||||
match a.next {
|
match a.next {
|
||||||
Some(next) => {
|
Some(next) => {
|
||||||
match &next.info {
|
|
||||||
DevicePathInfo::HardDrive {
|
|
||||||
partition_signature,
|
|
||||||
signature_type,
|
|
||||||
..
|
|
||||||
} => {
|
|
||||||
if matches!(signature_type, DevicePathInfoHardDriveSignatureType::Guid) {
|
|
||||||
let mut sig = [0u8; 16];
|
|
||||||
partition_signature
|
|
||||||
.as_slice()
|
|
||||||
.read_exact(&mut sig)
|
|
||||||
.expect("expected 128-bit Guid");
|
|
||||||
uuid = Some(fixup_uuid(u128::from_be_bytes(sig)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
DevicePathInfo::FilePath { path: _path } => {
|
|
||||||
path = Some(_path.clone());
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
return recurse_device_path(*next, uuid, path);
|
return recurse_device_path(*next, uuid, path);
|
||||||
}
|
}
|
||||||
None => return (uuid, path),
|
None => return (uuid, path),
|
||||||
|
|
|
@ -122,6 +122,7 @@ fn main() -> eyre::Result<()> {
|
||||||
&& let Some(device_path) = device_path
|
&& let Some(device_path) = device_path
|
||||||
{
|
{
|
||||||
let (uuid, path) = traverse_device_path(device_path);
|
let (uuid, path) = traverse_device_path(device_path);
|
||||||
|
eprintln!("devicepath uuid: {uuid:?}, path: {path:?}");
|
||||||
|
|
||||||
let windows_path_str = if let Some(windows_path_str) = path {
|
let windows_path_str = if let Some(windows_path_str) = path {
|
||||||
windows_path_str
|
windows_path_str
|
||||||
|
|
Loading…
Reference in a new issue