Crate cotton_scsi

Crate cotton_scsi 

Source
Expand description

CI status codecov dependency status Crates.io Crates.io docs.rs License: CC0-1.0

§cotton-scsi

Part of the Cotton project.

Actual SCSI hardware is rarely seen these days. But the command protocols live on, and are important for USB mass-storage class (USB storage devices) when tunnelled over USB and for CD-ROM when tunnelled over ATAPI.

This crate so far implements only those commands important for “direct storage access devices” (disks and flash-drives), but the mechanisms should be generic to all SCSI commands, such as for optical drives.

The most accessible reference for SCSI commands for disks (or other direct storage) is the “Seagate SCSI Commands Reference Manual” found at https://www.seagate.com/files/staticfiles/support/docs/manual/Interface%20manuals/100293068j.pdf

§Using cotton-scsi

Firstly you need to get hold of an implementation of the trait ScsiTransport – either the implementation of USB mass-storage class provided by the cotton-usb-host-msc crate, or your own new one.

Then, construct a ScsiDevice from your ScsiTransport. You can then call ScsiDevice::inquiry to determine what sort of SCSI device you have. If it’s of type PeripheralType::Disk then you’re in luck: you can construct a ScsiBlockDevice from your ScsiDevice and start reading and writing sectors.

If your device isn’t a PeripheralType::Disk – perhaps it’s a PeripheralType::Optical or something else – then you’ll need to send and receive SCSI commands more manually, using ScsiDevice::command_response; you can examine the implementation of methods such as ScsiDevice::read_capacity_10 to see what that needs to look like.

Re-exports§

pub use scsi_device::PeripheralType;
pub use scsi_device::ScsiDevice;
pub use scsi_transport::Error;
pub use scsi_transport::ScsiTransport;
pub use async_block_device::AsyncBlockDevice;
pub use async_block_device::DeviceInfo;
pub use scsi_block_device::ScsiBlockDevice;

Modules§

async_block_device
A generic asynchronous block device with a “read/write blocks” interface
scsi_block_device
Implementing AsyncBlockDevice in terms of ScsiDevice
scsi_device
A generic SCSI device
scsi_transport
An abstract communication channel with a SCSI device