Skip to content

Commit 23c8b19

Browse files
Kirk McKusickKirk McKusick
authored andcommitted
Drop checks with last alternate superblock in fsck_ffs(8).
The fsck_ffs(8) utility made sanity checks of critical superblock fields by comparing the values of those fields in the standard superblock againt the values of those fields in the last alternate superblock. The code for validating a superblock now cover all the checked fields as well as many more. Further the checks done are far more comprehensive. So we now drop the alternate superblock checks as they no longer provide value. Dropping these checks also eliminates the need to read the alternate superblock.
1 parent 5b5fa75 commit 23c8b19

File tree

1 file changed

+2
-62
lines changed

1 file changed

+2
-62
lines changed

sbin/fsck_ffs/setup.c

Lines changed: 2 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ __FBSDID("$FreeBSD$");
6060

6161
struct inoinfo **inphead, **inpsort; /* info about all inodes */
6262

63-
struct bufarea asblk;
64-
#define altsblock (*asblk.b_un.b_fs)
6563
#define POWEROF2(num) (((num) & ((num) - 1)) == 0)
6664

6765
static int calcsb(char *dev, int devfd, struct fs *fs);
@@ -163,10 +161,6 @@ setup(char *dev)
163161
pfatal("from before 2002 with the command ``fsck -c 2''\n");
164162
exit(EEXIT);
165163
}
166-
if ((asblk.b_flags & B_DIRTY) != 0 && !bflag) {
167-
memmove(&altsblock, &sblock, (size_t)sblock.fs_sbsize);
168-
flush(fswritefd, &asblk);
169-
}
170164
if (preen == 0 && yflag == 0 && sblock.fs_magic == FS_UFS2_MAGIC &&
171165
fswritefd != -1 && chkrecovery(fsreadfd) == 0 &&
172166
reply("SAVE DATA TO FIND ALTERNATE SUPERBLOCKS") != 0)
@@ -252,7 +246,7 @@ int
252246
readsb(int listerr)
253247
{
254248
off_t super;
255-
int bad, ret, flags;
249+
int ret, flags;
256250
struct fs *fs;
257251

258252
super = bflag ? bflag * dev_bsize : UFS_STDSB;
@@ -293,58 +287,6 @@ readsb(int listerr)
293287
dev_bsize = sblock.fs_fsize / fsbtodb(&sblock, 1);
294288
sblk.b_bno = sblock.fs_sblockactualloc / dev_bsize;
295289
sblk.b_size = SBLOCKSIZE;
296-
/*
297-
* Compare all fields that should not differ in alternate super block.
298-
* When an alternate super-block is specified this check is skipped.
299-
*/
300-
if (bflag)
301-
goto out;
302-
getblk(&asblk, cgsblock(&sblock, sblock.fs_ncg - 1), sblock.fs_sbsize);
303-
if (asblk.b_errs)
304-
return (0);
305-
bad = 0;
306-
#define CHK(x, y) \
307-
if (altsblock.x != sblock.x) { \
308-
bad++; \
309-
if (listerr && debug) \
310-
printf("SUPER BLOCK VS ALTERNATE MISMATCH %s: " y " vs " y "\n", \
311-
#x, (intmax_t)sblock.x, (intmax_t)altsblock.x); \
312-
}
313-
CHK(fs_sblkno, "%jd");
314-
CHK(fs_cblkno, "%jd");
315-
CHK(fs_iblkno, "%jd");
316-
CHK(fs_dblkno, "%jd");
317-
CHK(fs_ncg, "%jd");
318-
CHK(fs_bsize, "%jd");
319-
CHK(fs_fsize, "%jd");
320-
CHK(fs_frag, "%jd");
321-
CHK(fs_bmask, "%#jx");
322-
CHK(fs_fmask, "%#jx");
323-
CHK(fs_bshift, "%jd");
324-
CHK(fs_fshift, "%jd");
325-
CHK(fs_fragshift, "%jd");
326-
CHK(fs_fsbtodb, "%jd");
327-
CHK(fs_sbsize, "%jd");
328-
CHK(fs_nindir, "%jd");
329-
CHK(fs_inopb, "%jd");
330-
CHK(fs_cssize, "%jd");
331-
CHK(fs_ipg, "%jd");
332-
CHK(fs_fpg, "%jd");
333-
CHK(fs_magic, "%#jx");
334-
#undef CHK
335-
if (bad) {
336-
if (listerr == 0)
337-
return (0);
338-
if (preen)
339-
printf("%s: ", cdevname);
340-
printf(
341-
"VALUES IN SUPER BLOCK LSB=%jd DISAGREE WITH THOSE IN\n"
342-
"LAST ALTERNATE LSB=%jd\n",
343-
sblk.b_bno, asblk.b_bno);
344-
if (reply("IGNORE ALTERNATE SUPER BLOCK") == 0)
345-
return (0);
346-
}
347-
out:
348290
/*
349291
* If not yet done, update UFS1 superblock with new wider fields.
350292
*/
@@ -373,10 +315,8 @@ sblock_init(void)
373315
fsmodified = 0;
374316
lfdir = 0;
375317
initbarea(&sblk, BT_SUPERBLK);
376-
initbarea(&asblk, BT_SUPERBLK);
377318
sblk.b_un.b_buf = Malloc(SBLOCKSIZE);
378-
asblk.b_un.b_buf = Malloc(SBLOCKSIZE);
379-
if (sblk.b_un.b_buf == NULL || asblk.b_un.b_buf == NULL)
319+
if (sblk.b_un.b_buf == NULL)
380320
errx(EEXIT, "cannot allocate space for superblock");
381321
dev_bsize = secsize = DEV_BSIZE;
382322
}

0 commit comments

Comments
 (0)