]> git.wh0rd.org - dump.git/commitdiff
Fixed dumping/restoring of files ending with holes.
authorStelian Pop <stelian@popies.net>
Wed, 11 Apr 2001 13:42:52 +0000 (13:42 +0000)
committerStelian Pop <stelian@popies.net>
Wed, 11 Apr 2001 13:42:52 +0000 (13:42 +0000)
CHANGES
dump/traverse.c
restore/tape.c

diff --git a/CHANGES b/CHANGES
index 06f3d98d2a3a9f7675e5c0c021ee468f3d9749a8..9eeb3694194f6ad7723e3dbaf697b75d170252f9 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,4 @@
-$Id: CHANGES,v 1.110 2001/04/10 13:42:21 stelian Exp $
+$Id: CHANGES,v 1.111 2001/04/11 13:42:52 stelian Exp $
 
 Changes between versions 0.4b21 and 0.4b22 (released ????????????????)
 ======================================================================
@@ -46,6 +46,10 @@ Changes between versions 0.4b21 and 0.4b22 (released ????????????????)
        in a single invocation of dump. Thanks to Uwe Gohlke 
        <uwe@ugsoft.de> for implementing this option.
 
+9.     Fixed the dumping and restoring of files with holes
+       (files ending with holes didn't get dumped or restored 
+       correctly).
+
 Changes between versions 0.4b20 and 0.4b21 (released January 13, 2001)
 ======================================================================
 
index 0ea5b96f7b355255844bc5f85672543ed2c25f15..e4cf7d383d924e6dfd45140e1eac77de9d174bdb 100644 (file)
@@ -41,7 +41,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: traverse.c,v 1.32 2001/04/10 13:42:22 stelian Exp $";
+       "$Id: traverse.c,v 1.33 2001/04/11 13:42:52 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
@@ -796,9 +796,10 @@ void
 dumpino(struct dinode *dp, dump_ino_t ino)
 {
        unsigned long cnt;
-       fsizeT size;
+       fsizeT size, remaining;
        char buf[TP_BSIZE];
        struct old_bsd_inode obi;
+       int i;
 #ifdef __linux__
        struct block_context bc;
 #else
@@ -915,6 +916,16 @@ dumpino(struct dinode *dp, dump_ino_t ino)
        bc.next_block = NDADDR;
 
        ext2fs_block_iterate2(fs, (ext2_ino_t)ino, 0, NULL, dumponeblock, (void *)&bc);
+       /* deal with holes at the end of the inode */
+       remaining = i_size - bc.next_block*sblock->fs_fsize;
+       if (remaining > 0) 
+               for (i = 0; i < howmany(remaining, sblock->fs_fsize); i++) {
+                       bc.buf[bc.cnt++] = 0;
+                       if (bc.cnt == bc.max) {
+                               blksout (bc.buf, bc.cnt, bc.ino);
+                               bc.cnt = 0;
+                       }
+               }
        if (bc.cnt > 0) {
                blksout (bc.buf, bc.cnt, bc.ino);
        }
index f434143116847216ceee0722e32be8921117cc86..914db5c343433c2a8ef6b01a7d1a3f7a4f194974 100644 (file)
@@ -46,7 +46,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: tape.c,v 1.32 2001/04/10 12:46:53 stelian Exp $";
+       "$Id: tape.c,v 1.33 2001/04/11 13:42:52 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
@@ -841,6 +841,11 @@ loop:
                (*fill)((char *)buf, (size_t)(curblk * TP_BSIZE) + size);
                last_write_was_hole = 0;
        }
+       if (size > 0) {
+               fprintf(stderr, "Missing blocks at the end of %s, assuming hole\n", curfile.name);
+               (*skip)(clearedbuf, size);
+               last_write_was_hole = 1;
+       }
        if (last_write_was_hole) {
                ftruncate(ofile, origsize);
        }