diff options
author | des <des@FreeBSD.org> | 2013-04-29 20:13:09 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2013-04-29 20:13:09 +0000 |
commit | a44b26897fe945895cdaceab1334e351f45d0901 (patch) | |
tree | 76cb8332af9430e1c1556bbc8a24c5168fc2de7f /sbin/fsck_ffs/pass5.c | |
parent | 6cfe294dedc835f600fbdf81a4eebbd6aafe7099 (diff) | |
download | FreeBSD-src-a44b26897fe945895cdaceab1334e351f45d0901.zip FreeBSD-src-a44b26897fe945895cdaceab1334e351f45d0901.tar.gz |
Add a -Z option which zeroes unused blocks. It can be combined with -E,
in which case unused blocks are first zeroed and then erased.
Reviewed by: mckusick
MFC after: 3 weeks
Diffstat (limited to 'sbin/fsck_ffs/pass5.c')
-rw-r--r-- | sbin/fsck_ffs/pass5.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/sbin/fsck_ffs/pass5.c b/sbin/fsck_ffs/pass5.c index 146acec..38068eb 100644 --- a/sbin/fsck_ffs/pass5.c +++ b/sbin/fsck_ffs/pass5.c @@ -252,7 +252,7 @@ pass5(void) frags = 0; for (j = 0; j < fs->fs_frag; j++) { if (testbmap(d + j)) { - if (Eflag && start != -1) { + if ((Eflag || Zflag) && start != -1) { clear_blocks(start, d + j - 1); start = -1; } @@ -274,7 +274,7 @@ pass5(void) ffs_fragacct(fs, blk, newcg->cg_frsum, 1); } } - if (Eflag && start != -1) + if ((Eflag || Zflag) && start != -1) clear_blocks(start, d - 1); if (fs->fs_contigsumsize > 0) { int32_t *sump = cg_clustersum(newcg); @@ -586,6 +586,10 @@ static void clear_blocks(ufs2_daddr_t start, ufs2_daddr_t end) if (debug) printf("Zero frags %jd to %jd\n", start, end); - blerase(fswritefd, fsbtodb(&sblock, start), - lfragtosize(&sblock, end - start + 1)); + if (Zflag) + blzero(fswritefd, fsbtodb(&sblock, start), + lfragtosize(&sblock, end - start + 1)); + if (Eflag) + blerase(fswritefd, fsbtodb(&sblock, start), + lfragtosize(&sblock, end - start + 1)); } |