/* Program to dump the FAT of an MS-DOS format disk * * Copyright (c) 1991 Shal Farley * Cheshire Engineering Corporation * 650 Sierra Madre Villa Avenue, Suite 201 * Pasadena, California 91107 * (818) 351-5493 * (818) 351-8645 FAX * shal@alumni.caltech.edu * * This software may be used and distributed for any purpose without license or * royalty payments so long as the above copyright notice is preserved. If you * have any comments, bug fixes, improvements, or new programs based upon this * software I'd like to hear from you. */ #include #include "msport.h" #include "msfio.h" #include "msdir.h" static USHORT UchFromPch(pch) /* Get unsigned char from (char *) */ char *pch; { return 0xFF & (USHORT)*pch; } static USHORT GetFE_0(pFE) /* Return least entry */ MSFE *pFE; { return( ((USHORT)pFE->b1<<8 ) + (UchFromPch(&pFE->b0)) & 0xFFF ); } static USHORT GetFE_1(pFE) /* Return higher entry */ MSFE *pFE; { return( ((USHORT)pFE->b2<<8) + (UchFromPch(&pFE->b1)) >> 4 & 0xFFF); } main(argc,argv) int argc; char * argv[]; { MSDEV *pd; /* Pointer to device struct */ int nClust; /* Number of useable clusters */ int i; /* loop counter */ if ( argc != 2) { fprintf(stderr, "Usage: MSFAT device-or-file-name"); exit(1); } if ( (pd = msdopen(argv[1])) == NULL) { msperror("?MSFAT-F"); exit(1); } if (pd->fRT11) { fprintf(stderr, "?MSFAT-F-Device has RT-11 directory\n"); exit(1); } if (!pd->fValid & !pd->fMaybe) { fprintf(stderr, "?MSFAT-I-Device is not MS-DOS format\n"); exit(1); } /* * Dump the FAT table */ nClust = pd->nsTotal -pd->nsBoot -(pd->nFATs*pd->nsFAT) -(pd->nDirEntries*sizeof(MSDE)/SECTOR); printf(" %d clusters available (0x002 .. 0x%03X)", nClust, nClust+1); /* * Perhaps this loop should insert page breaks? Nah... */ for (i = 0; i < nClust+2; i ++) { if ( (i & 0xF) == 0) printf("\n%03X/ ", i); printf(" %03X", msfeclust(i, pd)); } printf("\n"); exit(0); }