Documentation ¶
Index ¶
Constants ¶
const ( // VhdFeatureNoFeaturesEnabled indicates that hard disk image has no special features enabled in it. // VhdFeatureNoFeaturesEnabled VhdFeature = 0x00000000 // VhdFeatureTemporary indicates that current disk is a temporary disk. A temporary disk designation // indicates to an application that this disk is a candidate for deletion on shutdown. // VhdFeatureTemporary = 0x00000001 // VhdFeatureReserved represents a bit must always be set to 1. All other bits are also reserved // and should be set to 0 // VhdFeatureReserved = 0x00000002 )
Variables ¶
This section is empty.
Functions ¶
func NewParseError ¶
NewParseError returns a new ParseError instance. The parameter footerField represents the field in the footer that failed to parse The parameter err is the underlying error for parse failure.
func SerializeFooter ¶
SerializeFooter returns the given VhdFooter instance as byte slice of length 512 bytes.
Types ¶
type DiskGeometry ¶
type DiskGeometry struct { // Offset = 0, Size = 2 // Stored in big-endian format Cylinder uint16 // Offset = 2, Size = 1 Heads byte // Offset = 3, Size = 1 Sectors byte }
DiskGeometry represents the cylinder, heads and sectors (CHS) per track.
func CreateNewDiskGeometry ¶
func CreateNewDiskGeometry(virtualSize int64) *DiskGeometry
CreateNewDiskGeometry creates a new DiskGeometry from the given virtual size. CHS field values are calculated based on the total data sectors present in the disk image.
func (*DiskGeometry) CreateCopy ¶
func (d *DiskGeometry) CreateCopy() *DiskGeometry
CreateCopy creates a copy of this instance
func (*DiskGeometry) Equals ¶
func (d *DiskGeometry) Equals(other *DiskGeometry) bool
Equals returns true if this and other points to the same instance or if CHS fields of pointed instances are same
func (*DiskGeometry) String ¶
func (d *DiskGeometry) String() string
String returns the string representation of this range, this satisfies stringer interface.
type DiskType ¶
type DiskType uint32
DiskType type represents the type of the disk, Value is stored in the footer in big-endian format.
const ( // DiskTypeNone represents a nil disk type // DiskTypeNone DiskType = 0 // DiskTypeFixed represents a fixed disk type // DiskTypeFixed DiskType = 2 // DiskTypeDynamic represents a dynamic disk type // DiskTypeDynamic DiskType = 3 // DiskTypeDifferencing represents a differencing disk type // DiskTypeDifferencing DiskType = 4 )
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
Factory type is used to create Footer instance by reading vhd footer section.
func NewFactory ¶
NewFactory creates a new instance of Factory, which can be used to create a Footer instance by reading the footer section using VhdReader.
type Footer ¶
type Footer struct { vhdcore.Cookie Features VhdFeature FileFormatVersion VhdFileFormatVersion // Absolute byte offset to the header structure, this is used for dynamic disks // and differencing disks. Fixed disk does not have header this field is set to // 0xFFFFFFFF for fixed disk. HeaderOffset int64 TimeStamp *time.Time CreatorApplication string CreatorVersion VhdCreatorVersion CreatorHostOsType HostOsType PhysicalSize int64 VirtualSize int64 DiskGeometry *DiskGeometry DiskType DiskType CheckSum uint32 UniqueID *common.UUID SavedState bool Reserved []byte RawData []byte }Cookie *
Footer represents the footer of the vhd, the size of the footer is 512 bytes. The last 512 bytes of the disk is footer. In case of dynamic and differential vhds, the footer is replicated at the beginning of the disk as well.
func (*Footer) CreateCopy ¶
CreateCopy creates and returns a deep copy of this instance.
type HostOsType ¶
type HostOsType uint32
HostOsType represents the host operating system a disk image is created on. Value is stored in the footer in big-endian format.
const ( // HostOsTypeNone represents a nil host OS type HostOsTypeNone HostOsType = 0 // HostOsTypeWindows represents a Windows OS type HostOsTypeWindows HostOsType = 0x5769326B // HostOsTypeMacintosh represents a MAC OS type HostOsTypeMacintosh HostOsType = 0x4D616320 )
func (HostOsType) String ¶
func (h HostOsType) String() string
String returns the string representation of the HostOsType. If the int type value does not match with the predefined OS types then this function convert the int to string and return
type ParseError ¶
type ParseError struct { // contains filtered or unexported fields }
ParseError is the error type representing disk footer parse error.
func (*ParseError) Error ¶
func (e *ParseError) Error() string
Error returns the string representation of the ParseError instance.
func (*ParseError) GetInnerErr ¶
func (e *ParseError) GetInnerErr() error
GetInnerErr returns the inner error, this method satisfies InnerErr interface
type VhdCreatorVersion ¶
type VhdCreatorVersion uint32
VhdCreatorVersion represents the major/minor version of the application that created the hard disk image. The version is stored in the vhd footer in big-endian format.
const ( // VhdCreatorVersionNone represents a nil host Creator version VhdCreatorVersionNone VhdCreatorVersion = 0 // VhdCreatorVersionVS2004 represents the value set by Virtual Server 2004 VhdCreatorVersionVS2004 VhdCreatorVersion = 0x00010000 // VhdCreatorVersionVPC2004 represents the value set by Virtual PC 2004 VhdCreatorVersionVPC2004 VhdCreatorVersion = 0x00050000 // VhdCreatorVersionCSUP2011 represents a value set by CSUP 2011 VhdCreatorVersionCSUP2011 VhdCreatorVersion = 0x00070000 )
func (VhdCreatorVersion) String ¶
func (v VhdCreatorVersion) String() string
String returns the string representation of the VhdCreatorVersion. If the int VhdCreatorVersion value does not match with the predefined CreatorVersions then this function convert the int to string and return.
type VhdFeature ¶
type VhdFeature uint32
VhdFeature represents a bit field used to indicate specific feature support. Value is stored in the footer in big-endian format.
func (VhdFeature) String ¶
func (v VhdFeature) String() string
String returns the string representation of the VhdFeature. If the int VhdFeature value does not match with the predefined VhdFeatures then this function convert int to string and return
type VhdFileFormatVersion ¶
type VhdFileFormatVersion uint32
VhdFileFormatVersion represents the version of the specification used in creating the vhd. The version is stored in the vhd footer in big-endian format. This is a 4 byte value - most-significant two bytes are for the major version. The least-significant two bytes are the minor version
const VhdFileFormatVersionDefault VhdFileFormatVersion = 0x00010000
VhdFileFormatVersionDefault represents the currently supported vhd specification version.
const VhdFileFormatVersionNone VhdFileFormatVersion = 0
VhdFileFormatVersionNone represents invalid version
func (VhdFileFormatVersion) IsSupported ¶
func (v VhdFileFormatVersion) IsSupported() bool
IsSupported returns true if this instance represents a supported vhd specification version.