On Fri, 3 Feb 2017 09:44:31 +0100, R.Wieser wrote:
>
> Maybe that "disk block size" is what I'm after ... Any info/keywords to how
> to retrieve it ?
SCSI storage's block size is not like what you think. In SCSI storage device
specifications, "block size" refers to the storage media sector size. i.e.
LBA sector. For older and current hard disk (platter, SSD/flash), the block
size is 512 bytes. Newer ones have be 4096 bytes block size. FYI,
CD/DVD/Bluray/HD-DVD ranges from 2048 (standard) to 2352 (raw/audio; CD
only) bytes.
Send the SCSI packet using IOCTL_SCSI_PASS_THROUGH /
IOCTL_SCSI_PASS_THROUGH_DIRECT via DeviceIoControl. In Windows NT SDK's
term, it's called SPT. The other method is to use ASPI (Adaptec's SCSI API).
ASPI is simpler and easier than SPT, but it's less flexible. ASPI was
initially designed for DOS, BTW.
For crash course on accessing SCSI devices, I'd recommend ASPI's
documentation. It's brief but it'll make you grasp SCSI API model pretty
quickly.
Or you can just get right into the SCSI specifications at:
<
http://www.t10.org/>
The documentations you should get are:
1. SPC. Generic commands for all SCSI devices. The SCSI command you want is
in here (Mode Sense). See SBC for the returned data format if you're
retrieving block-specific device information.
2. SBC. Commands for block devices. i.e. disks, not opticals/discs.
3. RBC (optional). Reduced command set of SBC. Only some devices support it.
Note that these documentations mostly are references, just like any other
specifications of things. There's no tutorial or how-to.
> In the same method as I described for writing the stick ? Didn't think of
> doing it that way.
Yes. By reading the disk sectors with both hardware & software cache
disabled. Writing onto a flash-based storage decreases its lifetime, as you
probably already know. IIRC, accessing a disk from a disk handle (not volume
handle) by defaults disables the disk level software cache. So, you only
need to disable the hardware cache via SCSI command.