summary |
tags |
clone url |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
8672a1f)
to look at alternate badsector files
SCCS-vsn: usr.sbin/bad144/bad144.c 5.13
#endif not lint
#ifndef lint
#endif not lint
#ifndef lint
-static char sccsid[] = "@(#)bad144.c 5.12 (Berkeley) %G%";
+static char sccsid[] = "@(#)bad144.c 5.13 (Berkeley) %G%";
int fflag, add, copy, verbose, nflag;
int compare();
int dups;
int fflag, add, copy, verbose, nflag;
int compare();
int dups;
+int badfile = -1; /* copy of badsector table to use, -1 if any */
#define MAXSECSIZE 1024
struct dkbad curbad, oldbad;
#define DKBAD_MAGIC 0
#define MAXSECSIZE 1024
struct dkbad curbad, oldbad;
#define DKBAD_MAGIC 0
verbose++;
break;
default:
verbose++;
break;
default:
+ if (**argv >= '0' && **argv <= '4') {
+ badfile = **argv - '0';
+ break;
+ }
}
shift(f, nbad, nbad-new);
}
}
shift(f, nbad, nbad-new);
}
- for (i = 0; i < 10 && i < dp->d_nsectors; i += 2) {
+ if (badfile == -1)
+ i = 0;
+ else
+ i = badfile * 2;
+ for (; i < 10 && i < dp->d_nsectors; i += 2) {
if (lseek(f, dp->d_secsize * (size - dp->d_nsectors + i),
L_SET) < 0)
Perror("lseek");
if (lseek(f, dp->d_secsize * (size - dp->d_nsectors + i),
L_SET) < 0)
Perror("lseek");
+ if (badfile != -1)
+ break;
}
#ifdef vax
if (nflag == 0 && fflag)
}
#ifdef vax
if (nflag == 0 && fflag)
daddr_t sn;
char msg[80];
daddr_t sn;
char msg[80];
- for (i = 0; i < 10 && i < dp->d_nsectors; i += 2) {
+ if (badfile == -1)
+ i = 0;
+ else
+ i = badfile * 2;
+ for (; i < 10 && i < dp->d_nsectors; i += 2) {
sn = size - dp->d_nsectors + i;
if (lseek(f, sn * dp->d_secsize, L_SET) < 0)
Perror("lseek");
sn = size - dp->d_nsectors + i;
if (lseek(f, sn * dp->d_secsize, L_SET) < 0)
Perror("lseek");
}
(void)sprintf(msg, "bad144: read bad sector file at sn %d", sn);
perror(msg);
}
(void)sprintf(msg, "bad144: read bad sector file at sn %d", sn);
perror(msg);
+ if (badfile != -1)
+ break;
}
fprintf(stderr, "bad144: %s: can't read bad block info\n", name);
exit(1);
}
fprintf(stderr, "bad144: %s: can't read bad block info\n", name);
exit(1);
- if (lseek(f, dp->d_secsize * s1, L_SET) < 0)
- Perror("lseek");
- for (tries = 0; tries < RETRIES; tries++)
+ for (tries = 0; tries < RETRIES; tries++) {
+ if (lseek(f, dp->d_secsize * s1, L_SET) < 0)
+ Perror("lseek");
if ((n = read(f, buf, dp->d_secsize)) == dp->d_secsize)
break;
if ((n = read(f, buf, dp->d_secsize)) == dp->d_secsize)
break;
if (n != dp->d_secsize) {
fprintf(stderr, "bad144: can't read sector, %d: ", s1);
if (n < 0)
if (n != dp->d_secsize) {
fprintf(stderr, "bad144: can't read sector, %d: ", s1);
if (n < 0)