scsi

package
v0.1.0-alpha.20 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2019 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package scsi provices a library for working with version 3 SCSI generic drivers.

Index

Constants

View Source
const (
	// S represents the SG_IO V3 interface variant identifier.
	S = int32('S')

	// SGIO is the SG_IO ioctl command.
	SGIO = 0x2285
	// SenseBufLen is the length of the sense buffer.
	SenseBufLen = 32
	// SGDxferNone is the SCSI test unit ready command.
	SGDxferNone = -1
	// SGDxferToDev is the SCSI write command.
	SGDxferToDev = -2
	// SGDxferFromDev is the SCSI read command.
	SGDxferFromDev = -3
	// SGGetVersionNum is the SCSI get version command.
	SGGetVersionNum = 0x2282
	// DefaultTimeout is time in milliseconds for SCSI commands.
	DefaultTimeout = 5 * 1000

	// InquiryCmd is the SCSI INQUIRY command.
	InquiryCmd = 0x12
	// InguiryBufLen is the length of the inquiry buffer.
	InguiryBufLen = 252

	// Page0 is VPD page 0.
	Page0 = 0x00
	// Page80 is VPD page 80.
	Page80 = 0x80
	// Page83 is VPD page 83.
	Page83 = 0x83
	// Page83PreSPC3 is VPD page pre-spc3-83.
	Page83PreSPC3 = -0x83

	// VendorLength is the vendor length.
	VendorLength = 8
	// ModelLength is the model length.
	ModelLength = 16

	// MaxSerialLen is the maximum length of the serial number, including
	// added prefixes such as vendor and product (model) strings.
	MaxSerialLen = 256

	// DescriptorTypeVendorSpecific is the vendor specific descriptor type.
	DescriptorTypeVendorSpecific = 0
	// DescriptorTypeT10Vendor is the t10vendor descriptor type.
	DescriptorTypeT10Vendor = 1
	// DescriptorTypeEUI64 is the eui64 descriptor type.
	DescriptorTypeEUI64 = 2
	// DescriptorTypeNAA is the naa descriptor type.
	DescriptorTypeNAA = 3
	// DescriptorTypeRelport is the relport descriptor type.
	DescriptorTypeRelport = 4
	// DescriptorTypeTgtGroup is the tgtgroup descriptor type.
	DescriptorTypeTgtGroup = 5
	// DescriptorTypeLungroup is the lungroup descriptor type.
	DescriptorTypeLungroup = 6
	// DescriptorTypeMD5 is the md5 descriptor type.
	DescriptorTypeMD5 = 7
	// DescriptorTypeName is the name descriptor type.
	DescriptorTypeName = 8

	// CodeSetBinary is the binary code set.
	CodeSetBinary = 1
	// CodeSetASCII is the ASCII code set.
	CodeSetASCII = 2
)
View Source
const (
	// TypeDisk represents the disk device type.
	TypeDisk = iota
	// TypeTape represents the tape device type.
	TypeTape
	// TypeOptical represents the optical device type.
	TypeOptical
	// TypeCD represents the cd device type.
	TypeCD
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandDescriptorBlock

type CommandDescriptorBlock = [InguiryBufLen]byte

CommandDescriptorBlock represents the command descriptor block.

type Device

type Device struct {
	*ID
	// contains filtered or unexported fields
}

Device represents a SCSI device.

func NewDevice

func NewDevice(name string) (device *Device, err error)

NewDevice returns a SCSI device. See https://www.tldp.org/HOWTO/SCSI-Generic-HOWTO/iddriver.html.

func (*Device) Close

func (dvc *Device) Close() error

Close closes the device.

func (*Device) Identify

func (dvc *Device) Identify() (err error)

Identify queries a SCSI device via the SCSI INQUIRY vital product data (VPD) page 0x80 and 0x83.

func (*Device) Page0Inquiry

func (dvc *Device) Page0Inquiry() (pages []byte, err error)

Page0Inquiry returns a list of Vital Product Data (VPD) pages. TODO(andrewrynhard): Should pages by an iota?

func (*Device) Page80Inquiry

func (dvc *Device) Page80Inquiry() (err error)

Page80Inquiry gets unit serial number VPD page.

func (*Device) Page83Inquiry

func (dvc *Device) Page83Inquiry() (err error)

Page83Inquiry sends a page 83 INQUIRY to the device.

func (*Device) StandardInquiry

func (dvc *Device) StandardInquiry() (err error)

StandardInquiry performs a basic inquiry on the device. nolint: gocyclo

type GenericIOHeader

type GenericIOHeader struct {
	InterfaceID    int32
	DxferDirection int32
	CmdLen         uint8
	MxSbLen        uint8
	IovecCount     uint16
	DxferLen       uint32
	Dxferp         *byte
	Cmdp           *uint8
	Sbp            *uint8
	Timeout        uint32
	Flags          uint32
	PackID         int32

	UsrPtr       *byte
	Status       uint8
	MaskedStatus uint8
	MsgStatus    uint8
	SbLenWr      uint8
	HostStatus   uint16
	DriverStatus uint16
	Resid        int32
	Duration     uint32
	Info         uint32
	// contains filtered or unexported fields
}

GenericIOHeader is the control structure for the version 3 SCSI generic driver.

type ID

type ID struct {
	Vendor             string
	Model              string
	Revision           string
	Type               Type
	Kernel             string
	Serial             string
	SerialShort        string
	UseSg              int32
	UnitSerialNumber   string
	WWN                string
	WWNVendorExtension string
	TgptGroup          string
}

ID represents the set of SCSI device identifiers.

type Sense

type Sense = [SenseBufLen]byte

Sense represents the error reporting buffer.

type Type

type Type int

Type represetns the device type.

func (Type) String

func (typ Type) String() string

String returns the string representation of the device type.

Jump to

Keyboard shortcuts

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