Skip to content

possible problem with reporting correct error/sense code #2

@rosjat

Description

@rosjat

lets say we do something very simple commandwise but we know is going to fail since the device doesnt support this command.

here we have Report Timestamp, just building a cdb for now nothing else, this should return an illegal request sense code but it doesnt.

class ReportTimestamp(SCSICommand):
    """
    A class to hold information from a ReportTimestamp command to a scsi device
    """
    _cdb_bits =        {'opcode': [0xff, 0],
                        'service_action': [0x1f, 1],
                        'alloc_len': [0xffffffff, 6], }

    _data_bits =       {'tspdl': [0xffff, 0],
                        'ts_origin': [0x07, 2],
                        'ts': [0xffffffffffff, 4], }

    def __init__(self,
                 opcode,
                 alloclen=12):
        """
        initialize a new instance

        :param opcode: a OpCode instance
        :param alloclen: the max number of bytes allocated for the data_in buffer
        """
        SCSICommand.__init__(self,
                             opcode,
                             0,
                             alloclen)

        self.cdb = self.build_cdb(opcode=self.opcode.value,
                                  service_action=self.opcode.serviceaction.REPORT_TIMESTAMP,
                                  alloc_len=alloclen)

calling this in example brings the following

Traceback (most recent call last):
  File "examples/report_timestamp.py", line 28, in <module>
    main(sys.argv[1])
  File "examples/report_timestamp.py", line 23, in main
    d.execute(cmd)
  File "/usr/local/lib/python3.7/site-packages/pyscsi/pyscsi/scsi_device.py", line 132, in execute
    cmd.datain)
  File "src/linux_sgio.pyx", line 144, in sgio.execute
sgio.UnspecifiedError

this would refer to this code

result = ioctl(fid.fileno(), SG_IO, &io_hdr)

    if result < 0:
        raise OSError(errno, 'ioctl failed')

    if io_hdr.info & SG_INFO_OK_MASK != SG_INFO_OK:
        if io_hdr.sb_len_wr > 0:
            raise CheckConditionError(sense)
        else:
            raise UnspecifiedError()

as far as i figured we get a 0 from the ioctl and this would result in that, i might be wrong with my cdb but again i know this command is not supported by the blockdevice i am issue this cdb at. So lets keep an eye on this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions