From: msnews.microsoft.com on
Those opcodes are not READ and WRITE (as in disk sectors). They are
multi-purpose opcodes used for functions like updating firmware (actual
usage depends on device and what command set it supports - in the example
these are used by CD-ROMs). The reason you got a check condition on the
WRITE BUFFER to a disk is that a) you didn't have a correctly formed buffer,
and b) you would have needed vendor provided firmware for the device.

The appropriate opcodes are SCSIOP_READ and SCSIOP_WRITE. Consult
www.t10.org and look at SBC or SBC-2 for disk devices.

"Robert Tonsing" <RobertTonsing(a)discussions.microsoft.com> wrote in message
news:9EA06FEB-DA5E-44F4-B292-AEFAFA98E584(a)microsoft.com...
> This is cut & pasted directly from the (original) sample output:
>
> ***** WRITE DATA BUFFER operation *****
> Error: 1 Incorrect function.
>
> ***** READ DATA BUFFER operation *****
> Error: 1 Incorrect function.
>
> and from spti.c:
> sptdwb.sptd.Cdb[0] = SCSIOP_WRITE_DATA_BUFF;
> .
> sptdwb.sptd.Cdb[0] = SCSIOP_READ_DATA_BUFF;
>
> Don't see how much more sense it can make, if those aren't READ or WRITE
> operations, what are they?
>
> It's a moot point now, I have my code working in spite of the sample.
>
> Thanks anyway.
> --
> Robert Tonsing
>
>
> "msnews.microsoft.com" wrote:
>
>> The sample from the Server 2003 SP1 DDK doesn't do any READ or WRITE
>> operations so claiming it doesn't "work out of the box" doesn't make much
>> sense to me.
>>
>> Also, a SCSI status of 2 is a "Check Condition" which means the device
>> failed the command which can happen for a lot of reasons. A check
>> condition
>> is typically followed by sense data which gives you more details about
>> what
>> failed. The specs should help you parse through that data and point you
>> to
>> the bit or bits in error.
>>
>> The appropriate SCSI specifications from www.t10.org will give you more
>> information (SAM-2 or SAM-3; SPC-2 or SPC-3 and SBC since this is a
>> disk).
>>
>> As a warning, doing direct writes to a disk requires not messing with any
>> blocks that might be used by volumes or filesystems, which is most of
>> them.
>> If you are using RAW devices, this should be fine.
>>
>> "Robert Tonsing" <RobertTonsing(a)discussions.microsoft.com> wrote in
>> message
>> news:8FDE7DB1-9B12-4328-8522-757880144D4E(a)microsoft.com...
>> > Thanks for the quick response.
>> >
>> > The permissions are:
>> > shareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; // default
>> > accessMode = GENERIC_WRITE | GENERIC_READ; // default
>> > as defined in the sample in the DDK.
>> >
>> > My main gripe is that the sample doesn't work, directly out of the box
>> > with
>> > no changes. The purpose of a "sample" should be to show me how to do
>> > it,
>> > not
>> > for me to figure out out to fix it. BTW, the DDK is Win Server 2003
>> > SP1,
>> > and
>> > I am running it on XP Pro SP2 (admin, of course), for more info.
>> >
>> > Like I said, I got Read to work using a different command, but Write
>> > (0x2A)
>> > returns a SCSI error 2, whatever that is.
>> >
>> > I had similar experience with ATA_PASS_THROUGH, read works great, but
>> > write
>> > does not (although the call passes). Was hoping SCSI pass through would
>> > work
>> > better.
>> > --
>> > Thanks
>> > Robert Tonsing
>> >
>> >
>> > "Jeff Goldner [MS]" wrote:
>> >
>> >> Hopefully you did the CreateFile with the correct permissions to allow
>> >> a
>> >> write to the device.
>> >> Check every bit in the CDB carefully - also the request block for that
>> >> matter (like the direction flag). Also current versions of the OS do
>> >> not
>> >> do
>> >> a good job of returning useful information on some SCSI errors in the
>> >> passthrough path.
>> >>
>> >> "Robert Tonsing" <RobertTonsing(a)discussions.microsoft.com> wrote in
>> >> message
>> >> news:2C72B5D7-B1E0-4C7A-965F-5089AAC7C424(a)microsoft.com...
>> >> > Hi,
>> >> >
>> >> > When I build & run this sample on a secondary hard disk (e:), I get
>> >> > "Incorrect function" errors on the write and read data buffer
>> >> > operations.
>> >> > Any
>> >> > reason this sample shouldn't work as is?
>> >> >
>> >> > Ultimately I need to read & write directly to a disk, as the sample
>> >> > should
>> >> > do. I can get read to work by changing to a read sector command
>> >> > 0x28,
>> >> > but
>> >> > still fail with write sector command 0x2A.
>> >> >
>> >> > Any help would be greatly appreciated, I'm new to SCSI i/o.
>> >> > --
>> >> > Robert Tonsing
>> >>
>> >>
>> >>
>>
>>
>>


From: Maxim S. Shatskih on
> The appropriate opcodes are SCSIOP_READ and SCSIOP_WRITE. Consult

Yes. And they also have "short" and "long" form - different bitness of the
sector address. READ6 and READ10, and now also IIRC READ16.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim(a)storagecraft.com
http://www.storagecraft.com


From: Jeff Goldner [MS] on
correct. SCSIOP_READ is the 10 byte form, READ6, READ12 and READ16 are also
possible. Check SBC and SBC-2 for more info.

"Maxim S. Shatskih" <maxim(a)storagecraft.com> wrote in message
news:%23MizIaE1FHA.2792(a)tk2msftngp13.phx.gbl...
>> The appropriate opcodes are SCSIOP_READ and SCSIOP_WRITE. Consult
>
> Yes. And they also have "short" and "long" form - different bitness of the
> sector address. READ6 and READ10, and now also IIRC READ16.
>
> --
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> maxim(a)storagecraft.com
> http://www.storagecraft.com
>
>