common

package
v0.0.5-rc4 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotSupportThisDriver = errors.New("not supported in this driver")
)

Functions

This section is empty.

Types

type AtaDriverHandle

type AtaDriverHandle interface {
	DriverHandle
	GetIdentity() []byte
	DoTaskFileCmd(rw bool, dma bool, tf *ata.Tf, data []byte, timeoutSecs int) error
}

type DparmError

type DparmError struct {
	Message      string
	DriverStatus byte
	SenseData    *scsi.SENSE_DATA
	// contains filtered or unexported fields
}

func (*DparmError) Error

func (e *DparmError) Error() string

type DriveFactory

type DriveFactory interface {
	OpenByPath(path string) (DriveHandle, error)
	EnumDrives() ([]DriveInfo, error)
	EnumVolumes() (EnumVolumeContext, error)
}

type DriveHandle

type DriveHandle interface {
	GetDriverHandle() DriverHandle
	Close()
	GetDevicePath() string
	GetDrivingType() DrivingType
	GetDriverName() string

	GetDriveInfo() *DriveInfo

	// ATA
	AtaDoTaskFileCmd(rw bool, dma bool, tf *ata.Tf, data []byte, timeoutSecs int) error

	// NVME
	NvmeGetLogPage(nsid uint32, logId uint32, rae bool, size int) ([]byte, error)

	// COMMON
	SecurityCommand(rw bool, dma bool, protocol uint8, comId uint16, buffer []byte, timeoutSecs int) error

	TcgDiscovery0() error
}

type DriveHandleImpl added in v0.0.2

type DriveHandleImpl struct {
	DriveHandle
	Dh   DriverHandle
	Info DriveInfo
}

func (*DriveHandleImpl) AtaDoTaskFileCmd added in v0.0.2

func (p *DriveHandleImpl) AtaDoTaskFileCmd(rw bool, dma bool, tf *ata.Tf, data []byte, timeoutSecs int) error

func (*DriveHandleImpl) Close added in v0.0.2

func (p *DriveHandleImpl) Close()

func (*DriveHandleImpl) GetDevicePath added in v0.0.2

func (p *DriveHandleImpl) GetDevicePath() string

func (*DriveHandleImpl) GetDriveInfo added in v0.0.2

func (p *DriveHandleImpl) GetDriveInfo() *DriveInfo

func (*DriveHandleImpl) GetDriverHandle added in v0.0.2

func (p *DriveHandleImpl) GetDriverHandle() DriverHandle

func (*DriveHandleImpl) GetDriverName added in v0.0.2

func (p *DriveHandleImpl) GetDriverName() string

func (*DriveHandleImpl) GetDrivingType added in v0.0.2

func (p *DriveHandleImpl) GetDrivingType() DrivingType

func (*DriveHandleImpl) Init added in v0.0.2

func (p *DriveHandleImpl) Init() error

func (*DriveHandleImpl) NvmeGetLogPage added in v0.0.2

func (p *DriveHandleImpl) NvmeGetLogPage(nsid uint32, logId uint32, rae bool, size int) ([]byte, error)

func (*DriveHandleImpl) SecurityCommand added in v0.0.2

func (p *DriveHandleImpl) SecurityCommand(rw bool, dma bool, protocol uint8, comId uint16, buffer []byte, timeoutSecs int) error

func (*DriveHandleImpl) TcgDiscovery0 added in v0.0.2

func (p *DriveHandleImpl) TcgDiscovery0() error

type DriveInfo

type DriveInfo struct {
	DevicePath  string
	DrivingType DrivingType
	DriverName  string

	PartitionStyle   PartitionStyle
	GptDiskId        string // uuid format
	MbrDiskSignature uint32

	Model            string
	Serial           string
	FirmwareRevision string
	RawSerial        [20]byte

	VendorId        string
	ProductRevision string

	WindowsDevNum   int
	SmartEnabled    bool
	AtaIdentity     *ata.IdentityDeviceData
	AtaIdentityRaw  []byte
	NvmeIdentity    *nvme.IdentifyController
	NvmeIdentityRaw []byte

	IsSsd          bool
	SsdCheckWeight int
	TotalCapacity  int64

	TcgSupport           int
	TcgTper              bool
	TcgLocking           bool
	TcgGeometryReporting bool
	TcgOpalSscV100       bool
	TcgOpalSscV200       bool
	TcgEnterprise        bool
	TcgSingleUser        bool
	TcgDataStore         bool

	TcgRawFeatures map[uint16][]byte

	Removable int
	DriveType DriveType
}

type DriveType added in v0.0.5

type DriveType int
const (
	DriveTypeUnknown DriveType = 0 + iota
	DriveTypeNoRootDir
	DriveTypeRemovable
	DriveTypeFixed
	DriveTypeRemote
	DriveTypeCdrom
	DriveTypeRamdisk
	DriveTypeTape
)

type DriverHandle

type DriverHandle interface {
	GetDriverName() string
	GetDrivingType() DrivingType
	ReopenWritable() error
	Close()

	SecurityCommand(rw bool, dma bool, protocol uint8, comId uint16, buffer []byte, timeoutSecs int) error
}

type DrivingType

type DrivingType int
const (
	DrivingUnknown DrivingType = 0 + iota
	DrivingAtapi
	DrivingNvme
)

type EnumVolumeContext

type EnumVolumeContext interface {
	GetList() []VolumeInfo
	FindVolumesByDrive(driveInfo *DriveInfo) []VolumeInfo
	OpenDriveByVolumePath(volumePath string) (DriveHandle, error)
	OpenDriveByPartition(partition Partition) (DriveHandle, error)
}

type GptPartitionInfo added in v0.0.2

type GptPartitionInfo struct {
	// PartitionType GUID Upper String Format {...}
	PartitionType string
	// PartitionId GUID Upper String Format {...}
	PartitionId string
}

type MbrPartitionInfo added in v0.0.2

type MbrPartitionInfo struct {
	PartitionType byte
	BootIndicator bool
}

type NestedError added in v0.0.2

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

func NewNestedError added in v0.0.2

func NewNestedError(msg string, cause error) *NestedError

func (*NestedError) Cause added in v0.0.2

func (e *NestedError) Cause() error

func (*NestedError) Error added in v0.0.2

func (e *NestedError) Error() string

type NvmeDriverHandle

type NvmeDriverHandle interface {
	DriverHandle
	GetIdentity() []byte
	DoNvmeAdminPassthru(cmd *nvme.NvmeAdminCmd) error
	NvmeGetLogPage(nsid uint32, logId uint32, rae bool, size int) ([]byte, error)
}

type Partition added in v0.0.2

type Partition interface {
	// GetStart bytes
	GetStart() uint64
	// GetEnd bytes
	GetSize() uint64

	GetPartitionStyle() PartitionStyle

	GetMbrInfo() *MbrPartitionInfo
	GetGptInfo() *GptPartitionInfo
}

type PartitionStyle

type PartitionStyle int
const (
	PartitionStyleRaw PartitionStyle = 0 + iota
	PartitionStyleMbr
	PartitionStyleGpt
)

type VolumeInfo

type VolumeInfo struct {
	Path        string
	Filesystem  string
	MountPoints []string
	Partitions  []Partition
	DriveType   DriveType
}

type WindowsPhysicalDrive

type WindowsPhysicalDrive struct {
	DeviceIndex        int
	PhysicalDiskPath   string
	SetupApiDevicePath string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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