Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Golang中编写SCSI命令(WriteAtomic,Read16)?_Go_Ioctl_Scsi - Fatal编程技术网

如何在Golang中编写SCSI命令(WriteAtomic,Read16)?

如何在Golang中编写SCSI命令(WriteAtomic,Read16)?,go,ioctl,scsi,Go,Ioctl,Scsi,在Golang/Ubuntu环境中工作 这些领域面临的问题 打开驱动器的正确命令是什么** 2//Read16 sendCMD := []byte {0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xff, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00} cmdBuf := make([]byte, 16) senseBuf := make([]byte, 512) ioHdr := SgIoHdr

在Golang/Ubuntu环境中工作

这些领域面临的问题 打开驱动器的正确命令是什么**

2//Read16

sendCMD := []byte {0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xff, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00} 

cmdBuf := make([]byte, 16)

senseBuf := make([]byte, 512)

ioHdr   := SgIoHdr{
        InterfaceID:    int32('S'),                     
        DxferDirection: SG_DXFER_FROM_DEV,        
        CmdLen:         uint16(len(sendCMD )),           
        MxSbLen:        SENSE_BUF_LEN,           
        DxferLen:       uint32(len(cmdBuf )),               
        Dxferp:         &cmdBuf [0],
        SCmd:           sendCMD [0],
        Sbp:            &senseBuf[0],
        Timeout:        60000,
    }

err :=  exec_ioctl(&ioHdr)

    if err != nil {

        return err
    }


func Ioctl(fd, cmd, ptr uintptr) error {

    _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, cmd, ptr)

}
当试图读取驱动器返回的数据时,它总是返回00

即使将错误的操作码发送到驱动器,err始终返回0 ie SCSI\U状态良好

Read16命令中是否存在任何问题

3。如何将WRITEATOMIC命令发送到像Read16这样的驱动器?

sendCMD := []byte {0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xff, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00} 

cmdBuf := make([]byte, 16)

senseBuf := make([]byte, 512)

ioHdr   := SgIoHdr{
        InterfaceID:    int32('S'),                     
        DxferDirection: SG_DXFER_FROM_DEV,        
        CmdLen:         uint16(len(sendCMD )),           
        MxSbLen:        SENSE_BUF_LEN,           
        DxferLen:       uint32(len(cmdBuf )),               
        Dxferp:         &cmdBuf [0],
        SCmd:           sendCMD [0],
        Sbp:            &senseBuf[0],
        Timeout:        60000,
    }

err :=  exec_ioctl(&ioHdr)

    if err != nil {

        return err
    }


func Ioctl(fd, cmd, ptr uintptr) error {

    _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, cmd, ptr)

}