api

package
v2.0.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IOCTL_STORAGE_GET_DEVICE_NUMBER = 0x2D1080
	IOCTL_STORAGE_QUERY_PROPERTY    = 0x002d1400
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AdditionalParameters

type AdditionalParameters byte

type DeviceType

type DeviceType uint32

type Disk

type Disk struct {
	Path         string `json:"Path"`
	SerialNumber string `json:"SerialNumber"`
}

type DiskAPI

type DiskAPI struct{}

DiskAPI implements the OS API calls related to Disk Devices. All code here should be very simple pass-through to the OS APIs or cmdlets. Any logic around the APIs/cmdlet invocation should go in pkg/disk/disk.go so that logic can be easily unit-tested without requiring specific OS environments.

func New

func New() DiskAPI

func (DiskAPI) BasicPartitionsExist

func (DiskAPI) BasicPartitionsExist(diskNumber uint32) (bool, error)

func (DiskAPI) CreateBasicPartition

func (DiskAPI) CreateBasicPartition(diskNumber uint32) error

func (DiskAPI) GetDiskNumber

func (DiskAPI) GetDiskNumber(disk syscall.Handle) (uint32, error)

func (DiskAPI) GetDiskNumberAndPage83ID

func (imp DiskAPI) GetDiskNumberAndPage83ID(path string) (uint32, string, error)

func (DiskAPI) GetDiskNumberWithID

func (imp DiskAPI) GetDiskNumberWithID(page83ID string) (uint32, error)

func (DiskAPI) GetDiskPage83ID

func (DiskAPI) GetDiskPage83ID(disk syscall.Handle) (string, error)

func (DiskAPI) GetDiskState

func (imp DiskAPI) GetDiskState(diskNumber uint32) (bool, error)

func (DiskAPI) GetDiskStats

func (imp DiskAPI) GetDiskStats(diskNumber uint32) (int64, error)

func (DiskAPI) InitializeDisk

func (DiskAPI) InitializeDisk(diskNumber uint32) error

func (DiskAPI) IsDiskInitialized

func (DiskAPI) IsDiskInitialized(diskNumber uint32) (bool, error)

func (DiskAPI) ListDiskIDs

func (imp DiskAPI) ListDiskIDs() (map[uint32]DiskIDs, error)

ListDiskIDs - constructs a map with the disk number as the key and the DiskID structure as the value. The DiskID struct has a field for the page83 ID.

func (DiskAPI) ListDiskLocations

func (DiskAPI) ListDiskLocations() (map[uint32]DiskLocation, error)

ListDiskLocations - constructs a map with the disk number as the key and the DiskLocation structure as the value. The DiskLocation struct has various fields like the Adapter, Bus, Target and LUNID.

func (DiskAPI) Rescan

func (DiskAPI) Rescan() error

func (DiskAPI) SetDiskState

func (imp DiskAPI) SetDiskState(diskNumber uint32, isOnline bool) error

type DiskIDs

type DiskIDs struct {
	Page83       string
	SerialNumber string
}

DiskIDs definition

type DiskLocation

type DiskLocation struct {
	Adapter string
	Bus     string
	Target  string
	LUNID   string
}

DiskLocation definition

type HostAPI

type HostAPI interface {
	// ListDiskLocations - constructs a map with the disk number as the key and the DiskLocation structure
	// as the value. The DiskLocation struct has various fields like the Adapter, Bus, Target and LUNID.
	ListDiskLocations() (map[uint32]DiskLocation, error)
	// IsDiskInitialized returns true if the disk identified by `diskNumber` is initialized.
	IsDiskInitialized(diskNumber uint32) (bool, error)
	// InitializeDisk initializes the disk `diskNumber`
	InitializeDisk(diskNumber uint32) error
	// BasicPartitionsExist checks if the disk `diskNumber` has any basic partitions.
	BasicPartitionsExist(diskNumber uint32) (bool, error)
	// CreateBasicPartition creates a partition in disk `diskNumber`
	CreateBasicPartition(diskNumber uint32) error
	// Rescan updates the host storage cache (re-enumerates disk, partition and volume objects)
	Rescan() error
	// ListDiskIDs list all disks by disk number.
	ListDiskIDs() (map[uint32]DiskIDs, error)
	// GetDiskStats gets the disk stats of the disk `diskNumber`.
	GetDiskStats(diskNumber uint32) (int64, error)
	// SetDiskState sets the offline/online state of the disk `diskNumber`.
	SetDiskState(diskNumber uint32, isOnline bool) error
	// GetDiskState gets the offline/online state of the disk `diskNumber`.
	GetDiskState(diskNumber uint32) (bool, error)
}

HostAPI declares the interface exposed by the internal API

type StorageAssociationType

type StorageAssociationType uint32
const (
	StorageIDAssocDevice StorageAssociationType = iota
	StorageIDAssocPort
	StorageIDAssocTarget
)

type StorageDeviceIDDescriptor

type StorageDeviceIDDescriptor struct {
	Version             uint32
	Size                uint32
	NumberOfIdentifiers uint32
	Identifiers         [1]byte
}

type StorageDeviceNumber

type StorageDeviceNumber struct {
	DeviceType      DeviceType
	DeviceNumber    uint32
	PartitionNumber uint32
}

type StorageIdentifier

type StorageIdentifier struct {
	CodeSet        StorageIdentifierCodeSet
	Type           StorageIdentifierType
	IdentifierSize uint16
	NextOffset     uint16
	Association    StorageAssociationType
	Identifier     [1]byte
}

type StorageIdentifierCodeSet

type StorageIdentifierCodeSet uint32
const (
	StorageIDCodeSetReserved StorageIdentifierCodeSet = iota
	StorageIDCodeSetBinary
	StorageIDCodeSetASCII
	StorageIDCodeSetUtf8
)

type StorageIdentifierType

type StorageIdentifierType uint32
const (
	StorageIdTypeVendorSpecific StorageIdentifierType = iota
	StorageIDTypeVendorID
	StorageIDTypeEUI64
	StorageIDTypeFCPHName
	StorageIDTypePortRelative
	StorageIDTypeTargetPortGroup
	StorageIDTypeLogicalUnitGroup
	StorageIDTypeMD5LogicalUnitIdentifier
	StorageIDTypeScsiNameString
)

type StoragePropertyID

type StoragePropertyID uint32
const (
	StorageDeviceProperty StoragePropertyID = iota
	StorageAdapterProperty
	StorageDeviceIDProperty
	StorageDeviceUniqueIDProperty
	StorageDeviceWriteCacheProperty
	StorageMiniportProperty
	StorageAccessAlignmentProperty
	StorageDeviceSeekPenaltyProperty
	StorageDeviceTrimProperty
	StorageDeviceWriteAggregationProperty
	StorageDeviceDeviceTelemetryProperty
	StorageDeviceLBProvisioningProperty
	StorageDevicePowerProperty
	StorageDeviceCopyOffloadProperty
	StorageDeviceResiliencyProperty
	StorageDeviceMediumProductType
	StorageAdapterRpmbProperty
	StorageAdapterCryptoProperty
	StorageDeviceIoCapabilityProperty
	StorageAdapterProtocolSpecificProperty
	StorageDeviceProtocolSpecificProperty
	StorageAdapterTemperatureProperty
	StorageDeviceTemperatureProperty
	StorageAdapterPhysicalTopologyProperty
	StorageDevicePhysicalTopologyProperty
	StorageDeviceAttributesProperty
	StorageDeviceManagementStatus
	StorageAdapterSerialNumberProperty
	StorageDeviceLocationProperty
	StorageDeviceNumaProperty
	StorageDeviceZonedDeviceProperty
	StorageDeviceUnsafeShutdownCount
	StorageDeviceEnduranceProperty
)

type StoragePropertyQuery

type StoragePropertyQuery struct {
	PropertyID StoragePropertyID
	QueryType  StorageQueryType
	Byte       []AdditionalParameters
}

type StorageQueryType

type StorageQueryType uint32
const (
	PropertyStandardQuery StorageQueryType = iota
	PropertyExistsQuery
	PropertyMaskQuery
	PropertyQueryMaxDefined
)

Jump to

Keyboard shortcuts

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