[comp.sys.amiga.programmer] HD CMD_READ solved - solution and question

sl87m@cc.usu.edu (The Barking Pumpkin Digital Gratification Ensemble) (06/27/91)

In article <1410@cbmger.UUCP>, peterk@cbmger.UUCP (Peter Kittel GERMANY) writes:
> In article <1991Jun24.125808.48207@cc.usu.edu> sl87m@cc.usu.edu (The Barking Pumpkin Digital Gratification Ensemble) writes:
>>Hi!
>>
>>I'm trying to access block directly on hard drives, but (obviously) I've got a
>>problem:
>>
>>I OpenDevice(...) fine, but when I go to do a DoIO(...), my machine crashes. If
>>I do an OpenDevice(TD_NAME....), and turn on the drive motor, then do the
>>DoIO(), it works fine.  What could I possibly be doing wrong?  My assumption is
>>that  CMD_READ,CMD_WRITE are universal for all devices, trackdisk or whatever.
> 
> Yes, the commands are universal, but *NOT* the device name. TD_NAME stands
> for TrackDisk device. Any harddisk has its own driver. At first you must
> find out the name of this driver, which you can spot in the device list,
> see other thread in this newsgroup. Then take this name for your OpenDevice,
> and all works ok.

I guess that I didn't make myself clear on this point. I *was* using the hard
drive device's name. I used TD_NAME as a test to see if there was any gross
and obvious errors. Sorry.

For those interested, here's what the problem was. (I finally figured it out at
a bleary 1:00 am last night.)

My hard drive is partitioned into DH0: and DH1:.
The unit number required by OpenDevice() is not the number in DH?. (e.g. it's
not 0 for DH0:.)  This was my silly assumption after playing with
trackdisk.device a lot.  The unit number is the physical number of the drive
that is defined by the drive's jumpers.  My hard drive's unit number is 1.
When, out of desperation, I tried opening "DH1" -- it worked! That tipped me
off. After that I checked dn_Startup->fssm_Unit and my MountList -- they 
agreed. So I belive that I've got the right answer. (It works now, and it 
seems now like it should have been "obvious.")

                                -=+=-

Curiosity yes/no question:

CMD_READ seems to be taking an absolute block number, ignoring any partitioning
of the drive. Is this true? (I have to convert partition block numbers into
absolute block numbers to access the correct block.  e.g. DH0: goes from track
2 to track 445 with 26 sectors/track, 7 heads/cylinder -- I have to add 2*26*7
= 364 to DH0's block number to get at it.)


James

P.S.   ************ THANK YOU ************ to _everybody_ that suggested a
solution. I did help to eliminate possible causes.


---
#include <std_disclaimer.h>
#include <cute_sig.h>

peterk@cbmger.UUCP (Peter Kittel GERMANY) (06/27/91)

In article <1991Jun26.133654.48232@cc.usu.edu> sl87m@cc.usu.edu (The Barking Pumpkin Digital Gratification Ensemble) writes:
>
>Curiosity yes/no question:
>
>CMD_READ seems to be taking an absolute block number, ignoring any partitioning
>of the drive. Is this true? (I have to convert partition block numbers into
>absolute block numbers to access the correct block.  e.g. DH0: goes from track
>2 to track 445 with 26 sectors/track, 7 heads/cylinder -- I have to add 2*26*7
>= 364 to DH0's block number to get at it.)

Same on all my disks. (not the numbers :-)

-- 
Best regards, Dr. Peter Kittel  // E-Mail to  \\  Only my personal opinions... 
Commodore Frankfurt, Germany  \X/ {uunet|pyramid|rutgers}!cbmvax!cbmger!peterk

S_ASCHMIDT@iravcl.ira.uka.de (|S| Angela Schmidt) (06/27/91)

In <1991Jun26.133654.48232@cc.usu.edu> sl87m@cc.usu.edu writes:
> 
> Curiosity yes/no question:
> 
> CMD_READ seems to be taking an absolute block number, ignoring any partitioning
> of the drive. Is this true? (I have to convert partition block numbers into
> absolute block numbers to access the correct block.  e.g. DH0: goes from track
> 2 to track 445 with 26 sectors/track, 7 heads/cylinder -- I have to add 2*26*7
> = 364 to DH0's block number to get at it.)
> 

Yes, that's true! Only the filesystem knows about your partitions. The device
doesn't know anything about it. But some programs - like sectorama - don't
know this.

To get infos about the mounted partitions you have to read the devicelist.
I posted an article how to do this 2 days ago. If you don't read the
devicelist your program will only run on Amigas with the same harddisks
and harddisk-partitions like yours. (If you coded your program to run
on _your_ Amiga). That's no good solution...

In some harddisk the partition-information is also contained in the
Rigid-Disk-Blocks (on the first cylinders of the harddisk).

If you're interessted I see your Rigid-Disk-Blocks (I think you use some,
since your partition begins at cylinder 2), you can read them using the
device. It also makes fun to find non-coded passwords in there (like
in ALF2.0 :-).

You even can get information about the Rigid-Disk-Blocks using a simple
diskmonitor (for harddisks): Mount the Rigid-Disk-Block as an own partition
(without using a standard filesystem, instead take somethink like a
dummy-handler) and you can use the diskmonitor to look into these blocks.
Or just take sectorama. :-)

> 
> James
> 

Hope it helps

Angela




---------------------------------------------------------+---------------------
Angela Schmidt   Internet: S_ASchmidt@iravcl.ira.uka.de  |        //
(Nessy in IRC)   BITNET:   UK8B@DKAUNI2.BITNET           | Amiga //
                 Phone:    +49 731 712316 & 721 6904-263 |   \\ // only 1000
                           MEZ: (10am-9pm)  (12pm-10pm)  |    \X/ the real one!
---------------------------------------------------------+---------------------