X-Git-Url: https://git.wh0rd.org/?p=dump.git;a=blobdiff_plain;f=dump%2Ftraverse.c;h=147df5b60e11486f3ce80a0f72fbe2aea274ec96;hp=2142abc0c274d5c481dee154556c7909c28fa1ef;hb=dba36a3e9b1fb9e7c207ab8b5f7cb7f502867780;hpb=d1925e0c515fcb4f815d75292566d600fd715ff5 diff --git a/dump/traverse.c b/dump/traverse.c index 2142abc..147df5b 100644 --- a/dump/traverse.c +++ b/dump/traverse.c @@ -37,7 +37,7 @@ #ifndef lint static const char rcsid[] = - "$Id: traverse.c,v 1.56 2003/10/26 16:05:47 stelian Exp $"; + "$Id: traverse.c,v 1.64 2004/12/15 09:31:49 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) { @@ -763,7 +771,7 @@ dumponeblock(UNUSED(ext2_filsys fs), blk_t *blocknr, e2_blkcnt_t blockcnt, UNUSED(blk_t ref_block), UNUSED(int ref_offset), void * private) { struct block_context *p; - int i; + e2_blkcnt_t i; if (blockcnt < NDADDR) return 0; @@ -977,6 +985,12 @@ convert_dir(struct ext2_dir_entry *dirent, UNUSED(int offset), struct direct *dp; int reclen; + /* do not save entries to excluded inodes */ + if (TSTINO(dirent->inode, dumpinomap) == 0 && + TSTINO(dirent->inode, dumpdirmap) == 0 && + TSTINO(dirent->inode, usedinomap) == 0) + return 0; + p = (struct convert_dir_context *)private; reclen = EXT2_DIR_REC_LEN((dirent->name_len & 0xFF) + 1); @@ -1190,9 +1204,9 @@ dmpindir(dump_ino_t ino, daddr_t blk, int ind_level, fsizeT *size) * Collect up the data into tape record sized buffers and output them. */ void -blksout(daddr_t *blkp, int frags, dump_ino_t ino) +blksout(blk_t *blkp, int frags, dump_ino_t ino) { - daddr_t *bp; + blk_t *bp; int i, j, count, blks, tbperdb; blks = howmany(frags * sblock->fs_fsize, TP_BSIZE); @@ -1233,6 +1247,7 @@ dumpmap(char *map, int type, dump_ino_t ino) spcl.c_type = type; spcl.c_count = howmany(mapsize * sizeof(char), TP_BSIZE); + spcl.c_dinode.di_size = mapsize; writeheader(ino); for (i = 0, cp = map; i < spcl.c_count; i++, cp += TP_BSIZE) writerec(cp, 0); @@ -1317,14 +1332,14 @@ getino(dump_ino_t inum) int breaderrors = 0; void -bread(daddr_t blkno, char *buf, int size) +bread(ext2_loff_t blkno, char *buf, int size) { int cnt, i; loop: #ifdef __linux__ - if (ext2fs_llseek(diskfd, (((ext2_loff_t)blkno) << dev_bshift), 0) != - (((ext2_loff_t)blkno) << dev_bshift)) + if (ext2fs_llseek(diskfd, (blkno << dev_bshift), 0) != + (blkno << dev_bshift)) #else if (lseek(diskfd, ((off_t)blkno << dev_bshift), 0) != ((off_t)blkno << dev_bshift)) @@ -1370,8 +1385,8 @@ loop: memset(buf, 0, size); for (i = 0; i < size; i += dev_bsize, buf += dev_bsize, blkno++) { #ifdef __linux__ - if (ext2fs_llseek(diskfd, (((ext2_loff_t)blkno) << dev_bshift), 0) != - (((ext2_loff_t)blkno) << dev_bshift)) + if (ext2fs_llseek(diskfd, (blkno << dev_bshift), 0) != + (blkno << dev_bshift)) #else if (lseek(diskfd, ((off_t)blkno << dev_bshift), 0) != ((off_t)blkno << dev_bshift))