From: Robert Tonsing on
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: Jeff Goldner [MS] on
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: Robert Tonsing on
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: msnews.microsoft.com on
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: Robert Tonsing on
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
> >>
> >>
> >>
>
>
>