in vhdcore/vhdfile/vhdFile.go [42:80]
func (f *VhdFile) GetBlockFactory() (block.Factory, error) {
params := &block.FactoryParams{
VhdHeader: f.Header,
VhdFooter: f.Footer,
VhdReader: f.VhdReader,
}
switch f.GetDiskType() {
case footer.DiskTypeFixed:
return block.NewFixedDiskBlockFactoryWithDefaultBlockSize(params), nil
case footer.DiskTypeDynamic:
params.BlockAllocationTable = f.BlockAllocationTable
return block.NewDynamicDiskFactory(params), nil
case footer.DiskTypeDifferencing:
params.BlockAllocationTable = f.BlockAllocationTable
parentVhdFile := f.Parent
if parentVhdFile.GetDiskType() == footer.DiskTypeFixed {
params.ParentBlockFactory = block.NewFixedDiskBlockFactory(
&block.FactoryParams{
VhdHeader: parentVhdFile.Header,
VhdFooter: parentVhdFile.Footer,
VhdReader: parentVhdFile.VhdReader,
},
int64(f.Header.BlockSize)) // The block-size of parent FixedDisk and this DifferentialDisk will be same.
} else {
var err error
params.ParentBlockFactory, err = parentVhdFile.GetBlockFactory()
if err != nil {
return nil, err
}
}
return block.NewDifferencingDiskBlockFactory(params), nil
}
return nil, fmt.Errorf("Unsupported disk format: %d", f.GetDiskType())
}