[][src]Crate pakr_rawata

Raw access to hard disks for Linux and FreeBSD. For technical information refer to ATA/ATAPI Command Set guide.

Warning

it bypasses all OS security checks and all software caches. You can kill the data on your HDD in a blink of an eye. The only protection is that it requires administrative privilege to run.

Supported operations

  • read sectors using READ_DMA_EXT (ATA cmd 0x25, documentation chapter 7.21),
  • write sectors using WRITE_DMA_EXT (ATA cmd 0x35, documentation chapter 7.57)
  • identify drive using IDENTIFY_DEVICE (ATA cmd 0xEC, documentation chapter 7.13, including a detailed description of returned structure).

On Linux uses SG subsystem, on FreeBSD uses CAM subsystem.

Note

In theory, a single ATA DMA transfer is limited to 65536 sectors (32MiB for 512B sectors). Sector count is 16 bit and a full 65536 sector transfer is indicated by a sector count of 0x0000).

In practice operating system enforces much lower limit, in the range of a few hundred kilobytes.

On FreeBSD I managed to achieve stable transfers of 8MB at a time by re-compiling kernel with custom configuration:

include GENERIC

ident           BIGDMA

options         DFLTPHYS=(16U*1024*1024)
options         MAXPHYS=(32U*1024*1024)

On Linux I didn't find any accessible tunable to bump-up the maximal DMA transfer size, neither compile-time nor run-time.

TODO

  • support sector sizes different than 512 bytes

Structs

Device

Attached ATA device

IdentifyDeviceData

ATA standard IDENTIFY_DEVICE structure.