footer

package
v0.0.0-...-7c30a37 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2023 License: MIT Imports: 7 Imported by: 9

Documentation

Index

Constants

View Source
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

func NewParseError(footerField string, err error) error

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

func SerializeFooter(footer *Footer) []byte

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
)

func (DiskType) String

func (d DiskType) String() string

String returns the string representation of the DiskType. If the int type value does not match with the predefined disk types then this function return the string "UnknownDiskType"

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

func NewFactory(vhdReader *reader.VhdReader) *Factory

NewFactory creates a new instance of Factory, which can be used to create a Footer instance by reading the footer section using VhdReader.

func (*Factory) Create

func (f *Factory) Create() (*Footer, error)

Create creates a Footer instance by reading the footer section of the disk. This function return error if any error occurs while reading or parsing the footer fields.

type Footer struct {
	// Offset =  0, Size = 8
	Cookie *vhdcore.Cookie
	// Offset =  8, Size = 4
	Features VhdFeature
	// Offset = 12, Size = 4
	FileFormatVersion VhdFileFormatVersion
	// Offset = 16, Size = 8
	// 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
	// Offset = 24, Size = 4
	TimeStamp *time.Time
	// Offset = 28, Size = 4
	CreatorApplication string
	// Offset = 32, Size = 4
	CreatorVersion VhdCreatorVersion
	// Offset = 36, Size = 4
	CreatorHostOsType HostOsType
	// Offset = 40, Size = 8
	PhysicalSize int64
	// Offset = 48, Size = 8
	VirtualSize int64
	// Offset = 56, Size = 4
	DiskGeometry *DiskGeometry
	// Offset = 60, Size = 4
	DiskType DiskType
	// Offset = 64, Size = 4
	CheckSum uint32
	// Offset = 68, Size = 16
	UniqueID *common.UUID
	// Offset = 84, Size = 1
	SavedState bool
	// Offset = 85, Size = 427
	Reserved []byte
	// Offset = 0, Size = 512
	RawData []byte
}

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

func (v *Footer) CreateCopy() *Footer

CreateCopy creates and returns a deep copy of this instance.

func (*Footer) Equal

func (v *Footer) Equal(other *Footer) bool

Equal returns true if this and other points to the same instance or if contents of the fields of these two instances are same.

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 {
	FooterField string
	// 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL