storageapi

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package storageapi provides access to the Windows mass storage drivers via device I/O control functions.

Index

Constants

View Source
const (
	StorageDeviceProperty                 = iota // 0 StorageDeviceProperty
	StorageAdapterProperty                       // 1 StorageAdapterProperty
	StorageDeviceIDProperty                      // 2 StorageDeviceIdProperty
	StorageDeviceUniqueIDProperty                // 3 StorageDeviceUniqueIdProperty
	StorageDeviceWriteCacheProperty              // 4 StorageDeviceWriteCacheProperty
	StorageMiniportProperty                      // 5 StorageMiniportProperty
	StorageAccessAlignmentProperty               // 6 StorageAccessAlignmentProperty
	StorageDeviceSeekPenaltyProperty             // 7 StorageDeviceSeekPenaltyProperty
	StorageDeviceTrimProperty                    // 8 StorageDeviceTrimProperty
	StorageDeviceWriteAggregationProperty        // 9 StorageDeviceWriteAggregationProperty
	StorageDeviceDeviceTelemetryProperty         // 10 StorageDeviceDeviceTelemetryProperty
	StorageDeviceLBProvisioningProperty          // 11 StorageDeviceLBProvisioningProperty
	StorageDevicePowerProperty                   // 12 StorageDevicePowerProperty
	StorageDeviceCopyOffloadProperty             // 13 StorageDeviceCopyOffloadProperty
	StorageDeviceResiliencyProperty              // 14 StorageDeviceResiliencyProperty
	StorageDeviceMediumProductType               // 15 StorageDeviceMediumProductType
)

STORAGE_PROPERTY_ID enumeration.

View Source
const (
	StorageDeviceIOCapabilityProperty      = iota + 48 // 48 StorageDeviceIoCapabilityProperty
	StorageAdapterProtocolSpecificProperty             // 49 StorageAdapterProtocolSpecificProperty
	StorageDeviceProtocolSpecificProperty              // 50 StorageDeviceProtocolSpecificProperty
	StorageAdapterTemperatureProperty                  // 51 StorageAdapterTemperatureProperty
	StorageDeviceTemperatureProperty                   // 52 StorageDeviceTemperatureProperty
	StorageAdapterPhysicalTopologyProperty             // 53 StorageAdapterPhysicalTopologyProperty
	StorageDevicePhysicalTopologyProperty              // 54 StorageDevicePhysicalTopologyProperty
	StorageDeviceAttributesProperty                    // 55 StorageDeviceAttributesProperty
)

STORAGE_PROPERTY_ID enumeration.

View Source
const (
	PropertyStandardQuery   = iota // 0
	PropertyExistsQuery            // 1
	PropertyMaskQuery              // 2
	PropertyQueryMaxDefined        // 3
)

STORAGE_QUERY_TYPE enumeration.

View Source
const (
	// PartitionNotAvailable is the partition number returned for devices that
	// do not have partitions. This value may be returned from calls to
	// GetDeviceNumber.
	PartitionNotAvailable = -1
)

Variables

This section is empty.

Functions

func QueryProperty

func QueryProperty(handle syscall.Handle, propertyID, queryType uint32, buffer []byte) (length uint32, err error)

QueryProperty is a low level API call that retrieves many different kinds of storage device properties. It is prefable to use one of the higher level functions like QueryDeviceDescriptor to retrieve a particular kind of data.

Types

type AccessAlignmentDescriptor

type AccessAlignmentDescriptor struct {
	Version                       uint32
	Size                          uint32
	BytesPerCacheLine             uint32
	BytesOffsetForCacheAlignment  uint32
	BytesPerLogicalSector         uint32
	BytesPerPhysicalSector        uint32
	BytesOffsetForSectorAlignment uint32
}

AccessAlignmentDescriptor describes the byte alignment characteristics of a storage device.

func QueryAccessAlignment

func QueryAccessAlignment(handle syscall.Handle) (descriptor AccessAlignmentDescriptor, err error)

QueryAccessAlignment retrieves the access alignment descriptor of the storage device represented by the provided handle.

type DeviceDescriptor

type DeviceDescriptor struct {
	DeviceType         byte
	DeviceTypeModifier byte
	RemovableMedia     bool
	CommandQueueing    bool
	VendorID           string
	ProductID          string
	ProductRevision    string
	SerialNumber       string
	BusType            uint32
}

DeviceDescriptor describes a storage device.

func QueryDeviceDescriptor

func QueryDeviceDescriptor(handle syscall.Handle) (descriptor DeviceDescriptor, err error)

QueryDeviceDescriptor retrieves the device descriptor of the storage device represented by the provided handle.

type DeviceNumber

type DeviceNumber struct {
	// DeviceType is a device type code as defined in the ioctlcode package.
	DeviceType uint16

	// DeviceNumber is the physical device number of the device.
	DeviceNumber uint32

	// PartitionNumber is the partition number of the device if it represents
	// a partitioned volume. If the device is not a partitioned volume it will
	// be set to PartitionNotAvailable.
	//
	// PartitionNumber is formally defined as a ulong in the official
	// documentation on MSDN, but the documentation also clearly states that a
	// value of -1 is returned for devices that are not parititioned, so the
	// package authors have elected to change its type from uint32 to int32 here.
	// See the MSDN documentation for details:
	//
	// https://msdn.microsoft.com/library/bb968801
	//
	// Users of this package should test its value against the
	// PartitionNotAvailable constant, which is guaranteed to match the "missing"
	// value, however the GetDeviceNumber function in this package will return it.
	PartitionNumber int32
}

DeviceNumber describes the device type and device number of storage devices, and can be used to construct the physical address of mass storage devices and logical volumes. For logical volumes it also holds the partition number of the volume.

func GetDeviceNumber

func GetDeviceNumber(handle syscall.Handle) (devnum DeviceNumber, err error)

GetDeviceNumber retrieves the device numbering of the storage device represented by the provided handle. The returned information includes the device type and physical device number, as well as the partition number if the device is a partitioned volume.

type PropertyQuery

type PropertyQuery struct {
	PropertyID uint32
	QueryType  uint32
	// contains filtered or unexported fields
}

PropertyQuery is used internally in calls to query storage devices.

type RawDeviceDescriptor

type RawDeviceDescriptor struct {
	Version               uint32
	Size                  uint32
	DeviceType            byte
	DeviceTypeModifier    byte
	RemovableMedia        bool
	CommandQueueing       bool
	VendorIDOffset        uint32
	ProductIDOffset       uint32
	ProductRevisionOffset uint32
	SerialNumberOffset    uint32
	BusType               uint32
	RawPropertiesLength   uint32
}

RawDeviceDescriptor is used internally for system calls that query storage device descriptors.

type RawDeviceDescriptorHeader

type RawDeviceDescriptorHeader struct {
	Version uint32
	Size    uint32
}

RawDeviceDescriptorHeader is used internally for system calls that query storage device descriptors.

Jump to

Keyboard shortcuts

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