vmdk

package
v0.0.0-...-efdbaa7 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SECTOR_SIZE       = 512
	COWD_MAGIC        = "COWD"
	VMDK_MAGIC        = "KDMV"
	SESPARSE_MAGIC    = "\xbe\xba\xfe\xca"
	CONFIG_FILE_MAGIC = "# Di"

	SPARSEFLAG_COMPRESSED   = 0x10000
	SPARSEFLAG_EMBEDDED_LBA = 0x20000

	SESPARSE_GRAIN_TYPE_MASK        = 0xF000000000000000
	SESPARSE_GRAIN_TYPE_UNALLOCATED = 0x0000000000000000
	SESPARSE_GRAIN_TYPE_FALLTHROUGH = 0x1000000000000000
	SESPARSE_GRAIN_TYPE_ZERO        = 0x2000000000000000
	SESPARSE_GRAIN_TYPE_ALLOCATED   = 0x3000000000000000
)

Variables

View Source
var ErrFileAccessorNotAvailable = errors.New("file accessor needed to access for parent and extents from file")

Functions

This section is empty.

Types

type COWDSparseExtentHeader

type COWDSparseExtentHeader struct {
	Magic                       [4]byte
	Version                     uint32
	Flags                       uint32
	Capacity                    uint32
	GrainSize                   uint32
	PrimaryGrainDirectoryOffset uint32
	NumGrainDirectoryEntries    uint32
	NextFreeGrain               uint32
}

COWDSparseExtentHeader struct

func (*COWDSparseExtentHeader) GetCapacity

func (r *COWDSparseExtentHeader) GetCapacity() uint64

func (*COWDSparseExtentHeader) GetGrainSize

func (r *COWDSparseExtentHeader) GetGrainSize() uint64

func (*COWDSparseExtentHeader) GrainOffset

func (r *COWDSparseExtentHeader) GrainOffset() uint64

func (*COWDSparseExtentHeader) IsCompressed

func (r *COWDSparseExtentHeader) IsCompressed() bool

func (*COWDSparseExtentHeader) IsEmeddedLBA

func (r *COWDSparseExtentHeader) IsEmeddedLBA() bool

type Disk

type Disk interface {
	ReadSectors(sector int64, count int) ([]byte, error)
	GetSize() int64
	GetSectorCount() int64
	GetSectorOffset() int64
	SetOffset(offset, sectorOffset int64)
}

type DiskDescriptor

type DiskDescriptor struct {
	Attr    map[string]string
	Extents []DiskExtent
	Ddb     map[string]string
	Sectors int64
	Raw     string
}

func ParseDiskDescriptor

func ParseDiskDescriptor(data string) (*DiskDescriptor, error)

type DiskExtent

type DiskExtent struct {
	AccessType  string
	Size        int64
	ExtentType  string
	Filename    string
	StartSector int64
}

type FileAccessorFn

type FileAccessorFn func(string) (io.ReadSeeker, error)
var FileAccessor FileAccessorFn

type RawDisk

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

func NewRawDisk

func NewRawDisk(fh io.ReadSeeker, size int64) (*RawDisk, error)

func (*RawDisk) GetSectorCount

func (rd *RawDisk) GetSectorCount() int64

func (*RawDisk) GetSectorOffset

func (rd *RawDisk) GetSectorOffset() int64

func (*RawDisk) GetSize

func (rd *RawDisk) GetSize() int64

func (*RawDisk) ReadSectors

func (rd *RawDisk) ReadSectors(sector int64, count int) ([]byte, error)

func (*RawDisk) SetOffset

func (rd *RawDisk) SetOffset(offset, sectorOffset int64)

type RawSparseExtentHeader

type RawSparseExtentHeader interface {
	IsCompressed() bool
	GetGrainSize() uint64
	GrainOffset() uint64
	IsEmeddedLBA() bool
}

type SparseDisk

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

func NewSparseDisk

func NewSparseDisk(fh io.ReadSeeker, parent *VMDK) (*SparseDisk, error)

func (*SparseDisk) GetSectorCount

func (rd *SparseDisk) GetSectorCount() int64

func (*SparseDisk) GetSectorOffset

func (rd *SparseDisk) GetSectorOffset() int64

func (*SparseDisk) GetSize

func (rd *SparseDisk) GetSize() int64

func (*SparseDisk) ReadSectors

func (sd *SparseDisk) ReadSectors(sector int64, count int) ([]byte, error)

readSectors method for SparseDisk

func (*SparseDisk) SetOffset

func (rd *SparseDisk) SetOffset(offset, sectorOffset int64)

type SparseExtentHeader

type SparseExtentHeader struct {
	Magic string
	Flags uint64

	Raw RawSparseExtentHeader
}

func ParseSparseExtentHeader

func ParseSparseExtentHeader(fh io.ReadSeeker) (*SparseExtentHeader, error)

ParseSparseExtentHeader function

func (*SparseExtentHeader) AsCOWD

func (*SparseExtentHeader) AsVMDK

func (*SparseExtentHeader) AsVMDKSES

func (s *SparseExtentHeader) AsVMDKSES() (*VMDKSESparseConstHeader, bool)

type SparseGrainLBAHeader

type SparseGrainLBAHeader struct {
	LBA     uint64
	CmpSize uint32
}

type VMDK

type VMDK struct {
	Disks       []Disk
	Parent      *VMDK
	Descriptor  *DiskDescriptor
	DiskOffsets []int64
	SectorCount int64
	Size        int64
}

func NewVMDK

func NewVMDK(fhs []io.ReadSeeker) (*VMDK, error)

func (*VMDK) ReadAt

func (v *VMDK) ReadAt(p []byte, offset int64) (int, error)

func (*VMDK) ReadSectors

func (v *VMDK) ReadSectors(sector int64, count int) ([]byte, error)

type VMDKSESparseConstHeader

type VMDKSESparseConstHeader struct {
	Magic                uint64
	Version              uint64
	Capacity             uint64
	GrainSize            uint64
	GrainTableSize       uint64
	Flags                uint64
	Reserved1            uint64
	Reserved2            uint64
	Reserved3            uint64
	Reserved4            uint64
	VolatileHeaderOffset uint64
	VolatileHeaderSize   uint64
	JournalHeaderOffset  uint64
	JournalHeaderSize    uint64
	JournalOffset        uint64
	JournalSize          uint64
	GrainDirectoryOffset uint64
	GrainDirectorySize   uint64
	GrainTablesOffset    uint64
	GrainTablesSize      uint64
	FreeBitmapOffset     uint64
	FreeBitmapSize       uint64
	BackmapOffset        uint64
	BackmapSize          uint64
	GrainsOffset         uint64
	GrainsSize           uint64
	Pad                  [304]byte
}

VMDKSESparseConstHeader struct

func (*VMDKSESparseConstHeader) GetCapacity

func (r *VMDKSESparseConstHeader) GetCapacity() uint64

func (*VMDKSESparseConstHeader) GetGrainSize

func (r *VMDKSESparseConstHeader) GetGrainSize() uint64

func (*VMDKSESparseConstHeader) GrainOffset

func (r *VMDKSESparseConstHeader) GrainOffset() uint64

func (*VMDKSESparseConstHeader) IsCompressed

func (r *VMDKSESparseConstHeader) IsCompressed() bool

func (*VMDKSESparseConstHeader) IsEmeddedLBA

func (r *VMDKSESparseConstHeader) IsEmeddedLBA() bool

type VMDKSparseExtentHeader

type VMDKSparseExtentHeader struct {
	Magic                         [4]byte
	Version                       uint32
	Flags                         uint32
	Capacity                      uint64
	GrainSize                     uint64
	DescriptorOffset              uint64
	DescriptorSize                uint64
	NumGrainTableEntries          uint32
	SecondaryGrainDirectoryOffset uint64
	PrimaryGrainDirectoryOffset   uint64
	Overhead                      uint64
	IsDirty                       uint8
	SingleEndLineChar             byte
	NonEndLineChar                byte
	DoubleEndLineChars            [2]byte
	CompressAlgorithm             uint16
	Pad                           [433]byte
}

VMDKSparseExtentHeader struct

func (*VMDKSparseExtentHeader) GetCapacity

func (r *VMDKSparseExtentHeader) GetCapacity() uint64

func (*VMDKSparseExtentHeader) GetGrainSize

func (r *VMDKSparseExtentHeader) GetGrainSize() uint64

func (*VMDKSparseExtentHeader) GrainOffset

func (r *VMDKSparseExtentHeader) GrainOffset() uint64

func (*VMDKSparseExtentHeader) IsCompressed

func (r *VMDKSparseExtentHeader) IsCompressed() bool

func (*VMDKSparseExtentHeader) IsEmeddedLBA

func (r *VMDKSparseExtentHeader) IsEmeddedLBA() bool

Jump to

Keyboard shortcuts

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