pub struct VmdkReader<R: Read + Seek> { /* private fields */ }Expand description
Read-only VMDK container reader, generic over any Read + Seek source.
Implements Read + Seek over the virtual sector stream.
§Examples
use std::fs::File;
use vmdk::VmdkReader;
let file = File::open("disk.vmdk").unwrap();
let mut reader = VmdkReader::open(file).unwrap();
println!("virtual disk size: {} bytes", reader.virtual_disk_size());Implementations§
Source§impl<R: Read + Seek> VmdkReader<R>
impl<R: Read + Seek> VmdkReader<R>
Sourcepub fn enable_rgd_fallback(&mut self)
pub fn enable_rgd_fallback(&mut self)
Enable opt-in RGD fallback: a read whose primary grain-table pointer is out of
bounds is resolved through the redundant grain directory instead, recovering
data from a damaged primary GD that qemu-img would simply fail on.
Sourcepub fn rgd_recovery_count(&self) -> u64
pub fn rgd_recovery_count(&self) -> u64
Number of grains resolved via the redundant grain directory so far (pointer- or entry-level recovery). Zero on a healthy image; non-zero quantifies how much of a damaged image was reconstructed from the RGD.
Source§impl<R: Read + Seek> VmdkReader<R>
impl<R: Read + Seek> VmdkReader<R>
Sourcepub fn open(reader: R) -> Result<Self, VmdkError>
pub fn open(reader: R) -> Result<Self, VmdkError>
Open a binary VMDK (monolithic sparse or stream-optimised) from any
Read + Seek source.
For multi-file flat VMDKs (text descriptor + extent files) use
VmdkReader::open_path instead.
Sourcepub fn virtual_disk_size(&self) -> u64
pub fn virtual_disk_size(&self) -> u64
Virtual disk size in bytes.
Sourcepub fn disk_type(&self) -> &str
pub fn disk_type(&self) -> &str
createType from the embedded text descriptor (e.g. "monolithicSparse").
Returns an empty string when no embedded descriptor is present.
Sourcepub fn parent_cid(&self) -> u32
pub fn parent_cid(&self) -> u32
Parent CID; 0xffff_ffff means this is a base image (no parent).
Sourcepub fn sector_count(&self) -> u64
pub fn sector_count(&self) -> u64
Virtual disk size in 512-byte sectors.
Sourcepub fn descriptor_text(&self) -> &str
pub fn descriptor_text(&self) -> &str
Raw embedded descriptor text; empty when no embedded descriptor is present.
Sourcepub fn disk_database(&self) -> DiskDatabase
pub fn disk_database(&self) -> DiskDatabase
Parsed ddb.* disk database (geometry, adapter type, VM hardware / tools
versions, UUID, long content ID, thin-provisioning, encoding).
Empty when the descriptor carries no disk database (e.g. a snapshot delta).
Sourcepub fn change_track_path(&self) -> Option<String>
pub fn change_track_path(&self) -> Option<String>
The descriptor’s changeTrackPath — the Change Block Tracking (-ctk.vmdk)
file, if this disk has CBT enabled. The -ctk file maps which blocks changed
between snapshots and is the basis for incremental forensic acquisition.
Sourcepub fn effective_content_id(&self) -> String
pub fn effective_content_id(&self) -> String
The disk’s effective content identifier as a hex string.
When CID == 0xFFFFFFFE (the “use the long content identifier” sentinel),
returns ddb.longContentID; otherwise the 8-hex-digit short CID.
Sourcepub fn is_allocated(&mut self, lba: u64) -> Result<bool>
pub fn is_allocated(&mut self, lba: u64) -> Result<bool>
Returns true if the 512-byte sector at lba is allocated (non-sparse).
An lba beyond the virtual disk boundary always returns false.
For flat/raw-extent VMDKs every sector is implicitly allocated; returns true for
any in-bounds LBA.
Sourcepub fn iter_allocated_grains(&mut self) -> Result<Vec<AllocatedGrain>>
pub fn iter_allocated_grains(&mut self) -> Result<Vec<AllocatedGrain>>
Iterate over all allocated (non-sparse) grain ranges in LBA order.
Each yielded AllocatedGrain covers exactly one grain; contiguous allocated
grains are not coalesced so the caller can apply its own merging if desired.
The iterator is eager — it collects all GTE reads upfront to avoid borrow issues.
Sourcepub fn hash(&mut self) -> Result<VmdkDigest>
pub fn hash(&mut self) -> Result<VmdkDigest>
Compute SHA-256 and MD5 digests of the full virtual disk in one sequential pass.
Reads from the current seek position (normally the caller should seek to 0 first). Uses a 64 KiB streaming buffer to avoid loading the whole disk into memory.
Source§impl VmdkReader<Box<dyn ReadSeek + Send>>
impl VmdkReader<Box<dyn ReadSeek + Send>>
Sourcepub fn extent_dependencies(path: &Path) -> Result<Vec<PathBuf>, VmdkError>
pub fn extent_dependencies(path: &Path) -> Result<Vec<PathBuf>, VmdkError>
List the companion extent files this VMDK depends on, resolved relative to the descriptor’s directory.
For a self-contained binary VMDK (monolithicSparse, streamOptimized, …)
this is empty — the single file holds everything. For multi-file formats
(twoGbMaxExtent*, monolithicFlat, vmfsSparse, seSparse, custom, …)
it returns every backing extent file in descriptor order. ZERO/NOACCESS
extents carry no file and are excluded.
Forensic use: enumerate what must be collected before the disk can be read, without opening (or even possessing) the extents themselves.
Sourcepub fn open_path(path: &Path) -> Result<Self, VmdkError>
pub fn open_path(path: &Path) -> Result<Self, VmdkError>
Open any VMDK format from a file-system path.
Unlike VmdkReader::open, this constructor handles text-descriptor
VMDKs (twoGbMaxExtentFlat) that reference external extent files, as
well as binary VMDKs that can be opened from a single stream.
Trait Implementations§
Source§impl<R: Read + Seek> Read for VmdkReader<R>
impl<R: Read + Seek> Read for VmdkReader<R>
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
1.36.0 · Source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
read, except that it reads into a slice of buffers. Read moreSource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
buf. Read more1.0.0 · Source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
buf. Read more1.6.0 · Source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
buf. Read moreSource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
read_buf)Source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
read_buf)cursor. Read more1.0.0 · Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Read. Read more1.0.0 · Source§fn chain<R>(self, next: R) -> Chain<Self, R>
fn chain<R>(self, next: R) -> Chain<Self, R>
Source§impl<R: Read + Seek> Seek for VmdkReader<R>
impl<R: Read + Seek> Seek for VmdkReader<R>
Source§fn seek(&mut self, pos: SeekFrom) -> Result<u64>
fn seek(&mut self, pos: SeekFrom) -> Result<u64>
1.55.0 · Source§fn rewind(&mut self) -> Result<(), Error>
fn rewind(&mut self) -> Result<(), Error>
Source§fn stream_len(&mut self) -> Result<u64, Error>
fn stream_len(&mut self) -> Result<u64, Error>
seek_stream_len)