header

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: 3

Documentation

Index

Constants

View Source
const VhdHeaderVersionNone = 0

VhdHeaderVersionNone indicates an invalid VHD specification version

Variables

This section is empty.

Functions

func NewParseError

func NewParseError(headerField string, err error) error

NewParseError returns a new ParseError instance. The parameter headerField represents the field in the header that failed to parse The parameter err is the underlying error for parse failure.

Types

type Factory

type Factory struct {
	// contains filtered or unexported fields
}

Factory type is used to create VhdHeader instance by reading vhd header section.

func NewFactory

func NewFactory(vhdReader *reader.VhdReader, headerOffset int64) *Factory

NewFactory creates a new instance of Factory, which can be used to create a VhdHeader instance by reading the header section using vhdReader.

func (*Factory) Create

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

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

type Header struct {
	// Offset =  0, Size = 8
	Cookie *vhdcore.Cookie
	// Offset =  8, Size = 8
	DataOffset int64
	// Offset = 16, Size = 8
	TableOffset int64
	// Offset = 24, Size = 4
	HeaderVersion VhdHeaderVersion
	// Offset = 28, Size = 4
	MaxTableEntries uint32
	// Offset = 32, Size = 4
	BlockSize uint32
	// Offset = 36, Size = 4
	CheckSum uint32
	// Offset = 40, Size = 16
	ParentUniqueID *common.UUID
	// Offset = 56, Size = 4
	ParentTimeStamp *time.Time
	// Offset = 60, Size = 4
	Reserved uint32
	// Offset = 64, Size = 512
	// This field contains a Unicode string (UTF-16) of the parent hard disk filename.
	// This will be absolute path to the parent disk of differencing disk.
	// If this field is set, then the ParentLocators collection will also contain
	// an entry with the same path, the PlatformCode of that field will be PlatformCodeW2Ku.
	ParentPath string
	// Offset = 576, Count = 8
	// Collection of entries store an absolute byte offset in the file where the
	// parent locator for a differencing hard disk is stored.
	// This field is used only for differencing disks and will be set to zero for
	// dynamic disks.
	ParentLocators parentlocator.ParentLocators
	// Offset = 0, Size = 1024
	// The entire header as raw bytes
	RawData []byte
}

Header represents the header of the vhd, size of the header is 1024 bytes. The header structure is present only for expanding disks (i.e. dynamic and differencing disks.) In case of dynamic and differential vhds the footer is replicated at the beginning of the disk as well, the header structure follows this replicated footer, the field 'HeaderOffset' in the footer contains absolute offset to the header structure.

type ParseError

type ParseError struct {
	HeaderField string
	// contains filtered or unexported fields
}

ParseError is the error type representing disk header 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 VhdHeaderVersion

type VhdHeaderVersion uint32

VhdHeaderVersion represents the major/minor version of the specification used in creating the vhd. The version is stored in the vhd header in big-endian format.

const VhdHeaderSupportedVersion VhdHeaderVersion = 0x00010000

VhdHeaderSupportedVersion indicates the current VHD specification version

func (VhdHeaderVersion) IsSupported

func (v VhdHeaderVersion) IsSupported() bool

IsSupported returns true if this instance represents a supported VHD specification version.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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