Пример #1
0
 def get_scsi_standard_inquiry(self):
     """:returns: the standard inquiry data"""
     from infi.asi.cdb.inquiry.standard import StandardInquiryCommand
     from infi.asi.coroutines.sync_adapter import sync_wait
     with self.asi_context() as asi:
         command = StandardInquiryCommand()
         return sync_wait(command.execute(asi))
Пример #2
0
def get_scsi_standard_inquiry(access_path):
    from infi.asi.coroutines.sync_adapter import sync_wait
    from infi.asi.cdb.inquiry.standard import StandardInquiryCommand, STANDARD_INQUIRY_MINIMAL_DATA_LENGTH

    with asi_context(access_path) as asi:
        command = StandardInquiryCommand(allocation_length=STANDARD_INQUIRY_MINIMAL_DATA_LENGTH)
        result = sync_wait(command.execute(asi))
        return result
Пример #3
0
def get_scsi_standard_inquiry(access_path):
    from infi.asi.coroutines.sync_adapter import sync_wait
    from infi.asi.cdb.inquiry.standard import StandardInquiryCommand, STANDARD_INQUIRY_MINIMAL_DATA_LENGTH

    with asi_context(access_path) as asi:
        command = StandardInquiryCommand(
            allocation_length=STANDARD_INQUIRY_MINIMAL_DATA_LENGTH)
        result = sync_wait(command.execute(asi))
        return result
Пример #4
0
 def _get_scsi_standard_inquiry_the_right_way():
     allocation_length = STANDARD_INQUIRY_MINIMAL_DATA_LENGTH
     with self.asi_context() as asi:
         command = StandardInquiryCommand(allocation_length=allocation_length)
         result = sync_wait(command.execute(asi))
         if result.additional_length >= 0:
             allocation_length += result.additional_length
             command = StandardInquiryCommand(allocation_length=allocation_length)
             result = sync_wait(command.execute(asi))
     return result
Пример #5
0
 def _get_scsi_standard_inquiry_the_fastest_way(allocation_length=219):
     try:
         with self.asi_context() as asi:
             command = StandardInquiryCommand(allocation_length=allocation_length)
             return sync_wait(command.execute(asi))
     except AsiCheckConditionError, e:
         (key, code) = (e.sense_obj.sense_key, e.sense_obj.additional_sense_code.code_name)
         if (key, code) == ('ILLEGAL_REQUEST', 'INVALID FIELD IN CDB'):
             return
         raise
import sys
from infi.asi import create_platform_command_executer
from infi.asi.cdb.inquiry.standard import StandardInquiryCommand
from infi.asi.coroutines.sync_adapter import sync_wait
from infi.asi import create_os_file
from infi.exceptools import print_exc

if len(sys.argv) != 2:
    sys.stderr.write("usage: %s device_name\n" % sys.argv[0])
    sys.exit(1)

path = sys.argv[1]

f = create_os_file(path)

try:
    executer = create_platform_command_executer(f)

    inquiry = StandardInquiryCommand()
    data = sync_wait(inquiry.execute(executer))

    print(data)

    f.close()
except:
    print_exc()
Пример #7
0
def do_standard_inquiry(sg_device):
    from infi.asi.cdb.inquiry.standard import StandardInquiryCommand
    cdb = StandardInquiryCommand()
    return do_scsi_cdb(sg_device, cdb)
Пример #8
0
        # [in] Interval in seconds
        ("TimeOutValue", c_ulong),
        # [in] Pointer to the data buffer
        ("DataBuffer", c_void_p),
        # [in] Offset from the beginning of the structure to the request-sense buffer
        ("SenseInfoOffset", c_ulong),
        # [in] CDB to send to the target device
        ("Cdb", c_ubyte * 16),

        # sizeof: 16 + 4 + 8 + 4 + 4 + 1 * 7 + 2 =
        # Our sense buffer
        ("sense_buffer", c_ubyte * SENSE_SIZE)
   ]

try:
    cmd = StandardInquiryCommand()
    cmd_str = cmd.create_datagram()

    f = win32.Win32File(r"\\.\PHYSICALDRIVE0",
               win32.GENERIC_READ | win32.GENERIC_WRITE,
               win32.FILE_SHARE_READ | win32.FILE_SHARE_WRITE,
               win32.OPEN_EXISTING)

    data_buffer = create_string_buffer(96)
    print("[!] SPT length: %d (%d)" % (sizeof(SCSIPassThroughDirect) - SENSE_SIZE, sizeof(SCSIPassThroughDirect)))
    spt = SCSIPassThroughDirect()
    spt.Length = sizeof(SCSIPassThroughDirect) - SENSE_SIZE
    spt.PathId = 0
    spt.TargetId = 0
    spt.Lun = 0
    spt.CdbLength = StandardInquiryCommand.sizeof(cmd)
        ("TimeOutValue", c_ulong),
        # [in] Pointer to the data buffer
        ("DataBuffer", c_void_p),
        # [in] Offset from the beginning of the structure to the request-sense buffer
        ("SenseInfoOffset", c_ulong),
        # [in] CDB to send to the target device
        ("Cdb", c_ubyte * 16),

        # sizeof: 16 + 4 + 8 + 4 + 4 + 1 * 7 + 2 =
        # Our sense buffer
        ("sense_buffer", c_ubyte * SENSE_SIZE)
    ]


try:
    cmd = StandardInquiryCommand()
    cmd_str = cmd.create_datagram()

    f = win32.Win32File(r"\\.\PHYSICALDRIVE0",
                        win32.GENERIC_READ | win32.GENERIC_WRITE,
                        win32.FILE_SHARE_READ | win32.FILE_SHARE_WRITE,
                        win32.OPEN_EXISTING)

    data_buffer = create_string_buffer(96)
    print("[!] SPT length: %d (%d)" %
          (sizeof(SCSIPassThroughDirect) - SENSE_SIZE,
           sizeof(SCSIPassThroughDirect)))
    spt = SCSIPassThroughDirect()
    spt.Length = sizeof(SCSIPassThroughDirect) - SENSE_SIZE
    spt.PathId = 0
    spt.TargetId = 0