5

我正在尝试将缓冲区数据写入 SCSI 设备,但是当我触发 deviceIoControl 调用时,我收到 Windows 错误代码 183。错误代码表明文件已经退出,但我无法理解与 IOCTL 调用有关的错误。

CreateFile 函数传递,因为我能够获得适当的设备句柄,如下所示。

int devHandle = DeviceIoControlHelper.CreateFile(设备名称,DeviceIoControlHelper.GENERIC_READ | DeviceIoControlHelper.GENERIC_WRITE,DeviceIoControlHelper.FILE_SHARE_READ | DeviceIoControlHelper.FILE_SHARE_WRITE,IntPtr.Zero,DeviceIoControlHelper.OPEN_EXISTING,0,IntPtr.Zero);

但是,当我尝试写入缓冲区时,出现错误:

 dwReturned = 0;
        int b = DeviceIoControlHelper.DeviceIoControl(
                devHandle,
                DeviceIoControlHelper.IOCTL_SCSI_PASS_THROUGH,
                inpBuffer,
                (uint)Marshal.SizeOf(info),
                inpBuffer, //out pDriveLayout,
                (uint)Marshal.SizeOf(info), //(uint)Marshal.SizeOf(typeof(DRIVE_LAYOUT_INFORMATION_EX)),
                out dwReturned,
                IntPtr.Zero);

        Log.Write(Log.TraceLevel_5,"ExecuteDeviceIoControl return pass_through scsistatus = " + info.spt.ScsiStatus);
        if (b == 0)
        {
            int win_err = this.GetWindowsErrorCode();
            Log.Write(Log.TraceLevel_5, "ExecuteDeviceIoControl failed, error =  " + win_err);
            LogMyTrace.Write(LogMyTrace.TraceLevel_5, "ExecuteDeviceIoControl failed, error =  " + win_err);

            this.CloseOpenHandle(devHandle);
            Marshal.FreeHGlobal(inpBuffer);
            throw new Exception("DeviceIoControl  failed " + deviceName +
                    " is '" + deviceName + "'. Windows Err is " + win_err);
        }
The error code is 183.

请提供一些输入,说明导致此错误的原因和建议。

我使用的是 Windows 2008 R2 (x64),它是 iSCSI 路径。

4

0 回答 0