Subject: badsect doesn't work (#148) Index: etc/badsect.c 2.11BSD Description: The badsect program was incapable of working due to an invalid parameter in the 'mknod' call. Repeat-By: Attempt to create a "placeholder" badblock file using 'badsect'. Fix: Thanks to Johnny Billquist for spotting this one (those RP07s sure are good at finding bugs in the system, aren't they?;-)). In addition to the 'mknod' fix i have added a sanity check on the sector number. The badsect program can only be used for sectors in the first 128mb because a u_short is all that is used in the mknod call. Apply the patch, recompile and install 'badsect'. ==========================cut here=============================== *** /usr/src/etc/badsect.c.old Sun Feb 15 21:20:39 1987 --- /usr/src/etc/badsect.c Tue Aug 10 19:44:51 1993 *************** *** 7,14 **** --- 7,19 ---- * are not part of the bad file for the pack (see bad144). For instance, * this program can be used if the driver for the file system in question * does not support bad block forwarding. + * + * Bugfix 930802 by Johnny Billquist + * Sanity check on sector number August 10,1993 by Steven Schultz */ + #include #include + #include long atol(); *************** *** 17,27 **** char **argv; { char nambuf[32]; int errs = 0; --argc, argv++; while (argc > 0) { ! if (mknod(*argv, 0, (u_short)(atol(*argv) / CLSIZE))) perror("mknod"), errs++; argc--, argv++; } --- 22,39 ---- char **argv; { char nambuf[32]; + long sector; int errs = 0; --argc, argv++; while (argc > 0) { ! sector = atol(*argv); ! if (sector <= 0 || sector > 131071L) { ! fprintf(stderr, "Sector %s <= 0 or > 131071\n", ! *argv); ! continue; ! } ! if (mknod(*argv, IFMT, (u_short)(sector / CLSIZE))) perror("mknod"), errs++; argc--, argv++; }