livedisk
Cross-platform enumeration of the live system's physical disks and
partitions — diskutil list / lsblk / diskpart, but as a library with
one unified model across macOS, Linux, and Windows.
for disk in livedisk::enumerate()? {
println!("{} — {}", disk.name, livedisk::human_size(disk.size_bytes));
for part in &disk.partitions {
println!(" {} {}", part.name, livedisk::human_size(part.size_bytes));
}
}
# Ok::<(), livedisk::Error>(())
Discovery is the only OS-specific part. Each backend (sysfs on Linux, the
IOKit IOMedia registry on macOS, DeviceIoControl on Windows) fills the
same [PhysicalDisk]/[Partition] structs; everything downstream — the
[render_overview] bar chart, the per-disk [render_disk_bar], the
[render_listing] view, and the JSON form — is platform-agnostic.
[open_device] opens a chosen device node as a sized Read + Seek so a
partition/filesystem analyzer can run on the live disk exactly as it would on
an image file.
Listing layout/metadata works unprivileged on all three platforms (it
reads the kernel's device registry, not raw sectors); only reading a device
needs root/Administrator. Backends therefore never silently return an empty
list on a permission problem — they surface [Error].