From e5916e4b30bb009709fe2a3a6f63ac16e986de6f Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Wed, 10 Mar 2004 16:26:30 +0000 Subject: [PATCH] Back in the backed out block estimate patch. :) --- dump/traverse.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/dump/traverse.c b/dump/traverse.c index 5376ef0..b0a1f14 100644 --- a/dump/traverse.c +++ b/dump/traverse.c @@ -37,7 +37,7 @@ #ifndef lint static const char rcsid[] = - "$Id: traverse.c,v 1.59 2004/03/08 14:12:56 stelian Exp $"; + "$Id: traverse.c,v 1.60 2004/03/10 16:26:30 stelian Exp $"; #endif /* not lint */ #include @@ -202,17 +202,25 @@ blockest(struct dinode const *dp) * dump blocks (sizeest vs. blkest in the indirect block * calculation). */ - blkest = howmany((u_quad_t)dp->di_blocks * 512, TP_BSIZE); + blkest = howmany((u_quad_t)dp->di_blocks * 512, fs->blocksize) * (fs->blocksize / TP_BSIZE); i_size = dp->di_size + ((u_quad_t) dp->di_size_high << 32); - sizeest = howmany(i_size, TP_BSIZE); + sizeest = howmany(i_size, fs->blocksize) * (fs->blocksize / TP_BSIZE); if (blkest > sizeest) blkest = sizeest; #ifdef __linux__ + if ((dp->di_mode & IFMT) == IFDIR) { + /* + * for directories, assume only half of space is filled + * with entries. + */ + blkest = blkest / 2; + sizeest = sizeest / 2; + } if (i_size > (u_quad_t)fs->blocksize * NDADDR) { /* calculate the number of indirect blocks on the dump tape */ blkest += howmany(sizeest - NDADDR * fs->blocksize / TP_BSIZE, - NINDIR(sblock) * EXT2_FRAGS_PER_BLOCK(fs->super)); + TP_NINDIR); } #else if (i_size > sblock->fs_bsize * NDADDR) { -- 2.39.5