Skip to contentSkip to conversation

SG_IO

DISCUSSION Julian Bangert 1 participant 1 message Apr 2, 2010 SCSI

lore
Share & tools
lore
#0 lore raw

Hello,
I want to write a tape utility using the SG_IO interface (because I don't have the expensive IBM one ;) ) but I have got a problem with the SCSI interface.
My program looks as follows:

    ioctl(g_fd,SG_IO,&io_hdr);
    memset(&io_hdr, 0, sizeof(struct sg_io_hdr));
        struct read_attr_cmd cmd;
        cmd.opcode = 0x8C;
        cmd.s_action = 0;
        cmd.pad1 = cmd.pad2 = cmd.pad3 = cmd.pad4 = 0;
        cmd.volid = cmd.partition = 0;
        cmd.attrib_id = htons(attribs[idx].id);
        cmd.size = htonl(buffer_size);
        cmd.control = 0;
        
        assert(sizeof(struct read_attr_cmd) == 16);
    
        io_hdr.interface_id='S';
        io_hdr.cmd_len = 16;//sizeof cmd;
        io_hdr.mx_sb_len= sizeof(sense_b);
        io_hdr.dxfer_direction = SG_DXFER_FROM_DEV;
        io_hdr.dxferp = buffer;
        io_hdr.dxfer_len = buffer_size;
        io_hdr.cmdp = (unsigned char *) &cmd;
        io_hdr.sbp = sense_b;
        io_hdr.timeout = 10000;
        
        if(ioctl(g_fd,SG_IO,&io_hdr) == -1)

The IOCTL succeeds, but io_hdr.host_status contains SG_ERR_DID_ABORT. All other fields are not touched. I am using an Adaptec 29160N(AIC7892) with the adaptec aix7xxx driver on Linux 2.6.31 (ubuntu). As far as I know this driver supports 16 Byte commands.

Thank you very much for your assistance,

-- Julian Bangert