#!/usr/bin/python import sys import os import fcntl import struct import array PAD_SIZE=1023 if __name__ == "__main__": prog, drv = sys.argv fd = os.open(drv, os.O_RDONLY|os.O_NONBLOCK) b = array.array('c') b.extend(struct.pack("@L", 0)) # length of input b.extend(struct.pack("@L", 1024)) # length of output buffer b.append(chr(0x12)) # INQUIRY */ b.append(chr(0x00)) # lun=0, evpd=0 */ b.append(chr(0x00)) # page code = 0 */ b.append(chr(0x00)) # (reserved) */ b.append(chr(0xff)) # allocation length */ b.append(chr(0x00)) # control */ b.extend(chr(0) * (PAD_SIZE - len(b))) old_b = b[:] status = fcntl.ioctl(fd, 1, b, True) print "status", status assert not status, "%s" % status assert b[:] != old_b[:], "BUG: output wasn't changed!" print "POST", b pagestart = b[8:] print pagestart[8:16] print pagestart[16:32] print pagestart[32:48]