scuzz

package
v7.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2020 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package scuzz supports direct access to SCSI or SATA devices. SCSI and ATA used to be different, but for SATA, it's all the same look.

In the long term we can use it to implement hdparm(1) and other Linux commands.

This package only supports post-2003 48-bit lba addressing. Further, we only concern ourselves with ATA_16. For now it only works on Linux.

Other info:

http://www.t13.org/ Technical Committee T13 AT Attachment (ATA/ATAPI) Interface.
http://www.serialata.org/ Serial ATA International Organization.

Index

Constants

View Source
const DefaultTimeout time.Duration = 15 * time.Second

DefaultTimeout is the default timeout for disk operations.

Variables

View Source
var Debug = func(string, ...interface{}) {}

Debug is an empty function you can replace with, e.g., log.Printf

Functions

This section is empty.

Types

type Cmd

type Cmd uint8

Cmd is an ATA command. See the ATA standard starting in the 80s.

type Disk

type Disk interface {
	// Unlock unlocks the drive, given a password and an indication of
	// whether it is the admin (true) or user (false) password.
	Unlock(password string, admin bool) error

	// Identify returns drive identity information
	Identify() (*Info, error)
}

Disk is the interface to a disk, with operations to create packets and operate on them.

type Info

type Info struct {
	NumberSectors           uint64
	ECCBytes                uint
	MasterPasswordRev       uint16
	SecurityStatus          uint16
	TrustedComputingSupport uint16

	Serial           string
	Model            string
	FirmwareRevision string

	// These are the pair-byte-swapped space-padded versions of serial,
	// model, and firmware revision as originally returned by the SCSI
	// device.
	OrigSerial           string
	OrigModel            string
	OrigFirmwareRevision string
}

Info is information about a SCSI disk device.

func (*Info) String

func (i *Info) String() string

String prints a nice JSON-formatted info.

type SGDisk

type SGDisk struct {

	// Timeuut is the timeout on a disk operation.
	Timeout time.Duration
	// contains filtered or unexported fields
}

SGDisk implements a Disk using the Linux SG device

func NewSGDisk

func NewSGDisk(n string, opt ...SGDiskOpt) (*SGDisk, error)

NewSGDisk returns a Disk that uses the Linux SCSI Generic Device. It also does an Identify to verify that the target name is a true lba48 device.

func (*SGDisk) Close

func (s *SGDisk) Close() error

Close closes any open FDs.

func (*SGDisk) Identify

func (s *SGDisk) Identify() (*Info, error)

Identify returns identifying information for Linux SCSI Generic Disks.

func (*SGDisk) Unlock

func (s *SGDisk) Unlock(password string, admin bool) error

Unlock performs unlock requests for Linux SCSI Generic Disks

type SGDiskOpt

type SGDiskOpt func(*SGDisk)

SGDiskOpt allows callers of NewSGDisk to set values

func WithTimeout

func WithTimeout(timeout time.Duration) SGDiskOpt

WithTimeout returns an SGDiskOpt that allows setting a non-default TimeOut

Jump to

Keyboard shortcuts

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