home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / program / 139 / c / bpb.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-05-13  |  4.4 KB  |  97 lines

  1. /****************************************************************************/
  2. /*                                                                          */
  3. /* Module:     bpb.c - Display BIOS Parameter Block of selected drive.      */
  4. /*                                                                          */
  5. /* Programmer: George R. Woodside                                           */
  6. /*                                                                          */
  7. /* Date:       January 17, 1987                                             */
  8. /*                                                                          */
  9. /****************************************************************************/
  10.  
  11. #include <stdio.h>
  12. #include <ctype.h>
  13. #include <osbind.h>
  14.  
  15. #define  RMAGIC  0x1234543L
  16.  
  17. struct bpb {
  18.   int       byt_sect;                   /* bytes per sector                 */
  19.   int       sec_clust;                  /* sectors per cluster              */
  20.   int       byt_clust;                  /* bytes per cluster                */
  21.   int       dir_len;                    /* directory length                 */
  22.   int       fat_size;                   /* file allocation table size       */
  23.   int       fat2_start;                 /* start of second copy of fat      */
  24.   int       clust_start;                /* start of data clusters           */
  25.   int       clusters;                   /* number of clusters               */
  26.   int       flags;                      /* parameter flags                  */
  27.   long      ram_start;                  /* RAMdisk only! RAM start address  */
  28.   long      ram_magic;                  /* RAMdisk only! Magic number       */
  29.   };
  30.  
  31. main(argc,argv)
  32. int   argc;
  33. char  *argv[];
  34.  
  35. {
  36.  
  37.   register  int   i;
  38.  
  39.   if(argc < 1)                          /* if no input,                     */
  40.     {
  41.       printf("Usage: bpb [drivenames]\n"); /* show usage                    */
  42.       exit(0);
  43.     }
  44.  
  45.   for(i=1; i<argc; i++)                 /* for each drive requested,        */
  46.     doit(argv[i]);                      /* display the data                 */
  47.  
  48. }
  49.  
  50. /****************************************************************************/
  51. /*                                                                          */
  52. /* Display the bpb for a specific drive.                                    */
  53. /* Display the RAM address only if drive is M.                              */
  54. /*                                                                          */
  55. /****************************************************************************/
  56.  
  57. doit(drive)
  58. char  drive[];
  59. {
  60.  
  61.   register  int     c;
  62.   register  struct  bpb  *bpb_at;
  63.  
  64.   c = drive[0];                         /* get the drive letter             */
  65.  
  66.   if( isupper(c) )                      /* insure lower case                */
  67.     c = tolower(c);
  68.  
  69.   bpb_at = (struct bpb *)Getbpb(c - 'a'); /* now get the BPB address        */
  70.  
  71.   printf("\nDrive: %c        BPB address:          %8X\n",c,bpb_at);
  72.   printf("\t\tBytes per sector:        %5d\n",bpb_at->byt_sect);
  73.   printf("\t\tSectors per cluster:     %5d\n",bpb_at->sec_clust);
  74.   printf("\t\tBytes per cluster:       %5d\n",bpb_at->byt_clust);
  75.   printf("\t\tDirectory sectors:       %5d\n",bpb_at->dir_len);
  76.   printf("\t\tFAT sectors:             %5d\n",bpb_at->fat_size);
  77.   printf("\t\tSecond FAT start sector: %5d\n",bpb_at->fat2_start);
  78.   printf("\t\tFirst data sector:       %5d\n",bpb_at->clust_start);
  79.   printf("\t\tNumber of clusters:      %5d\n",bpb_at->clusters);
  80.   printf("\t\tFlag word:               %5x  ",bpb_at->flags);
  81.  
  82.   if(bpb_at->flags & 1)                 /* if bit 0 is set,                 */
  83.     printf("(16 bit FATs)\n");          /* the FATs are 16 bits.            */
  84.   else                                  /* if it is zero,                   */
  85.     printf("(12 bit FATs)\n");          /* they are 12 bits                 */
  86.  
  87.   if( c == 'm' )                        /* if this the RAMdisk              */
  88.     {
  89.       if(bpb_at->ram_magic == RMAGIC)   /* if special RAMdisk,              */
  90.         printf("\t\tRAM data start:       %8X\n",bpb_at->ram_start);
  91.     }                                   /* end buffer address display       */
  92.  
  93.   printf("\n(Press any key.) ");        /* prompt for a keypress            */
  94.   Crawcin();                            /* then wait for one                */
  95.   printf("\n");                         /* and be neat                      */
  96. }
  97.