[comp.sys.atari.st] Programming Hard Drive access?

antony@lbl-csam.arpa (Antony A. Courtney) (09/24/89)

After looking through both the Laser C manual and the 2 Abacus books, I still
haven't a clue how to go about doing sector level hard drive access from a
C or assembly language program.  Can anyone either tell me how to do this or
point me to a reference?

Thanks!

		Antony A. Courtney
--
*******************************************************************************
Antony A. Courtney				antony@lbl.gov
Advanced Development Group			ucbvax!lbl-csam.arpa!antony
Lawrence Berkeley Laboratory			AACourtney@lbl.gov

hcj@lzaz.ATT.COM (HC Johnson) (09/25/89)

In article <3859@helios.ee.lbl.gov>, antony@lbl-csam.arpa (Antony A. Courtney) writes:
> 
> After looking through both the Laser C manual and the 2 Abacus books, I still
> haven't a clue how to go about doing sector level hard drive access from a
> C or assembly language program.  Can anyone either tell me how to do this or
> point me to a reference?

Use Rwabs(rorw,buffer,n,rec,drive)
	int rorw,n,rec,drive;
	char *buffer

	where rorw, is 0 read, 1 write
	buffer is the address to read into (keep it even, it faster)
	n is number of sectors (2 sectors make a cluster)
	rec is the starting sector on the logical drive. (thats why
		TOS partiions are limited to 32 MB)
	drive is the logical drive:
		0 is A floppy, 1 is B floppy, 2-14 are the hard drive partition.

A common extension, in SUPRA/ICD/and HDX3 formats is to or 8 to the rorw.
This then changes the interpretation  of n to ABSOLUTE sector.
This is GREAT for read/write of the boot sector (0) of the hard disk.

for floppies, you can also or 2 to rorw, meaning doent alter medium change

and for some, or 4, meaning dont retry on error, just report it.

Enjoy.

Howard C. Johnson
ATT Bell Labs
att!lzaz!hcj
hcj@lzaz.att.com

root@yale.UUCP (Root Of All Evil) (09/25/89)

In article <3859@helios.ee.lbl.gov> antony@lbl-csam.arpa (Antony A. Courtney) writes:
>
>After looking through both the Laser C manual and the 2 Abacus books, I still
>haven't a clue how to go about doing sector level hard drive access from a
>C or assembly language program.  Can anyone either tell me how to do this or
>point me to a reference?

Check out the Bios (Xbios?) routine Rwabs.

==================================================
| Michael Fischer                                |
|    Arpanet:    <fischer-michael@cs.yale.edu>   |
|    Bitnet:     <fischer-michael@yalecs.bitnet> |
|    UUCP:       <fischer-michael@yale.UUCP>     |
==================================================

antony@lbl-csam.arpa (Antony A. Courtney) (09/26/89)

In article <799@lzaz.ATT.COM> hcj@lzaz.ATT.COM (HC Johnson) writes:
>In article <3859@helios.ee.lbl.gov>, antony@lbl-csam.arpa (Antony A. Courtney) writes:
>> 
>> After looking through both the Laser C manual and the 2 Abacus books, I still
>> haven't a clue how to go about doing sector level hard drive access from a
>> C or assembly language program.  Can anyone either tell me how to do this or
>> point me to a reference?
>
>Use Rwabs(rorw,buffer,n,rec,drive)
>

I appologize.  I hadn't worded my aritcle correctly at all.  What I really want
to know is how I can write sector level access routines which call things like
Rwabs() to access files.  How can I find out the mapping of files->sectors. I
assume this is an intrinisic part of the directory structure, unfortunatley I
can not seem to find anything describing how this works.  A piece of sample
code which uses rwabs() to access a file would be nice.  A description of this
would also be nice.  And if nothing else, a pointer to a reference which
describes this would also be appreciated.

Thanks!

		Antony A. Courtney

--
*******************************************************************************
Antony A. Courtney				antony@lbl.gov
Advanced Development Group			ucbvax!lbl-csam.arpa!antony
Lawrence Berkeley Laboratory			AACourtney@lbl.gov

dlm@druwy.ATT.COM (Dan Moore) (09/26/89)

in article <3867@helios.ee.lbl.gov>, antony@lbl-csam.arpa (Antony A. Courtney)
says:
> I appologize.  I hadn't worded my aritcle correctly at all.  What I really want
> to know is how I can write sector level access routines which call things like
> Rwabs() to access files.  How can I find out the mapping of files->sectors. I
> assume this is an intrinisic part of the directory structure, unfortunatley I
> can not seem to find anything describing how this works.  A piece of sample
> code which uses rwabs() to access a file would be nice.  A description of this
> would also be nice.  And if nothing else, a pointer to a reference which
> describes this would also be appreciated.

	Books on MSDOS which cover the filesystem (GEMDOS is modeled
after MSDOS):

	Programmer's Guide to the IBM PC -- Peter Norton, Microsoft Press

	Advanced MSDOS -- Ray Duncan, Microsfot Press

	Microsoft MSDOS Reference Manual (also available from IBM)


	Most good bookstores should have the first two books, good
computer stores should carry the last (check IBM dealers).  All cover
the logical layout of the MSDOS filesystem, GEMDOS is almost 100%
compatible (GEMDOS ignores some fields that MSDOS cares about).

	You also might want to check out the back issues of STLog
magazine, Dave Small and I had an article on CHK in it about 18 months
ago.  CHK is a GEMDOS/MSDOS filesystem tester, it includes code to do
logical (ie. file level) to physical (ie. sector level) translations. 
The C source and binary were on the disk included with the magazine.



				Dan Moore
				AT&T Bell Labs
				Denver
				dlm@druwy.ATT.COM