Documentation ¶
Index ¶
- func NewBlockAllocationTableParseError(batItemIndex uint32, err error) error
- type BlockAllocationTable
- func (b *BlockAllocationTable) GetBitmapAddress(blockIndex uint32) int64
- func (b *BlockAllocationTable) GetBitmapSizeInBytes() int32
- func (b *BlockAllocationTable) GetBlockDataAddress(blockIndex uint32) int64
- func (b *BlockAllocationTable) GetSectorPaddedBitmapSizeInBytes() int32
- func (b *BlockAllocationTable) HasData(blockIndex uint32) bool
- type BlockAllocationTableFactory
- type BlockAllocationTableParseError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBlockAllocationTableParseError ¶
NewBlockAllocationTableParseError returns a new BlockAllocationTableParseError instance. The parameter batItemIndex represents BAT index failed to parse The parameter err is the underlying error for parse failure.
Types ¶
type BlockAllocationTable ¶
type BlockAllocationTable struct { BATEntriesCount uint32 BAT []uint32 // contains filtered or unexported fields }
BlockAllocationTable type represents the Block Allocation Table (BAT) of the disk, BAT served as index to access the disk's blocks. A block is a unit of expansion for dynamic and differencing hard disks. All blocks within a given image must be the same size. The number of entries in the BAT is the number of blocks needed to store the contents of the disk when fully expanded. Each entry in this table is the absolute sector offset to a block. Each entry is four bytes long. if the disk is not fully expanded then, even though BAT has entries reserved for unexpanded blocks, the corresponding block will not exists. All such unused table entries are initialized to 0xFFFFFFFF. A block consists of two sections 'data section' and 'block bitmap section'. The 'BlockSize' field of the disk header is the size of the 'data section' of the block, it does not include the size of the 'block bitmap section'. Each bit in the bitmap indicates the state of the corresponding sector in 'data section', 1 indicates sector contains valid data, 0 indicates the sector have never been modified.
func NewBlockAllocationTable ¶
func NewBlockAllocationTable(blockSize uint32, bat []uint32) *BlockAllocationTable
NewBlockAllocationTable creates an instance of BlockAllocationTable, BAT is the block allocation table, each entry in this table is the absolute sector offset to a block, blockSize is the size of block's 'data section' in bytes.
func (*BlockAllocationTable) GetBitmapAddress ¶
func (b *BlockAllocationTable) GetBitmapAddress(blockIndex uint32) int64
GetBitmapAddress returns the address of the 'block bitmap section' of a given block. Address is the absolute byte offset of the 'block bitmap section'. A block consists of 'block bitmap section' and 'data section'
func (*BlockAllocationTable) GetBitmapSizeInBytes ¶
func (b *BlockAllocationTable) GetBitmapSizeInBytes() int32
GetBitmapSizeInBytes returns the size of the 'block bitmap section' that stores the state of the sectors in block's 'data section'. This means the number of bits in the bitmap is equivalent to the number of sectors in 'data section', dividing this number by 8 will yield the number of bytes required to store the bitmap. As per vhd specification sectors per block must be power of two. The sector length is always 512 bytes. This means the block size will be power of two as well e.g. 512 * 2^3, 512 * 2^4, 512 * 2^5 etc..
func (*BlockAllocationTable) GetBlockDataAddress ¶
func (b *BlockAllocationTable) GetBlockDataAddress(blockIndex uint32) int64
GetBlockDataAddress returns the address of the 'data section' of a given block. Address is the absolute byte offset of the 'data section'. A block consists of 'block bitmap section' and 'data section'
func (*BlockAllocationTable) GetSectorPaddedBitmapSizeInBytes ¶
func (b *BlockAllocationTable) GetSectorPaddedBitmapSizeInBytes() int32
GetSectorPaddedBitmapSizeInBytes returns the size of the 'block bitmap section' in bytes which is padded to a 512-byte sector boundary. The bitmap of a block is always padded to a 512-byte sector boundary.
func (*BlockAllocationTable) HasData ¶
func (b *BlockAllocationTable) HasData(blockIndex uint32) bool
HasData returns true if the given block has not yet expanded hence contains no data.
type BlockAllocationTableFactory ¶
type BlockAllocationTableFactory struct {
// contains filtered or unexported fields
}
BlockAllocationTableFactory type is used to create BlockAllocationTable instance by reading BAT section of the disk which follows the header
func NewBlockAllocationFactory ¶
func NewBlockAllocationFactory(vhdReader *reader.VhdReader, vhdHeader *header.Header) *BlockAllocationTableFactory
NewBlockAllocationFactory creates a new instance of BlockAllocationTableFactory, which can be used to create BlockAllocationTable instance by reading BAT section of the Vhd. vhdReader is the reader to be used to read the entry, vhdHeader is the header structure representing the disk header.
func (*BlockAllocationTableFactory) Create ¶
func (f *BlockAllocationTableFactory) Create() (*BlockAllocationTable, error)
Create creates a BlockAllocationTable instance by reading the BAT section of the disk. This function return error if any error occurs while reading or parsing the BAT entries.
type BlockAllocationTableParseError ¶
type BlockAllocationTableParseError struct { BATItemIndex uint32 // contains filtered or unexported fields }
BlockAllocationTableParseError is the error type representing BAT parse error.
func (*BlockAllocationTableParseError) Error ¶
func (e *BlockAllocationTableParseError) Error() string
Error returns the string representation of the BlockAllocationTableParseError instance.
func (*BlockAllocationTableParseError) GetInnerErr ¶
func (e *BlockAllocationTableParseError) GetInnerErr() error
GetInnerErr returns the inner error, this method satisfies InnerErr interface