home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / SRC / msdos_diskaccess.lzh / MS_DISK_ACCESS / msdos.h < prev    next >
Text File  |  1991-07-20  |  2KB  |  57 lines

  1. /*
  2.  * msdos common header file
  3.  */
  4.  
  5. #define MSECSIZ    512            /* sector size */
  6. #define MDIRSIZ    32            /* directory size */
  7. #define CLSTRBUF 1024            /* largest cluster size */
  8. #define MAX_PATH 128
  9.  
  10. struct directory {
  11.     unsigned char    name[8];    /* file name */
  12.     unsigned char    ext[3];        /* file extent */
  13.     unsigned char    attr;        /* attribute byte */
  14.     unsigned char    reserved[10];    /* ?? */
  15.     unsigned char    time[2];        
  16.     unsigned char    date[2];
  17.     unsigned char    start[2];    /* starting cluster number */
  18.     unsigned char    size[4];    /* size of the file */
  19. };
  20.  
  21. struct superblock {
  22.   unsigned char jump[3] ;       /* Jump to boot code */
  23.   unsigned char banner[8];    /* OEM name & version */
  24.   unsigned char secsiz[2];    /* Bytes per sector hopefully 512 */
  25.   unsigned char clsiz ;         /* Cluster size in sectors */
  26.   unsigned char nrsvsect[2];    /* Number of reserved (boot) sectors */
  27.   unsigned char nfat;           /* Number of FAT tables hopefully 2 */
  28.   unsigned char dirents[2];    /* Number of directory slots */
  29.   unsigned char psect[2];    /* Total sectors on disk */
  30.   unsigned char descr;          /* Media descriptor=first byte of FAT */
  31.   unsigned char fatlen[2];    /* Sectors in FAT */
  32.   unsigned char nsect[2];    /* Sectors/track */
  33.   unsigned char ntrack[2];    /* tracks/cyl */
  34.   unsigned char nhs[2];        /* number of hidden sectors ? */
  35. } ;
  36.  
  37. union bootblock {
  38.   char dummy[MSECSIZ] ;
  39.   struct superblock sb ;
  40. } ;
  41.  
  42. #define WORD_VAL(x) ((x)[0] + ((x)[1] << 8))
  43.  
  44. #define SECSIZ(x)    WORD_VAL(x.secsiz)
  45. #define CLSIZ(x)    (x.clsiz)
  46. #define FSSIZ(x)    WORD_VAL(x.psect)
  47. #define DIRENTS(x)    WORD_VAL(x.dirents)
  48. #define FATLEN(x)    WORD_VAL(x.fatlen)
  49. #define DIRLEN(x)    ((DIRENTS(x)*MDIRSIZ-1)/MSECSIZ+1)
  50. #define FATOFF(x)    WORD_VAL(x.nrsvsect)
  51. #define DIROFF(x)    (FATOFF(x)+FATLEN(x)*x.nfat)
  52. #define NCLUST(x)    (FSSIZ(x)-DIROFF(x)-DIRLEN(x)-WORD_VAL(x.nhs))/CLSIZ(x)
  53. #define NSECT(x)    WORD_VAL(x.nsect)
  54. #define NTRACK(x)    WORD_VAL(x.ntrack)
  55. #define NCYL(x)        (FSSIZ(x)/(NTRACK(x)*NSECT(x)))
  56. #define FATCODE(x)    (x.descr)
  57.