home *** CD-ROM | disk | FTP | other *** search
- /* UnNonDos v 1.0
-
- Program to patch the first byte of the FAT to F8 to get rid of
- "Probable NON-DOS disk" problems with CHKDSK
- 01/28/90 by Ward Christensen CIS # 76703,302
- The Ward Board BBS # (708) 849-1132
- world's first BBS # (312) 545-8086
-
- use: unnondos drive:
- ex: unnondos c:
-
- Compiled with Borland Turbo C 2.0
-
- Written as a simple response to the many many recent msgs on Compuserve
- from people saying
-
- What do I do now: chkdsk says "probable NON-DOS disk"?
-
- */
-
- #define vers "1.0"
-
- #include <stdio.h>
- #include <dos.h>
- #include <ctype.h>
- #include <errno.h>
-
- unsigned char buffer[512];
- int drive,i,rc;
- char drivechar,answer[80];
-
- how()
- { puts("\nSyntax:");
- puts("\tUnNonDOS drive:");
- puts("\n\tEx: unnondos c:");
- }
-
- dump()
- { putchar('\t');
- for (i=0;i<20;++i)
- printf("%02X ",buffer[i]);
- puts(" ");
- }
-
-
- int main(int argc, char *argv[])
- {
- printf("\nUN-NON-DOS (unnondos) Version %s, by Ward Christensen\n",
- vers);
- puts("\nEnsures that a hard disk has an F8 in byte 0 of the first FAT.");
- puts("\tand that bytes 1-2 are FF.");
- puts("\nUsed when CHKDSK reports ""Probable Non-DOS disk"".");
- if (argc != 2)
- { how();
- exit(1);
- }
- if (argv[1][1] != ':')
- { how();
- exit(1);
- }
- drivechar = argv[1][0];
- if (islower(drivechar))
- drivechar = toupper(drivechar);
- if (drivechar >= 'A' && drivechar <= 'B')
- puts("\n*** Not designed to work on diskettes - they don't use F8.");
-
- if (drivechar < 'C')
- { how();
- exit(1);
- }
- if (drivechar > 'Z')
- { how();
- exit(1);
- }
- drive = drivechar-'A';
- /* drive, # sectors, start sec */
- rc = absread(drive, 1, 1, buffer);
- if (rc != 0)
- { perror("*** Unable to read Fat 1 sector");
- exit(1);
-
- }
- puts("\nYour current FAT starts out:");
- dump();
- if ((int) buffer[0] == 0x00F8)
- { puts("\n*** FAT byte 00 is already an F8. No action taken.");
- exit(0);
- }
- buffer[0] = '\xF8'; /* Patch in correct values */
- buffer[1] = '\xFF';
- buffer[2] = '\xFF';
-
- puts("\nAfter patching, your buffer looks like this:");
- dump();
-
- printf("\nDo you want to write the patched value back to disk? ");
- gets(answer);
- if (islower(answer[0]))
- answer[0] = toupper(answer[0]);
- if (answer[0] == 'Y')
- { printf("writing...");
- rc = abswrite(drive, 1, 1, buffer);
- if (rc != 0)
- { perror("*** Error writing back sector");
- exit(1);
- }
- }
- puts("Done");
- }
-