From: Stelian Pop Date: Wed, 11 Apr 2001 13:42:52 +0000 (+0000) Subject: Fixed dumping/restoring of files ending with holes. X-Git-Tag: release_0_4b22~15 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=cfa03414886424d1dcc4ca41210c26d54204c444;p=dump.git Fixed dumping/restoring of files ending with holes. --- diff --git a/CHANGES b/CHANGES index 06f3d98..9eeb369 100644 --- 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 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) ====================================================================== diff --git a/dump/traverse.c b/dump/traverse.c index 0ea5b96..e4cf7d3 100644 --- a/dump/traverse.c +++ b/dump/traverse.c @@ -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 @@ -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); } diff --git a/restore/tape.c b/restore/tape.c index f434143..914db5c 100644 --- a/restore/tape.c +++ b/restore/tape.c @@ -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 @@ -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); }