smartie.scsi.structures module¶
This file contains the various low-level structure definitions used for sending and receiving SCSI commands, as well as the structures required for platform-specific APIs.
Where reasonable, the names of fields have been taken from the specifications to ease reference searches.
- class smartie.scsi.structures.ATACommands(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
The possible values for Command16.command.
- IDENTIFY = 236¶
- READ_DATA = 208¶
- READ_LOG = 213¶
- RETURN_STATUS = 218¶
- SMART = 176¶
- class smartie.scsi.structures.ATAPICommands(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
The possible values for Command16.command when targeting an ATAPI device.
- IDENTIFY = 161¶
- class smartie.scsi.structures.ATAProtocol(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
The possible values for Command16.protocol.
- DEVICE_DIAGNOSTIC = 8¶
- DEVICE_RESET = 9¶
- DMA = 6¶
- DMA_QUEUED = 7¶
- FPDMA = 12¶
- HARD_RESET = 0¶
- NON_DATA = 3¶
- PIO_DATA_IN = 4¶
- PIO_DATA_OUT = 5¶
- RETURN_RESPONSE_INFORMATION = 15¶
- SRST = 1¶
- UDMA_DATA_IN = 10¶
- UDMA_DATA_OUT = 11¶
- class smartie.scsi.structures.ATASmartFeature(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
The possible values for the feature field on an ATA SMART command.
- SMART_DISABLE_OPERATIONS = 217¶
- SMART_ENABLE_OPERATIONS = 216¶
- SMART_EXECUTE_OFF_LINE_IMMEDIATE = 212¶
- SMART_READ_DATA = 208¶
- SMART_READ_LOG = 213¶
- SMART_READ_THRESHOLDS = 209¶
- SMART_RETURN_STATUS = 218¶
- SMART_TOGGLE_ATTRIBUTE_AUTOSAVE = 210¶
- SMART_WRITE_LOG = 214¶
- class smartie.scsi.structures.Command12[source]¶
Bases:
Structure
A 12-byte SCSI/ATA passthrough command.
Note
The contents of this structure are documented in 04-262r8.pdf, section 13.2.2.
- command¶
Structure/Union member
- control¶
Structure/Union member
- device¶
Structure/Union member
- features¶
Structure/Union member
- flags¶
Structure/Union member
- lba_high¶
Structure/Union member
- lba_low¶
Structure/Union member
- lba_mid¶
Structure/Union member
- operation_code¶
Structure/Union member
- protocol¶
Structure/Union member
- reserved_1¶
Structure/Union member
- reserved_2¶
Structure/Union member
- reserved_3¶
Structure/Union member
- reserved_4¶
Structure/Union member
- reserved_5¶
Structure/Union member
- sector_count¶
Structure/Union member
- class smartie.scsi.structures.Command16[source]¶
Bases:
Structure
A 16-byte SCSI/ATA passthrough command.
Note
The contents of this structure are documented in 04-262r8.pdf, section 13.2.3.
- command¶
Structure/Union member
- control¶
Structure/Union member
- device¶
Structure/Union member
- features¶
Structure/Union member
- flags¶
Structure/Union member
- lba_high¶
Structure/Union member
- lba_high_high¶
Structure/Union member
- lba_high_low¶
Structure/Union member
- lba_high_mid¶
Structure/Union member
- lba_low¶
Structure/Union member
- lba_mid¶
Structure/Union member
- operation_code¶
Structure/Union member
- protocol¶
Structure/Union member
- sector_count¶
Structure/Union member
- class smartie.scsi.structures.CommandFlags[source]¶
Bases:
Structure
The flags used in the SCSI Command16 and Command12 structures.
- class Length(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
Possible values for the t_length field.
- IN_FEATURE = 1¶
The transfer length is in the FEATURE field.
- IN_SECTOR_COUNT = 2¶
The transfer length is in the SECTOR_COUNT field.
- IN_STPSIU = 3¶
The transfer length is in the STPIU.
- class OffLine(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntFlag
Possible values for the off_line field.
- FOURTEEN_SECONDS = 3¶
- SIX_SECONDS = 2¶
- TWO_SECONDS = 1¶
- ZERO_SECONDS = 0¶
- byt_blok¶
Structure/Union member
- ck_cond¶
Structure/Union member
- off_line¶
Structure/Union member
- reserved_1¶
Structure/Union member
- t_dir¶
Structure/Union member
- t_length¶
Structure/Union member
- class smartie.scsi.structures.DescriptorFormatSense[source]¶
Bases:
Structure
The SENSE response may be in of two formats - this one, or
FixedFormatSense
. The exact format depends on the value of the first byte, error_code.- additional_sense_code¶
Structure/Union member
- additional_sense_code_qualifier¶
Structure/Union member
- error_code¶
Structure/Union member
- reserved_1¶
Structure/Union member
- sense_key¶
Structure/Union member
- valid¶
Structure/Union member
- class smartie.scsi.structures.DeviceType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
Common device types returned by the SCSI INQUIRY command.
Note
Not all possible values are defined here due to lack of testable hardware.
- CDROM = 5¶
CD/DVD/BLU-RAY
- DIRECT_ACCESS_BLOCK_DEVICE = 0¶
Direct access block device (ex: disk)
- OPTICAL_CARD_RW = 15¶
Optical card reader/writer device
- OPTICAL_MEMORY_DEVICE = 7¶
Some types of optical disks
- RAID_CONTROLLER = 12¶
Storage array controller device
- SEQUENTIAL_ACCESS_DEVICE = 1¶
Sequential access device (ex: tape drive)
- class smartie.scsi.structures.Direction(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
The direction of the command being sent by a call to DeviceIO.issue_command.
Note
These are really the constants for the direction in SG_IO calls, but we map them for other platforms.
- FROM = -3¶
- NONE = -1¶
- TO = -2¶
- class smartie.scsi.structures.FixedFormatSense[source]¶
Bases:
Structure
The SENSE response may be in of two formats - this one, or
DescriptorFormatSense
. The exact format depends on the value of the first byte, error_code.- additional_sense_code¶
Structure/Union member
- additional_sense_code_qualifier¶
Structure/Union member
- additional_sense_length¶
Structure/Union member
- command_specific_information¶
Structure/Union member
- eom¶
Structure/Union member
- error_code¶
Structure/Union member
- field_replaceable_unit_code¶
Structure/Union member
- filemark¶
Structure/Union member
- ili¶
Structure/Union member
- information¶
Structure/Union member
- reserved_1¶
Structure/Union member
- segment_number¶
Structure/Union member
- sense_key¶
Structure/Union member
- sense_key_specific¶
Structure/Union member
- valid¶
Structure/Union member
- smartie.scsi.structures.IOCTL_SCSI_PASS_THROUGH_DIRECT = 315412¶
The Windows IOCTL for SCSI pass-through, which is what we use to send and receive SCSI commands.
- smartie.scsi.structures.IOCTL_SG_IO = 8837¶
The Linux IOCTL for SG_IO, which is the driver we use to send and receive SCSI commands.
- class smartie.scsi.structures.IdentifyResponse[source]¶
Bases:
Structure
The response to an SCSI/ATA IDENTIFY command.
Note
This is a large structure, and has only been partially implemented. The full response is 512 bytes.
- device_type¶
Structure/Union member
- firmware_revision¶
Structure/Union member
- fixed_device¶
Structure/Union member
- model_number¶
Structure/Union member
- padding_1¶
Structure/Union member
- padding_2¶
Structure/Union member
- removable_media¶
Structure/Union member
- reserved_1¶
Structure/Union member
- response_incomplete¶
Structure/Union member
- retired_1¶
Structure/Union member
- retired_2¶
Structure/Union member
- retired_3¶
Structure/Union member
- serial_number¶
Structure/Union member
- class smartie.scsi.structures.InquiryCommand[source]¶
Bases:
Structure
An SCSI INQUIRY command.
- allocation_length¶
Structure/Union member
- control¶
Structure/Union member
- lun¶
Structure/Union member
- operation_code¶
Structure/Union member
- page_code¶
Structure/Union member
- reserved_1¶
Structure/Union member
- class smartie.scsi.structures.InquiryResponse[source]¶
Bases:
Structure
The response to an SCSI INQUIRY command.
- additional_length¶
Structure/Union member
- cmd_que¶
Structure/Union member
- enc_serv¶
Structure/Union member
- hi_sup¶
Structure/Union member
- hot_pluggable¶
Structure/Union member
- lu_cong¶
Structure/Union member
- multi_p¶
Structure/Union member
- norm_aca¶
Structure/Union member
- obsolete_1¶
Structure/Union member
- obsolete_2¶
Structure/Union member
- obsolete_3¶
Structure/Union member
- obsolete_4¶
Structure/Union member
- obsolete_5¶
Structure/Union member
- obsolete_6¶
Structure/Union member
- obsolete_7¶
Structure/Union member
- obsolete_8¶
Structure/Union member
- peripheral_device_type¶
Structure/Union member
- peripheral_qualifier¶
Structure/Union member
- product_identification¶
Structure/Union member
- product_revision_level¶
Structure/Union member
- protect¶
Structure/Union member
- reserved_1¶
Structure/Union member
- reserved_10¶
Structure/Union member
- reserved_11¶
Structure/Union member
- reserved_2¶
Structure/Union member
- reserved_3¶
Structure/Union member
- reserved_4¶
Structure/Union member
- reserved_5¶
Structure/Union member
- reserved_6¶
Structure/Union member
- reserved_7¶
Structure/Union member
- reserved_8¶
Structure/Union member
- reserved_9¶
Structure/Union member
- response_data_format¶
Structure/Union member
- rmb¶
Structure/Union member
- sccs¶
Structure/Union member
- t10_vendor_identification¶
Structure/Union member
- three_pc¶
Structure/Union member
- tpgs¶
Structure/Union member
- vendor_specific_1¶
Structure/Union member
- version¶
Structure/Union member
- version_descriptors¶
Structure/Union member
- vs_1¶
Structure/Union member
- vs_2¶
Structure/Union member
- class smartie.scsi.structures.OperationCode(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
- COMMAND_12 = 161¶
12-byte ATA passthrough command.
- COMMAND_16 = 133¶
16-byte ATA passthrough command.
- INQUIRY = 18¶
SCSI INQUIRY command.
- class smartie.scsi.structures.SCSIPassThroughDirect[source]¶
Bases:
Structure
Corresponds to the SCSI_PASS_THROUGH_DIRECT structure in <ntddscsi.h> on Windows.
- cdb¶
Structure/Union member
- cdb_length¶
Structure/Union member
- data_buffer¶
Structure/Union member
- data_in¶
Structure/Union member
- data_transfer_length¶
Structure/Union member
- length¶
Structure/Union member
- lun¶
Structure/Union member
- path_id¶
Structure/Union member
- scsi_status¶
Structure/Union member
- sense_info_length¶
Structure/Union member
- sense_info_offset¶
Structure/Union member
- target_id¶
Structure/Union member
- timeout_value¶
Structure/Union member
- class smartie.scsi.structures.SCSIPassThroughDirectWithBuffer[source]¶
Bases:
Structure
Corresponds to the SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER structure in <ntddscsi.h> on Windows.
- filler¶
Structure/Union member
- sense¶
Structure/Union member
- sptd¶
Structure/Union member
- class smartie.scsi.structures.SGIOHeader[source]¶
Bases:
Structure
Corresponds to the compat_sg_io_hdr structure in <scsi/sg.h> on Linux.
- cmd_len¶
Structure/Union member
- cmdp¶
Structure/Union member
- driver_status¶
Structure/Union member
- duration¶
Structure/Union member
- dxfer_direction¶
Structure/Union member
- dxfer_len¶
Structure/Union member
- dxferp¶
Structure/Union member
- flags¶
Structure/Union member
- host_status¶
Structure/Union member
- info¶
Structure/Union member
- interface_id¶
Structure/Union member
- iovec_count¶
Structure/Union member
- masked_status¶
Structure/Union member
- msg_status¶
Structure/Union member
- mx_sb_len¶
Structure/Union member
- pack_id¶
Structure/Union member
- resid¶
Structure/Union member
- sb_len_wr¶
Structure/Union member
- sbp¶
Structure/Union member
- status¶
Structure/Union member
- timeout¶
Structure/Union member
- usr_ptr¶
Structure/Union member
- class smartie.scsi.structures.SenseErrorCode(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
- CURRENT_ERROR = 112¶
- DEFERRED_ERROR = 113¶
- class smartie.scsi.structures.SmartDataEntry[source]¶
Bases:
Structure
An entry in the SMART attribute table.
Note
The specification calls this field vendor specific, but its format is very consistent.
- current¶
Structure/Union member
- flags¶
Structure/Union member
- id¶
Structure/Union member
- reserved¶
Structure/Union member
- vendor_specific_1¶
Structure/Union member
- worst¶
Structure/Union member
- class smartie.scsi.structures.SmartDataResponse[source]¶
Bases:
Structure
The result of a SMART READ_DATA command.
Note
The most interesting field in here is likely vendor_specific_1, which contains the SMART attribute table that encodes values such as the current device temperature.
Although the specification calls this field vendor specific, its format is very consistent. See
smartie.smart.parse_smart_read_data()
for an example.- attributes¶
Structure/Union member
- conveyance_self_test_recommended_time¶
Structure/Union member
- data_checksum_structure¶
Structure/Union member
- error_logging_capability¶
Structure/Union member
- extended_self_test_recommended_time¶
Structure/Union member
- extended_self_test_recommended_time_wide¶
Structure/Union member
- offline_data_collection_capability¶
Structure/Union member
- offline_data_collection_status¶
Structure/Union member
- reserved_1¶
Structure/Union member
- self_test_execution_status_buyte¶
Structure/Union member
- short_self_test_recommended_time¶
Structure/Union member
- smart_capability¶
Structure/Union member
- vendor_specific_2¶
Structure/Union member
- vendor_specific_3¶
Structure/Union member
- vendor_specific_4¶
Structure/Union member
- version¶
Structure/Union member
- class smartie.scsi.structures.SmartThresholdEntry[source]¶
Bases:
Structure
A single entry in the SMART READ_THRESHOLDS response.
- attribute_id¶
Structure/Union member
- reserved_1¶
Structure/Union member
- value¶
Structure/Union member
- class smartie.scsi.structures.SmartThresholdResponse[source]¶
Bases:
Structure
The result of a SMART READ_THRESHOLDS command.
Note
The most interesting field in here is likely vendor_specific_1, which contains the SMART threshold table that encodes values such as the temperature at which the device will start throttling.
- checksum¶
Structure/Union member
- entries¶
Structure/Union member
- reserved_1¶
Structure/Union member
- revision_number¶
Structure/Union member
- class smartie.scsi.structures.StatusCode(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
The possible values for SGIOHeader.status.
- BUSY = 4¶
- CHECK_CONDITION = 1¶
- CONDITION_GOOD = 2¶
- GOOD = 0¶
- INTERMEDIATE_C_GOOD = 10¶
- INTERMEDIATE_GOOD = 8¶
- RESERVATION_CONFLICT = 12¶