Documentation
¶
Overview ¶
Package block provides block-level reading and decompression logic for virtual disks.
Package block provides block-level reading and sector I/O for virtual disks.
Index ¶
- type Block
- type BlockReader
- type VHDBlockReader
- func (br *VHDBlockReader) BlockCount() uint32
- func (br *VHDBlockReader) BlockSize() uint32
- func (br *VHDBlockReader) ReadAt(p []byte, virtualOffset int64) (int, error)
- func (br *VHDBlockReader) ReadBlock(blockIndex uint32) ([]byte, error)
- func (br *VHDBlockReader) ReadSectorBitmap(blockIndex uint32) (*bat.SectorBitmap, error)
- type VHDXBlockReader
- func (br *VHDXBlockReader) BlockCount() uint32
- func (br *VHDXBlockReader) BlockDescriptor(blockIndex uint32) (*types.BlockDescriptor, error)
- func (br *VHDXBlockReader) BlockSize() uint32
- func (br *VHDXBlockReader) ReadAt(p []byte, virtualOffset int64) (int, error)
- func (br *VHDXBlockReader) ReadBlock(blockIndex uint32) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Block ¶
type Block struct {
Index uint32 // Block index
Offset int64 // Physical offset in file
Size uint32 // Block size in bytes
State uint32 // Block state
}
Block represents a single block in a virtual disk.
type BlockReader ¶
type BlockReader interface {
// ReadBlock reads a single block by index.
ReadBlock(index uint32) ([]byte, error)
// ReadSector reads a single sector (512 bytes) at the given index.
ReadSector(index uint32) ([]byte, error)
// BlockCount returns the total number of blocks.
BlockCount() uint32
// BlockSize returns the size of each block in bytes.
BlockSize() uint32
}
BlockReader provides interface for reading blocks from virtual disks.
type VHDBlockReader ¶
type VHDBlockReader struct {
// contains filtered or unexported fields
}
VHDBlockReader reads block and sector data from VHD dynamic disks.
func NewVHDBlockReader ¶
func NewVHDBlockReader(r io.ReaderAt, b *types.VHDBlockAllocationTable, sectorSize uint32) *VHDBlockReader
NewVHDBlockReader creates a VHD block reader using a parsed BAT.
func (*VHDBlockReader) BlockCount ¶
func (br *VHDBlockReader) BlockCount() uint32
BlockCount returns the total number of blocks.
func (*VHDBlockReader) BlockSize ¶
func (br *VHDBlockReader) BlockSize() uint32
BlockSize returns the size in bytes of each block.
func (*VHDBlockReader) ReadAt ¶
func (br *VHDBlockReader) ReadAt(p []byte, virtualOffset int64) (int, error)
ReadAt implements io.ReaderAt — reads from the virtual disk address space.
func (*VHDBlockReader) ReadBlock ¶
func (br *VHDBlockReader) ReadBlock(blockIndex uint32) ([]byte, error)
ReadBlock reads the full data of the block at blockIndex (excluding sector bitmap).
func (*VHDBlockReader) ReadSectorBitmap ¶
func (br *VHDBlockReader) ReadSectorBitmap(blockIndex uint32) (*bat.SectorBitmap, error)
ReadSectorBitmap reads the raw sector bitmap for a given block.
type VHDXBlockReader ¶
type VHDXBlockReader struct {
// contains filtered or unexported fields
}
VHDXBlockReader reads block and sector data from VHDX disks.
func NewVHDXBlockReader ¶
func NewVHDXBlockReader(r io.ReaderAt, b *types.VHDXBlockAllocationTable, sectorSize uint32) *VHDXBlockReader
NewVHDXBlockReader creates a VHDX block reader using a parsed BAT.
func (*VHDXBlockReader) BlockCount ¶
func (br *VHDXBlockReader) BlockCount() uint32
BlockCount returns the total number of blocks.
func (*VHDXBlockReader) BlockDescriptor ¶
func (br *VHDXBlockReader) BlockDescriptor(blockIndex uint32) (*types.BlockDescriptor, error)
BlockDescriptor returns the descriptor for a block including its state and sector ranges.
func (*VHDXBlockReader) BlockSize ¶
func (br *VHDXBlockReader) BlockSize() uint32
BlockSize returns the size in bytes of each block.