1: /*	blockio.c	1.4	83/05/13	*/
   2: 
   3: #include <stdio.h>
   4: #include "cpmio.h"
   5: 
   6: /*
   7:  * Get a full block or a part of a block from floppy disk file
   8:  * nsect gives the actual number of physical sectors to read.
   9:  * if nsect is negative then always read a full block.
  10:  */
  11: 
  12: getblock(blockno, buffer, nsect)
  13:     char buffer[];
  14: {
  15: 
  16:     int sect, track, counter;
  17: 
  18: #ifdef DEBUG
  19:     printf("block: %d\n",blockno);
  20: #endif
  21:     if (nsect < 0)
  22:         nsect = blksiz/seclth;
  23: 
  24:     /* Translate block number into logical track/sector address */
  25:     sect = (blockno*(blksiz/seclth)+ sectrk*2)%sectrk + 1;
  26:     track = (blockno*(blksiz/seclth)+ sectrk*2)/sectrk ;
  27:     /* read the block */
  28:     for (counter = 0; counter < nsect; counter++) {
  29:         if (getpsect(track, skewtab[sect++ -1], buffer+(seclth*counter))
  30:                 == EOF)
  31:             return (EOF);
  32:         if (sect > sectrk) {
  33:             sect = 1;
  34:             track++;
  35:         }
  36:     }
  37:     return (0);
  38: }
  39: 
  40: /*
  41:  * Save a full block or a part of a block in floppy disk file
  42:  * If nsects is negative, write a full block.
  43:  */
  44: 
  45: putblock(blockno, buffer, nsect)
  46:     char buffer[];
  47: {
  48: 
  49:     int sect, track, counter;
  50: 
  51:     if (nsect < 0)
  52:         nsect = blksiz/seclth;
  53: 
  54:     /* Translate block number into logical track/sector address */
  55:     sect = (blockno*(blksiz/seclth)+ sectrk*2)%sectrk + 1;
  56:     track = (blockno*(blksiz/seclth)+ sectrk*2)/sectrk ;
  57:     /* write the block */
  58:     for (counter = 0; counter < nsect; counter++) {
  59:         if (putpsect(track, skewtab[sect++ -1],buffer+(seclth*counter))
  60:                 == EOF)
  61:             return (EOF);
  62:         if (sect > sectrk) {
  63:             sect = 1;
  64:             track++;
  65:         }
  66:     }
  67:     return (0);
  68: }

Defined functions

Last modified: 1983-06-24
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 819
Valid CSS Valid XHTML 1.0 Strict