home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************/
- /* */
- /* Module: bpb.c - Display BIOS Parameter Block of selected drive. */
- /* */
- /* Programmer: George R. Woodside */
- /* */
- /* Date: January 17, 1987 */
- /* */
- /****************************************************************************/
-
- #include <stdio.h>
- #include <ctype.h>
- #include <osbind.h>
-
- #define RMAGIC 0x1234543L
-
- struct bpb {
- int byt_sect; /* bytes per sector */
- int sec_clust; /* sectors per cluster */
- int byt_clust; /* bytes per cluster */
- int dir_len; /* directory length */
- int fat_size; /* file allocation table size */
- int fat2_start; /* start of second copy of fat */
- int clust_start; /* start of data clusters */
- int clusters; /* number of clusters */
- int flags; /* parameter flags */
- long ram_start; /* RAMdisk only! RAM start address */
- long ram_magic; /* RAMdisk only! Magic number */
- };
-
- main(argc,argv)
- int argc;
- char *argv[];
-
- {
-
- register int i;
-
- if(argc < 1) /* if no input, */
- {
- printf("Usage: bpb [drivenames]\n"); /* show usage */
- exit(0);
- }
-
- for(i=1; i<argc; i++) /* for each drive requested, */
- doit(argv[i]); /* display the data */
-
- }
-
- /****************************************************************************/
- /* */
- /* Display the bpb for a specific drive. */
- /* Display the RAM address only if drive is M. */
- /* */
- /****************************************************************************/
-
- doit(drive)
- char drive[];
- {
-
- register int c;
- register struct bpb *bpb_at;
-
- c = drive[0]; /* get the drive letter */
-
- if( isupper(c) ) /* insure lower case */
- c = tolower(c);
-
- bpb_at = (struct bpb *)Getbpb(c - 'a'); /* now get the BPB address */
-
- printf("\nDrive: %c BPB address: %8X\n",c,bpb_at);
- printf("\t\tBytes per sector: %5d\n",bpb_at->byt_sect);
- printf("\t\tSectors per cluster: %5d\n",bpb_at->sec_clust);
- printf("\t\tBytes per cluster: %5d\n",bpb_at->byt_clust);
- printf("\t\tDirectory sectors: %5d\n",bpb_at->dir_len);
- printf("\t\tFAT sectors: %5d\n",bpb_at->fat_size);
- printf("\t\tSecond FAT start sector: %5d\n",bpb_at->fat2_start);
- printf("\t\tFirst data sector: %5d\n",bpb_at->clust_start);
- printf("\t\tNumber of clusters: %5d\n",bpb_at->clusters);
- printf("\t\tFlag word: %5x ",bpb_at->flags);
-
- if(bpb_at->flags & 1) /* if bit 0 is set, */
- printf("(16 bit FATs)\n"); /* the FATs are 16 bits. */
- else /* if it is zero, */
- printf("(12 bit FATs)\n"); /* they are 12 bits */
-
- if( c == 'm' ) /* if this the RAMdisk */
- {
- if(bpb_at->ram_magic == RMAGIC) /* if special RAMdisk, */
- printf("\t\tRAM data start: %8X\n",bpb_at->ram_start);
- } /* end buffer address display */
-
- printf("\n(Press any key.) "); /* prompt for a keypress */
- Crawcin(); /* then wait for one */
- printf("\n"); /* and be neat */
- }
-