home *** CD-ROM | disk | FTP | other *** search
- Copyright (c) 1988 by Edward V Dong, All Rights Reserved.
-
- This archive contains code to determine the total number of sectors
- on a disk (any disk, hard or floppy), and do a simple verification of
- the disk by simply reading each and every sector on the disk.
-
- Two files are provided: Source (ADISK.C) and executable (ADISK.EXE).
-
- Compiler: Turbo C version 1.5. Should also work with version 1.0.
- Although I have not yet received TC ver 2.0,
- this should still work with ver 2.0.
-
- NOTE: You should compile with Char as UNSIGNED. If you don't, you'll
- probably get a compiler error.
-
- The key Turbo C routine used is "absread", summarized as follows.
-
- int absread(drive,nsects,sectno,buffer)
- int drive,int nsects,int sectno,void *buffer;
- - reads disk absolute logical sectors
- - drive = 0(A), 1(B), etc
- - nsects = # of sectors to read
- - sectno = beginning logical sector number
- - buffer = address of buffer
- - returns 0 if OK; -1 on error; 'errno' = DOS error number
- - needs dos.h
-
- Logical sectors start with 0. What the manual doesn't tell you is
- that DOS (and Turbo C) doesn't really manage the stacks very well,
- when doing "absread". The parameters passed to 'absread' should be
- global or static. If you try using parameters created within the routine,
- the values are not preserved or incremented. This is probably a
- function of DOS, since any alternate version runs into the same
- problems.
-
- The routine, as written, provides information about the disk organization,
- and optionally allows verification of the disk through reading each
- sector on the disk. For this implementation, I've simply used a buffer
- of 16K, which allows 32 sectors to be read at a time for a 1.2M disk.
- Hard disks, formatted under DOS 3.2 or higher, of 20 MB or greater,
- lowers this to 16 sectors at a time (sector size being 1024).
-
- Edward V. Dong
- 71641,2371 on CompuServ
- E.DONG on GENIE
-