Solved

Send arbitrary SCSI command

Posted on 1997-03-07
2
1,404 Views
Last Modified: 2013-12-28
Hello,

we need to be able to send an arbitrary SCSI command to any device attached to NT 4.0 Server through a SCSI miniport driver. Using DOS/ASPI will not work, because:

Background: Using Seagate Barracuda Fibre Channel drives connected to an Emulex LightPulse Fibre Channel host adapter. The Emulex works through a SCSI miniport driver, but no DOS ASPI drivers are available for it. We wish to enable the write cache on the Seagate drives, which can be done through a SCSI command (SCSI-3 sits "atop" Fibre Channel).

If you have written or know of an application that can send SCSI commands through a SCSI miniport driver (or rather, the Win32 API), we'd like to hear from you.

Soenke Behrens
0
Comment
Question by:sbehrens
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Accepted Solution

by:
Schmelnik earned 200 total points
ID: 1776755
Hi!

There are two ways to solve your problem:
1. You write your code for the ASPI for Win32, but this is not included in Windows NT. As i knows only Adaptec supplies one for their controllers. You can find it even with the necessary documentation on Adaptec Web-Server.
But if you aren't sure that your program would always run on a NT system with an installed ASPI manager, i think you should prefer the second method:
2. You could send normal SCSI commands through the DeviceIOControl command. You can find an example for this in the Windows NT DDK at ddk\src\storage\class\spti
Below you find the interesting parts. But i think that this method has a disadvantage, because my tests have shown that each call with this parameters to DeviceIOControl will cause a memory leak of about 300 bytes. I don't know why, but i think this is a bug of NT.

If you need more info, simply ask.

regards,
Christoph Schmelnik



#include <devioctl.h>
#include <ntdddisk.h>
#include <ntddscsi.h>

    SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER sptdwb;
    ZeroMemory(&sptdwb, sizeof(SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER));
    ZeroMemory(dataBuffer,sectorSize);

    sptdwb.sptd.Length = sizeof(SCSI_PASS_THROUGH_DIRECT);
    sptdwb.sptd.PathId = 0;
    sptdwb.sptd.TargetId = 1;
    sptdwb.sptd.Lun = 0;
    sptdwb.sptd.CdbLength = CDB10GENERIC_LENGTH;
    sptdwb.sptd.DataIn = SCSI_IOCTL_DATA_IN;
    sptdwb.sptd.SenseInfoLength = 24;
    sptdwb.sptd.DataTransferLength = sectorSize;
    sptdwb.sptd.TimeOutValue = 2;
    sptdwb.sptd.DataBuffer = dataBuffer;
    sptdwb.sptd.SenseInfoOffset =
       offsetof(SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER,ucSenseBuf);
    sptdwb.sptd.Cdb[0] = SCSIOP_READ_DATA_BUFF;
    sptdwb.sptd.Cdb[1] = 2;                         // Data mode
    sptdwb.sptd.Cdb[7] = (UCHAR)(sectorSize >> 8);  // Parameter List length
    sptdwb.sptd.Cdb[8] = 0;
    length = sizeof(SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER);
    status = DeviceIoControl(fileHandle,
                             IOCTL_SCSI_PASS_THROUGH_DIRECT,
                             &sptdwb,
                             length,
                             &sptdwb,
                             length,
                             &returned,
                             FALSE);



0
 

Expert Comment

by:Noatec
ID: 3480033
Schmelnik,

How would you do this on a WIN95 machine? Different headers?
0

Featured Post

Save the day with this special offer from ATEN!

Save 30% on the CV211 using promo code EXPERTS30 now through April 30th. The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

An article on effective troubleshooting
A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decadeā€¦

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question