Solved

Send arbitrary SCSI command

Posted on 1997-03-07
2
1,394 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
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

Want to promote your upcoming event?

Are you going to an event? Are you going to be exhibiting at a tradeshow? Talking at a conference? Using a promotional banner in your email signature ensures that your organization’s most important contacts stay in the know and can potentially spread the word about the event.

Join & Write a Comment

A few months ago I had an issue with LaserJet 1020 printer which was installed to XP and Windows 7.  It was installed to XP and working, but when I tried to connect from a Windows 7 PC, it would attempt connection and then fail.  Sometimes the Spool…
In this article, I will show you HOW TO: Perform a Physical to Virtual (P2V) Conversion the easy way from a computer backup (image).
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …

759 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now