diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 2001-03-02 08:33:56 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 2001-03-02 08:33:56 +0000 |
commit | bc52bf44002bec5b1b272f1bbf3c005758564872 (patch) | |
tree | a8239e28d96f263a75ab8a326f695ac8180e04b9 /sbin/fsck_ffs/pass5.c | |
parent | 6af6b3b76f04d736f591134b4842c45f7f3d1656 (diff) |
Make fsck aware of soft updates.
We had this in the tree 1997, but it went away because it was too close to
release.
Ok: csapuntz@
(as a size note: It's really good to test fsck when you are torture testing
the filesystems)
Diffstat (limited to 'sbin/fsck_ffs/pass5.c')
-rw-r--r-- | sbin/fsck_ffs/pass5.c | 66 |
1 files changed, 49 insertions, 17 deletions
diff --git a/sbin/fsck_ffs/pass5.c b/sbin/fsck_ffs/pass5.c index 08b510c2d6b..7ddd982f018 100644 --- a/sbin/fsck_ffs/pass5.c +++ b/sbin/fsck_ffs/pass5.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass5.c,v 1.7 1999/03/01 07:45:18 d Exp $ */ +/* $OpenBSD: pass5.c,v 1.8 2001/03/02 08:33:55 art Exp $ */ /* $NetBSD: pass5.c,v 1.16 1996/09/27 22:45:18 christos Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)pass5.c 8.6 (Berkeley) 11/30/94"; #else -static char rcsid[] = "$OpenBSD: pass5.c,v 1.7 1999/03/01 07:45:18 d Exp $"; +static char rcsid[] = "$OpenBSD: pass5.c,v 1.8 2001/03/02 08:33:55 art Exp $"; #endif #endif /* not lint */ @@ -68,11 +68,12 @@ void pass5() { int c, blk, frags, basesize, sumsize, mapsize, savednrpos=0; + int inomapsize, blkmapsize; register struct fs *fs = &sblock; register struct cg *cg = &cgrp; daddr_t dbase, dmax; - register daddr_t d; - register long i, j; + daddr_t d; + long i, j, k; struct csum *cs; struct csum cstotal; struct inodesc idesc[3]; @@ -130,6 +131,8 @@ pass5() sumsize = &ocg->cg_iused[0] - (u_int8_t *)(&ocg->cg_btot[0]); mapsize = &ocg->cg_free[howmany(fs->fs_fpg, NBBY)] - (u_char *)&ocg->cg_iused[0]; + blkmapsize = howmany(fs->fs_fpg, NBBY); + inomapsize = &ocg->cg_magic - (u_char *)&ocg->cg_iused[0]; ocg->cg_magic = CG_MAGIC; savednrpos = fs->fs_nrpos; fs->fs_nrpos = 8; @@ -144,12 +147,12 @@ pass5() fs->fs_cpg * fs->fs_nrpos * sizeof(int16_t); newcg->cg_freeoff = newcg->cg_iusedoff + howmany(fs->fs_ipg, NBBY); - if (fs->fs_contigsumsize <= 0) { - newcg->cg_nextfreeoff = newcg->cg_freeoff + - howmany(fs->fs_cpg * fs->fs_spc / NSPF(fs), NBBY); - } else { - newcg->cg_clustersumoff = newcg->cg_freeoff + - howmany(fs->fs_cpg * fs->fs_spc / NSPF(fs), NBBY) - + inomapsize = newcg->cg_freeoff - newcg->cg_iusedoff; + newcg->cg_nextfreeoff = newcg->cg_freeoff + + howmany(fs->fs_cpg * fs->fs_spc / NSPF(fs), NBBY); + blkmapsize = newcg->cg_nextfreeoff - newcg->cg_freeoff; + if (fs->fs_contigsumsize > 0) { + newcg->cg_clustersumoff = newcg->cg_nextfreeoff - sizeof(int32_t); newcg->cg_clustersumoff = roundup(newcg->cg_clustersumoff, sizeof(int32_t)); @@ -166,6 +169,7 @@ pass5() break; default: + inomapsize = blkmapsize = sumsize = 0; errexit("UNKNOWN ROTATIONAL TABLE FORMAT %d\n", fs->fs_postblformat); } @@ -320,13 +324,6 @@ pass5() cgdirty(); continue; } - if (memcmp(cg_inosused(newcg), - cg_inosused(cg), mapsize) != 0 && - dofix(&idesc[1], "BLK(S) MISSING IN BIT MAPS")) { - memcpy(cg_inosused(cg), cg_inosused(newcg), - (size_t)mapsize); - cgdirty(); - } if ((memcmp(newcg, cg, basesize) != 0 || memcmp(&cg_blktot(newcg)[0], &cg_blktot(cg)[0], sumsize) != 0) && @@ -336,6 +333,41 @@ pass5() &cg_blktot(newcg)[0], (size_t)sumsize); cgdirty(); } + if (usedsoftdep) { + for (i = 0; i < inomapsize; i++) { + j = cg_inosused(newcg)[i]; + if ((cg_inosused(cg)[i] & j) == j) + continue; + for (k = 0; k < NBBY; k++) { + if ((j & (1 << k)) == 0) + continue; + if (cg_inosused(cg)[i] & (1 << k)) + continue; + pwarn("ALLOCATED INODE %d MARKED FREE", + c * fs->fs_ipg + i * 8 + k); + } + } + for (i = 0; i < blkmapsize; i++) { + j = cg_blksfree(cg)[i]; + if ((cg_blksfree(newcg)[i] & j) == j) + continue; + for (k = 0; k < NBBY; k++) { + if ((j & (1 << k)) == 0) + continue; + if (cg_inosused(cg)[i] & (1 << k)) + continue; + pwarn("ALLOCATED FRAG %d MARKED FREE", + c * fs->fs_fpg + i * 8 + k); + } + } + } + if (memcmp(cg_inosused(newcg), cg_inosused(cg), + mapsize) != 0 && + dofix(&idesc[1], "BLK(S) MISSING IN BIT MAPS")) { + memmove(cg_inosused(cg), cg_inosused(newcg), + (size_t)mapsize); + cgdirty(); + } } info_fn = NULL; if (fs->fs_postblformat == FS_42POSTBLFMT) |