home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / ADISK.ZIP / ADISK.DOC < prev    next >
Encoding:
Text File  |  1988-10-24  |  2.0 KB  |  46 lines

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