Documentation
¶
Index ¶
- func NewDataReadError(blockIndex uint32, diskType footer.DiskType, err error) error
- func NewSectorReadError(blockIndex, sectorIndex uint32, err error) error
- type Block
- type DataReadError
- type DataReader
- type DifferencingDiskBlockFactory
- func (f *DifferencingDiskBlockFactory) Create(blockIndex uint32) (*Block, error)
- func (f *DifferencingDiskBlockFactory) GetBitmapFactory() *bitmap.Factory
- func (f *DifferencingDiskBlockFactory) GetBlockCount() int64
- func (f *DifferencingDiskBlockFactory) GetBlockSize() int64
- func (f *DifferencingDiskBlockFactory) GetFooterRange() *common.IndexRange
- func (f *DifferencingDiskBlockFactory) GetSector(block *Block, sectorIndex uint32) (*Sector, error)
- type DifferencingDiskBlockReader
- type DynamicDiskBlockFactory
- func (f *DynamicDiskBlockFactory) Create(blockIndex uint32) (*Block, error)
- func (f *DynamicDiskBlockFactory) GetBitmapFactory() *bitmap.Factory
- func (f *DynamicDiskBlockFactory) GetBlockCount() int64
- func (f *DynamicDiskBlockFactory) GetBlockSize() int64
- func (f *DynamicDiskBlockFactory) GetFooterRange() *common.IndexRange
- func (f *DynamicDiskBlockFactory) GetSector(block *Block, sectorIndex uint32) (*Sector, error)
- type DynamicDiskBlockReader
- type Factory
- type FactoryParams
- type FixedDiskBlockFactory
- func (f *FixedDiskBlockFactory) Create(blockIndex uint32) (*Block, error)
- func (f *FixedDiskBlockFactory) GetBlockCount() int64
- func (f *FixedDiskBlockFactory) GetBlockSize() int64
- func (f *FixedDiskBlockFactory) GetFooterRange() *common.IndexRange
- func (f *FixedDiskBlockFactory) GetSector(block *Block, sectorIndex uint32) (*Sector, error)
- type FixedDiskBlockReader
- type Sector
- type SectorFactory
- type SectorReadError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDataReadError ¶
NewDataReadError returns a new DataReadError instance. The parameter blockIndex represents index of the block whose bitmap failed to parse The parameter err is the underlying error for parse failure.
func NewSectorReadError ¶
NewSectorReadError returns a new SectorReadError instance. The parameter blockIndex represents index of the block The parameter sectorIndex represents index of the sector within the block The parameter err is the underlying read error.
Types ¶
type Block ¶
type Block struct { // BlockIndex is the index of the block, block indices are consecutive values starting from 0 // for the first block. BlockIndex uint32 // IsEmpty is true if the block is empty, for dynamic and differencing disk the BAT entry of an // empty block contains 0xFFFFFFFF. IsEmpty bool // BitMap represents 'bitmap section' of the block. Each bit in the bitmap represents the state // of a sector in the block. // // This field is always nil for fixed disk. For Dynamic and differencing disk this field is set // if the block is not marked as empty in the BAT. // // The dynamic and differencing subsystem reads the sector marked as dirty from the current disk, // if a sector is marked as clean and if the current disk disk is dynamic then the sector will be // read from the parent disk. BitMap *bitmap.BitMap // LogicalRange holds the absolute start and end byte offset of the block's 'data' in the converted // fixed disk. When converting dynamic and differential vhd to fixed vhd, we place all block's 'data' // consecutively starting at byte offset 0 of the fixed disk. LogicalRange *common.IndexRange // VhdUniqueId holds the unique identifier of the vhd that the block belongs to. The vhd unique // identifier is stored in the vhd footer unique id field. VhdUniqueID *common.UUID // blockDataReader is the reader for reading the block's 'data' from the disk. BlockDataReader DataReader // contains filtered or unexported fields }
Block type represents Block of a vhd. A block of a dynamic or differential vhd starts with a 'bitmap' section followed by the 'data' section, in case of fixed vhd the entire block is used to store the 'data'.
func (*Block) Data ¶
Data returns the block data, the content of entire block in case of fixed vhd and the content of block's data section in case of dynamic and differential vhd.
func (*Block) GetSector ¶
GetSector returns an instance of Sector representing a sector with the given Id in this block. The parameter sectorIndex is the index of the sector in this block to read.
func (*Block) GetSectorCount ¶
GetSectorCount returns the number of sectors in the block.
type DataReadError ¶
type DataReadError struct { BlockIndex uint32 DiskType footer.DiskType // contains filtered or unexported fields }
DataReadError is the error type representing block data read error.
func (*DataReadError) Error ¶
func (e *DataReadError) Error() string
Error returns the string representation of the BlockDataReadError instance.
func (*DataReadError) GetInnerErr ¶
func (e *DataReadError) GetInnerErr() error
GetInnerErr returns the inner error, this method satisfies InnerErr interface
type DataReader ¶
type DataReader interface { // Read reads the disk block identified by the parameter block // Read(block *Block) ([]byte, error) }
DataReader interface that all block readers specific to disk type (fixed, dynamic, differencing) needs to satisfy.
type DifferencingDiskBlockFactory ¶
type DifferencingDiskBlockFactory struct {
// contains filtered or unexported fields
}
DifferencingDiskBlockFactory is a type which is used for following purposes To create a Block instance representing a differencing disk block To get the number of blocks in the differencing disk To get the block size of the block in differencing disk To get a Sector instance representing sector of differencing disk's block To get the logical footer range of fixed disk generated from the differencing disk and it's parents.
func NewDifferencingDiskBlockFactory ¶
func NewDifferencingDiskBlockFactory(params *FactoryParams) *DifferencingDiskBlockFactory
NewDifferencingDiskBlockFactory creates a DifferencingDiskBlockFactory instance which can be used to create a Block objects representing differential disk block of a size specified in header BlockSize field parameter vhdFile represents the differencing disk.
func (*DifferencingDiskBlockFactory) Create ¶
func (f *DifferencingDiskBlockFactory) Create(blockIndex uint32) (*Block, error)
Create returns an instance of Block which represents a differencing disk block, the parameter blockIndex identifies the block. If the block to be read is marked as empty in the differencing disk BAT then this method will query parent disk for the same block. This function return error if the block cannot be created due to any read error.
func (*DifferencingDiskBlockFactory) GetBitmapFactory ¶
func (f *DifferencingDiskBlockFactory) GetBitmapFactory() *bitmap.Factory
GetBitmapFactory returns an instance of BitmapFactory that can be used to create the bitmap of a block by reading block from differencing disk.
func (*DifferencingDiskBlockFactory) GetBlockCount ¶
func (f *DifferencingDiskBlockFactory) GetBlockCount() int64
GetBlockCount returns the number of blocks in the differential disk.
func (*DifferencingDiskBlockFactory) GetBlockSize ¶
func (f *DifferencingDiskBlockFactory) GetBlockSize() int64
GetBlockSize returns the size of the 'data section' of block in bytes in the differential disk.
func (*DifferencingDiskBlockFactory) GetFooterRange ¶
func (f *DifferencingDiskBlockFactory) GetFooterRange() *common.IndexRange
GetFooterRange returns the logical range of the footer when converting this differential vhd to fixed logical range of footer is the absolute start and end byte offset of the footer.
func (*DifferencingDiskBlockFactory) GetSector ¶
func (f *DifferencingDiskBlockFactory) GetSector(block *Block, sectorIndex uint32) (*Sector, error)
GetSector returns an instance of Sector in a differencing disk, parameter block object identifies the block containing the sector, the parameter sectorIndex identifies the sector in the block. If the sector to be read is marked as empty in the block's bitmap then this method will query parent disk for the same sector. This function return error if the sector cannot be created due to any read error or if the requested sector index is invalid.
type DifferencingDiskBlockReader ¶
type DifferencingDiskBlockReader struct {
// contains filtered or unexported fields
}
DifferencingDiskBlockReader type satisfies BlockDataReader interface, implementation of BlockDataReader::Read by this type can read the 'data' section of a differencing disk's block.
func NewDifferencingDiskBlockReader ¶
func NewDifferencingDiskBlockReader(vhdReader *reader.VhdReader, blockAllocationTable *bat.BlockAllocationTable, blockSizeInBytes uint32) *DifferencingDiskBlockReader
NewDifferencingDiskBlockReader create a new instance of DifferencingDiskBlockReader which read the 'data' section of differencing disk block. The parameter vhdReader is the reader to read the disk The parameter blockAllocationTable represents the disk's BAT The parameter blockSizeInBytes is the size of the differencing disk block
type DynamicDiskBlockFactory ¶
type DynamicDiskBlockFactory struct {
// contains filtered or unexported fields
}
DynamicDiskBlockFactory is a type which is used for following purposes To create a Block instance representing a dynamic disk block To get the number of blocks in the dynamic disk To get the block size of the block in dynamic disk To get a Sector instance representing sector of dynamic disk's block To get the logical footer range of fixed disk generated from the dynamic disk
func NewDynamicDiskFactory ¶
func NewDynamicDiskFactory(params *FactoryParams) *DynamicDiskBlockFactory
NewDynamicDiskFactory creates a DynamicDiskBlockFactory instance which can be used to create a Block objects representing dynamic disk block of a size specified in header BlockSize field parameter params contains header, footer, BAT of dynamic disk and reader to read the disk.
func (*DynamicDiskBlockFactory) Create ¶
func (f *DynamicDiskBlockFactory) Create(blockIndex uint32) (*Block, error)
Create returns an instance of Block which represents a dynamic disk block, the parameter blockIndex identifies the block. This function return error if the block cannot be created due to any read error.
func (*DynamicDiskBlockFactory) GetBitmapFactory ¶
func (f *DynamicDiskBlockFactory) GetBitmapFactory() *bitmap.Factory
GetBitmapFactory returns an instance of BitmapFactory that can be used to create the bitmap of a block by reading block from dynamic disk.
func (*DynamicDiskBlockFactory) GetBlockCount ¶
func (f *DynamicDiskBlockFactory) GetBlockCount() int64
GetBlockCount returns the number of blocks in the dynamic disk.
func (*DynamicDiskBlockFactory) GetBlockSize ¶
func (f *DynamicDiskBlockFactory) GetBlockSize() int64
GetBlockSize returns the size of the 'data section' of block in bytes in the dynamic disk.
func (*DynamicDiskBlockFactory) GetFooterRange ¶
func (f *DynamicDiskBlockFactory) GetFooterRange() *common.IndexRange
GetFooterRange returns the logical range of the footer when converting this dynamic vhd to fixed logical range of footer is the absolute start and end byte offset of the footer.
func (*DynamicDiskBlockFactory) GetSector ¶
func (f *DynamicDiskBlockFactory) GetSector(block *Block, sectorIndex uint32) (*Sector, error)
GetSector returns an instance of Sector in a dynamic disk, parameter block object identifying the block containing the sector, the parameter sectorIndex identifies the sector in the block. This function return error if the sector cannot be created due to any read error or if the requested sector index is invalid.
type DynamicDiskBlockReader ¶
type DynamicDiskBlockReader struct {
// contains filtered or unexported fields
}
DynamicDiskBlockReader type satisfies BlockDataReader interface, implementation of BlockDataReader::Read by this type can read the 'data' section of a dynamic disk's block.
func NewDynamicDiskBlockReader ¶
func NewDynamicDiskBlockReader(vhdReader *reader.VhdReader, blockAllocationTable *bat.BlockAllocationTable, blockSizeInBytes uint32) *DynamicDiskBlockReader
NewDynamicDiskBlockReader create a new instance of DynamicDiskBlockReader which read the 'data' section of dynamic disk block. The parameter vhdReader is the reader to read the disk The parameter blockAllocationTable represents the disk's BAT The parameter blockSizeInBytes is the size of the dynamic disk block
type Factory ¶
type Factory interface { GetBlockCount() int64 GetBlockSize() int64 Create(blockIndex uint32) (*Block, error) GetSector(block *Block, sectorIndex uint32) (*Sector, error) }
Factory interface that all block factories specific to disk type (fixed, dynamic, differencing) needs to satisfy.
type FactoryParams ¶
type FactoryParams struct { VhdHeader *header.Header BlockAllocationTable *bat.BlockAllocationTable VhdReader *reader.VhdReader ParentBlockFactory Factory }
FactoryParams represents type of the parameter for different disk block factories.
type FixedDiskBlockFactory ¶
type FixedDiskBlockFactory struct {
// contains filtered or unexported fields
}
FixedDiskBlockFactory is a type which is used for following purposes To create a Block instance representing a fixed disk block To get the number of blocks in the fixed disk To get the block size of the block in fixed disk To get a Sector instance representing sector of fixed disk's block To get the logical footer range of the fixed disk
func NewFixedDiskBlockFactory ¶
func NewFixedDiskBlockFactory(params *FactoryParams, blockSize int64) *FixedDiskBlockFactory
NewFixedDiskBlockFactory creates a FixedDiskBlockFactory instance which can be used to create a Block objects representing fixed disk block of a specific size, parameter params contains header, footer of the fixed disk and reader to read the disk, parameter blockSize represents the size of blocks in the fixed disk
func NewFixedDiskBlockFactoryWithDefaultBlockSize ¶
func NewFixedDiskBlockFactoryWithDefaultBlockSize(params *FactoryParams) *FixedDiskBlockFactory
NewFixedDiskBlockFactoryWithDefaultBlockSize creates a FixedDiskBlockFactory instance which can be used to create a Block object representing fixed disk block of default size 512 KB. parameter params contains header, footer of the fixed disk and reader to read the disk.
func (*FixedDiskBlockFactory) Create ¶
func (f *FixedDiskBlockFactory) Create(blockIndex uint32) (*Block, error)
Create returns an instance of Block which represents a fixed disk block, the parameter blockIndex identifies the block.
func (*FixedDiskBlockFactory) GetBlockCount ¶
func (f *FixedDiskBlockFactory) GetBlockCount() int64
GetBlockCount returns the number of blocks in the fixed disk.
func (*FixedDiskBlockFactory) GetBlockSize ¶
func (f *FixedDiskBlockFactory) GetBlockSize() int64
GetBlockSize returns the size of the block in bytes of the fixed disk.
func (*FixedDiskBlockFactory) GetFooterRange ¶
func (f *FixedDiskBlockFactory) GetFooterRange() *common.IndexRange
GetFooterRange returns the logical range of the footer of the fixed disk, logical range of footer is the absolute start and end byte offset of the footer.
func (*FixedDiskBlockFactory) GetSector ¶
func (f *FixedDiskBlockFactory) GetSector(block *Block, sectorIndex uint32) (*Sector, error)
GetSector returns an instance of Sector in a fixed disk, parameter block describes the block containing the sector, the parameter sectorIndex identifies the sector in the block. This function return error if the sector cannot be created due to any read error or if the requested sector index is invalid.
type FixedDiskBlockReader ¶
type FixedDiskBlockReader struct {
// contains filtered or unexported fields
}
FixedDiskBlockReader type satisfies BlockDataReader interface, implementation of BlockDataReader::Read by this type can read the data from a block of a fixed disk.
func NewFixedDiskBlockReader ¶
func NewFixedDiskBlockReader(vhdReader *reader.VhdReader, blockSizeInBytes uint32) *FixedDiskBlockReader
NewFixedDiskBlockReader create a new instance of FixedDiskBlockReader which can read data from a fixed disk block. The parameter vhdReader is the reader to read the disk The parameter blockSizeInBytes is the size of the fixed disk block
type SectorFactory ¶
type SectorFactory struct {
// contains filtered or unexported fields
}
SectorFactory type is used to create Sector instance by reading 512 byte sector from block's 'data section'.
func NewSectorFactory ¶
func NewSectorFactory(vhdReader *reader.VhdReader, blockHasData func(uint32) bool, getBlockAddress func(uint32) int64) *SectorFactory
NewSectorFactory creates a new instance of SectorFactory, which can be used to create Sector instances by reading 512 byte sector from block's 'data section' vhdReader is the reader to be used to read the sector, blockHasData is a function which can be used to check a block is empty by providing block identifier, getBlockAddress is a function which can be used to fetch the absolute byte offset of a block by providing block identifier.
func (*SectorFactory) Create ¶
func (f *SectorFactory) Create(block *Block, sectorIndex uint32) (*Sector, error)
Create creates an instance of Sector by reading a 512 byte sector from the 'data section' of a block. block describes the block containing the sector, sectorIndex identifies the sector to read. This function return error if requested sector is invalid or in case of any read error.
func (*SectorFactory) CreateEmptySector ¶
func (f *SectorFactory) CreateEmptySector(blockIndex, sectorIndex uint32) *Sector
CreateEmptySector creates an instance of Sector representing empty sector. The Data property of this sector will be a slice of 512 bytes filled with zeros.
type SectorReadError ¶
type SectorReadError struct { BlockIndex uint32 SectorIndex uint32 // contains filtered or unexported fields }
SectorReadError is the error type representing block's sector read error.
func (*SectorReadError) Error ¶
func (e *SectorReadError) Error() string
Error returns the string representation of the SectorReadError instance.