vmdk

package
v0.0.0-...-612096e Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2022 License: Apache-2.0 Imports: 10 Imported by: 13

Documentation

Index

Constants

View Source
const (
	// MARKER_EOS    = uint32(0x00000000)
	MARKER_GT = uint32(0x00000001)
	MARKER_GD = uint32(0x00000002)
	// MARKER_FOOTER = uint32(0x00000003)
	MARKER_GRAIN = uint32(0xffffffff)

	// COWD = uint32(0x434f5744)
	KDMV = uint32(0x564d444b)
)
View Source
const (
	SectionDiskDescriptorFile       = "disk descriptorfile"
	SectionExtentDescription        = "extent description"
	SectionDiskDataBase             = "the disk data base"
	SectionDDB                      = "ddb"
	Sector                    int64 = 0x200
)
View Source
const (
	SPARSE = "SPARSE"
)
View Source
const (
	StreamOptimized = "streamOptimized"
)

Variables

View Source
var (
	ErrReadSizeFormat   = "failed to read size error: actual(%d), expected(%d)"
	ErrSeekOffsetFormat = "failed to seek offset error: actual(%d), expected(%d)"
)
View Source
var (
	ErrUnSupportedDividedImage = xerrors.New("divided images are not supported")
	ErrUnSupportedType         = xerrors.New("type is not supported")
	ErrIsNotVMDK               = xerrors.New("this file is not vmdk")
)
View Source
var (
	ErrDataNotPresent = xerrors.New("data not present")
)

Functions

func Check

func Check(r io.Reader) (bool, error)

func Open

func Open(rs io.ReadSeeker, cache Cache[string, []byte]) (*io.SectionReader, error)

Types

type Cache

type Cache[K string, V any] interface {
	// Add cache data
	Add(key K, value V) bool

	// Get returns key's value from the cache
	Get(key K) (value V, ok bool)
}

type DiskDescriptor

type DiskDescriptor struct {
	Version    int
	CID        string
	ParentCID  string
	CreateType string
	Extents    []ExtentDescription
}

func ParseDiskDescriptor

func ParseDiskDescriptor(rs io.ReadSeeker, header Header) (DiskDescriptor, error)

type Entry

type Entry int32

type ExtentDescription

type ExtentDescription struct {
	Mode string
	Size int64
	Type string
	Name string
}

type GrainDirectory

type GrainDirectory struct {
	Entries []Entry
}

type GrainTable

type GrainTable struct {
	Entries []Entry
}
type Header struct {
	Signature          uint32
	Version            int32
	Flag               int32
	Capacity           int64
	GrainSize          int64
	DescriptorOffset   int64
	DescriptorSize     int64
	NumGTEsPerGT       int32
	RgdOffset          int64
	GdOffset           int64
	OverHead           int64
	UncleanShutdown    byte
	SingleEndLineChar  byte
	NonEndLineChar     byte
	DoubleEndLineChar1 byte
	DoubleEndLineChar2 byte
	CompressAlgorithm  int16
	Padding            [433]byte
}

Header specification https://www.vmware.com/app/vmdk/?src=vmdk

func ParseHeader

func ParseHeader(r io.Reader) (Header, error)

type Marker

type Marker struct {
	Value uint64
	Size  uint32
	Type  uint32
	Data  []byte
}

type SparseExtentHeader

type SparseExtentHeader struct {
	MagicNumber        uint32
	Version            uint32
	Flags              uint32
	Capacity           uint64
	GrainSize          uint64
	DescriptorOffset   uint64
	DescriptorSize     uint64
	NumberGTEsPerGT    uint32
	RgdOffset          uint64
	GdOffset           uint64
	OverHead           uint64
	UncleanShutdown    uint8
	SingleEndLineChar  byte
	NonEndLineChar     byte
	DoubleEndLineChar1 byte
	DoubleEndLineChar2 byte
	CompressAlgorithm  uint16
}

type StreamOptimizedImage

type StreamOptimizedImage struct {
	VMDK

	SparseExtentHeader SparseExtentHeader
	GD                 GrainDirectory
	GTCache            map[int64]GrainTable
}

func NewStreamOptimizedImage

func NewStreamOptimizedImage(v VMDK) (*StreamOptimizedImage, error)

func (*StreamOptimizedImage) ReadAt

func (v *StreamOptimizedImage) ReadAt(p []byte, off int64) (n int, err error)

func (*StreamOptimizedImage) Size

func (v *StreamOptimizedImage) Size() int64

func (*StreamOptimizedImage) TranslateOffset

func (v *StreamOptimizedImage) TranslateOffset(off int64) (int64, int64, error)

TranslateOffset is translates the physical offset of a VMDK into a logical offset.

type VMDK

type VMDK struct {
	Header         Header
	DiskDescriptor DiskDescriptor
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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