package vhd

import "github.com/rubiojr/go-vhd/vhd"

Package to work with VHD images See https://technet.microsoft.com/en-us/virtualization/bb676673.aspx

Index

Constants

const FOURK_SECTOR_SIZE = 4096
const SECTOR_SIZE = 512
const VHD_BLOCK_SIZE = 2 * 1024 * 1024 // 2MB
const VHD_COOKIE = "636f6e6563746978" // conectix
const VHD_CREATOR_APP = "676f2d766864" // go-vhd
const VHD_CREATOR_HOST_OS = "5769326B" // Win2k
const VHD_DYN_COOKIE = "6378737061727365" // cxsparse
const VHD_EXTRA_HEADER_SIZE = 1024
const VHD_HEADER_SIZE = 512

Functions

func RawToFixed

func RawToFixed(f *os.File, options *VHDOptions)

Types

type VHD

type VHD struct {
	Footer      VHDHeader
	ExtraHeader VHDExtraHeader
}

A VDH file

func FromFile

func FromFile(f *os.File) (vhd VHD)

func VHDCreateSparse

func VHDCreateSparse(size uint64, name string, options VHDOptions) VHD

func (*VHD) PrintExtraHeader

func (vhd *VHD) PrintExtraHeader()

func (*VHD) PrintFooter

func (vhd *VHD) PrintFooter()

func (*VHD) PrintInfo

func (vhd *VHD) PrintInfo()

type VHDExtraHeader

type VHDExtraHeader struct {
	Cookie              [8]byte
	DataOffset          [8]byte
	TableOffset         [8]byte
	HeaderVersion       [4]byte
	MaxTableEntries     [4]byte
	BlockSize           [4]byte
	Checksum            [4]byte
	ParentUUID          [16]byte
	ParentTimestamp     [4]byte
	Reserved            [4]byte
	ParentUnicodeName   [512]byte
	ParentLocatorEntry1 [24]byte
	ParentLocatorEntry2 [24]byte
	ParentLocatorEntry3 [24]byte
	ParentLocatorEntry4 [24]byte
	ParentLocatorEntry5 [24]byte
	ParentLocatorEntry6 [24]byte
	ParentLocatorEntry7 [24]byte
	ParentLocatorEntry8 [24]byte
	Reserved2           [256]byte
}

VHD extra header, for dynamic and differential disks

func (*VHDExtraHeader) CookieString

func (header *VHDExtraHeader) CookieString() string

type VHDHeader

type VHDHeader struct {
	Cookie             [8]byte
	Features           [4]byte
	FileFormatVersion  [4]byte
	DataOffset         [8]byte
	Timestamp          [4]byte
	CreatorApplication [4]byte
	CreatorVersion     [4]byte
	CreatorHostOS      [4]byte
	OriginalSize       [8]byte
	CurrentSize        [8]byte
	DiskGeometry       [4]byte
	DiskType           [4]byte
	Checksum           [4]byte
	UniqueId           [16]byte
	SavedState         [1]byte
	Reserved           [427]byte
}

VHD Header

func CreateFixedHeader

func CreateFixedHeader(size uint64, options *VHDOptions) VHDHeader

func (*VHDHeader) DiskTypeStr

func (h *VHDHeader) DiskTypeStr() (dt string)

func (*VHDHeader) TimestampTime

func (h *VHDHeader) TimestampTime() time.Time

Return the timestamp of the header

type VHDOptions

type VHDOptions struct {
	UUID      string
	Timestamp int64
}

Options for the CreateSparseVHD function

Source Files

util.go vhd.go

Version
v0.0.0-20200706122120-ccecf6c0760f (latest)
Published
Jul 6, 2020
Platform
js/wasm
Imports
11 packages
Last checked
1 month ago

Tools for package owners.