]> git.wh0rd.org - dump.git/blobdiff - dump/traverse.c
Exclude directory entries to non-dumped inodes from the dump.
[dump.git] / dump / traverse.c
index fb868dba4050aec08cc81ae8a961cc5eb6045f19..9e68fdd596fbb16df9b6952062f59ec250142cd6 100644 (file)
@@ -37,7 +37,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: traverse.c,v 1.57 2004/03/01 15:38:13 stelian Exp $";
+       "$Id: traverse.c,v 1.62 2004/11/22 10:22:43 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
@@ -208,6 +208,14 @@ blockest(struct dinode const *dp)
        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 +=
@@ -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,11 @@ 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)
+               return 0;
+
        p = (struct convert_dir_context *)private;
 
        reclen = EXT2_DIR_REC_LEN((dirent->name_len & 0xFF) + 1);
@@ -1190,9 +1203,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);
@@ -1317,14 +1330,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 +1383,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))