]> git.wh0rd.org - dump.git/commitdiff
Fixed an offset calculation leading to bread lseek errors.
authorStelian Pop <stelian@popies.net>
Thu, 1 Jul 2004 09:14:48 +0000 (09:14 +0000)
committerStelian Pop <stelian@popies.net>
Thu, 1 Jul 2004 09:14:48 +0000 (09:14 +0000)
CHANGES
THANKS
compat/include/bsdcompat.h
compat/include/protocols/dumprestore.h
dump/dump.h
dump/tape.c
dump/traverse.c

diff --git a/CHANGES b/CHANGES
index cc9eb64eb7eb06e3cde0f0033f1c16ae2884cf4f..fdf96eed745fa86eedb62b29d4fcb85df8b143de 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,4 @@
-$Id: CHANGES,v 1.250 2004/06/17 09:01:13 stelian Exp $
+$Id: CHANGES,v 1.251 2004/07/01 09:14:48 stelian Exp $
 
 Changes between versions 0.4b36 and 0.4b37 (released ??????????????)
 ====================================================================
 
 Changes between versions 0.4b36 and 0.4b37 (released ??????????????)
 ====================================================================
@@ -21,6 +21,11 @@ Changes between versions 0.4b36 and 0.4b37 (released ??????????????)
        preventing dump from crashing when the dumpdates file has
        been modified by hand.
 
        preventing dump from crashing when the dumpdates file has
        been modified by hand.
 
+4.     Fixed some offset calculations in dump code which could 
+       lead to "bread lseek errors" on large filesystems. Thanks
+       to Bruce Lowekamp <lowekamp@users.sourceforge.net> for
+       reporting this bug and debugging the issue.
+
 Changes between versions 0.4b35 and 0.4b36 (released April 21, 2004)
 ====================================================================
 
 Changes between versions 0.4b35 and 0.4b36 (released April 21, 2004)
 ====================================================================
 
diff --git a/THANKS b/THANKS
index 0869803a4a43b5e341373671bd514c5db3bde522..3e2854cf7845c16b29a100d0a024e25eb67b7036 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -1,4 +1,4 @@
-$Id: THANKS,v 1.84 2004/03/29 13:57:28 stelian Exp $
+$Id: THANKS,v 1.85 2004/07/01 09:14:48 stelian Exp $
 
 Dump and restore were written by the people of the CSRG at the University
 of California, Berkeley.
 
 Dump and restore were written by the people of the CSRG at the University
 of California, Berkeley.
@@ -77,6 +77,7 @@ Kari Lempiainen               kari@funky.pp.fi
 Ambrose Li             acli@mingpaoxpress.com
 Georg Lippold          g_lippold@sourceforge.net
 Patrick J. LoPresti    patl@cag.lcs.mit.edu
 Ambrose Li             acli@mingpaoxpress.com
 Georg Lippold          g_lippold@sourceforge.net
 Patrick J. LoPresti    patl@cag.lcs.mit.edu
+Bruce Lowekamp         lowekamp@users.sourceforge.net
 Greg Lutz              greglutz@ix.netcom.com
 Eric Maisonobe         virnet@nat.fr
 Kai Makisara           Kai.Makisara@kolumbus.fi
 Greg Lutz              greglutz@ix.netcom.com
 Eric Maisonobe         virnet@nat.fr
 Kai Makisara           Kai.Makisara@kolumbus.fi
index 3e9895b57c65a15eb44e818e7b21f83bf687fc88..4b9b9077ac6edacbf38a9e27e2f793a5122a9b52 100644 (file)
@@ -5,12 +5,13 @@
  *     Stelian Pop <stelian@popies.net>, 1999-2000
  *     Stelian Pop <stelian@popies.net> - Alcôve <www.alcove.com>, 2000-2002
  *
  *     Stelian Pop <stelian@popies.net>, 1999-2000
  *     Stelian Pop <stelian@popies.net> - Alcôve <www.alcove.com>, 2000-2002
  *
- *     $Id: bsdcompat.h,v 1.22 2004/01/27 10:15:37 stelian Exp $
+ *     $Id: bsdcompat.h,v 1.23 2004/07/01 09:14:48 stelian Exp $
  */
 
 #include <config.h>
 #include <sys/time.h>
 #include <dirent.h>
  */
 
 #include <config.h>
 #include <sys/time.h>
 #include <dirent.h>
+#include <ext2fs/ext2fs.h>
 
 #define        __dead          volatile
 #define UNUSED(x)      x __attribute__ ((unused))
 
 #define        __dead          volatile
 #define UNUSED(x)      x __attribute__ ((unused))
@@ -47,7 +48,7 @@
 #define powerof2(x)    ((((x)-1)&(x))==0)
 #endif
 
 #define powerof2(x)    ((((x)-1)&(x))==0)
 #endif
 
-#define fsbtodb(sb,b)  ((int)(((long long)(b) * EXT2_BLOCK_SIZE((sb)->super)) / DEV_BSIZE))
+#define fsbtodb(sb,b)  ((ext2_loff_t)(((long long)(b) * EXT2_BLOCK_SIZE((sb)->super)) / DEV_BSIZE))
 #define dbtofsb(sb,b)  ((int)(((long long)(b) * DEV_BSIZE) / EXT2_BLOCK_SIZE((sb)->super)))
 
 #define        sblock          fs
 #define dbtofsb(sb,b)  ((int)(((long long)(b) * DEV_BSIZE) / EXT2_BLOCK_SIZE((sb)->super)))
 
 #define        sblock          fs
@@ -117,8 +118,8 @@ struct dinode {
        __u32   di_blocks;
        __u32   di_flags;
        __u32   di_reserved1;
        __u32   di_blocks;
        __u32   di_flags;
        __u32   di_reserved1;
-       daddr_t di_db[NDADDR];
-       daddr_t di_ib[NIADDR];
+       __u32   di_db[NDADDR];
+       __u32   di_ib[NIADDR];
        __u32   di_gen;
        __u32   di_file_acl;
        __u32   di_dir_acl;
        __u32   di_gen;
        __u32   di_file_acl;
        __u32   di_dir_acl;
@@ -248,8 +249,8 @@ struct old_bsd_inode {
                char    di_usymlink[MAXFASTLINK + 1];
        }               di_un;
 #else
                char    di_usymlink[MAXFASTLINK + 1];
        }               di_un;
 #else
-       daddr_t         di_db[NDADDR];
-       daddr_t         di_ib[NIADDR];
+       __u32           di_db[NDADDR];
+       __u32           di_ib[NIADDR];
 #endif
        __s32           di_flags;
        __s32           di_blocks;
 #endif
        __s32           di_flags;
        __s32           di_blocks;
@@ -277,8 +278,8 @@ struct new_bsd_inode {
        struct bsdtimeval       di_atime;
        struct bsdtimeval       di_mtime;
        struct bsdtimeval       di_ctime;
        struct bsdtimeval       di_atime;
        struct bsdtimeval       di_mtime;
        struct bsdtimeval       di_ctime;
-       daddr_t         di_db[NDADDR];
-       daddr_t         di_ib[NIADDR];
+       __u32           di_db[NDADDR];
+       __u32           di_ib[NIADDR];
        __u32           di_flags;
        __s32           di_blocks;
        __s32           di_gen;
        __u32           di_flags;
        __s32           di_blocks;
        __s32           di_gen;
index 54bc19071de249d14b3b3badcab05db33d68eb19..fc437159619b7ef60349b0a8be15e3d80ebb5a97 100644 (file)
@@ -5,7 +5,7 @@
  *     Stelian Pop <stelian@popies.net>, 1999-2000
  *     Stelian Pop <stelian@popies.net> - Alcôve <www.alcove.com>, 2000-2002
  *
  *     Stelian Pop <stelian@popies.net>, 1999-2000
  *     Stelian Pop <stelian@popies.net> - Alcôve <www.alcove.com>, 2000-2002
  *
- *     $Id: dumprestore.h,v 1.21 2004/04/13 13:03:55 stelian Exp $
+ *     $Id: dumprestore.h,v 1.22 2004/07/01 09:14:49 stelian Exp $
  */
 
 /*
  */
 
 /*
@@ -92,7 +92,7 @@ union u_spcl {
                int32_t c_date;             /* date of this dump */
                int32_t c_ddate;            /* date of previous dump */
                int32_t c_volume;           /* dump volume number */
                int32_t c_date;             /* date of this dump */
                int32_t c_ddate;            /* date of previous dump */
                int32_t c_volume;           /* dump volume number */
-               daddr_t c_tapea;            /* logical block of this record */
+               u_int32_t c_tapea;          /* logical block of this record */
                dump_ino_t c_inumber;       /* number of inode */
                int32_t c_magic;            /* magic number (see above) */
                int32_t c_checksum;         /* record checksum */
                dump_ino_t c_inumber;       /* number of inode */
                int32_t c_magic;            /* magic number (see above) */
                int32_t c_checksum;         /* record checksum */
index 8960c88e7a8f0b29801898fbf451cbe3ee3d119d..fafd4c399552a859ce519fe139727d082b33849d 100644 (file)
@@ -5,7 +5,7 @@
  *     Stelian Pop <stelian@popies.net>, 1999-2000
  *     Stelian Pop <stelian@popies.net> - Alcôve <www.alcove.com>, 2000-2002
  *
  *     Stelian Pop <stelian@popies.net>, 1999-2000
  *     Stelian Pop <stelian@popies.net> - Alcôve <www.alcove.com>, 2000-2002
  *
- *     $Id: dump.h,v 1.48 2004/04/21 08:55:51 stelian Exp $
+ *     $Id: dump.h,v 1.49 2004/07/01 09:14:49 stelian Exp $
  */
 
 /*-
  */
 
 /*-
@@ -42,7 +42,7 @@
 #include <compatlfs.h>
 
 #define MAXINOPB       (MAXBSIZE / sizeof(struct dinode))
 #include <compatlfs.h>
 
 #define MAXINOPB       (MAXBSIZE / sizeof(struct dinode))
-#define MAXNINDIR      (MAXBSIZE / sizeof(daddr_t))
+#define MAXNINDIR      (MAXBSIZE / sizeof(blk_t))
 #define NUM_STR_SIZE   32      /* a generic number buffer size */
 
 /*
 #define NUM_STR_SIZE   32      /* a generic number buffer size */
 
 /*
@@ -156,8 +156,8 @@ int maponefile __P((dump_ino_t maxino, long *tapesize, char *directory));
 int    mapdirs __P((dump_ino_t maxino, long *tapesize));
 
 /* file dumping routines */
 int    mapdirs __P((dump_ino_t maxino, long *tapesize));
 
 /* file dumping routines */
-void   blksout __P((daddr_t *blkp, int frags, dump_ino_t ino));
-void   bread __P((daddr_t blkno, char *buf, int size));
+void   blksout __P((blk_t *blkp, int frags, dump_ino_t ino));
+void   bread __P((ext2_loff_t blkno, char *buf, int size));
 void   dumpino __P((struct dinode *dp, dump_ino_t ino, int metaonly));
 #ifdef __linux__
 void   dumpdirino __P((struct dinode *dp, dump_ino_t ino));
 void   dumpino __P((struct dinode *dp, dump_ino_t ino, int metaonly));
 #ifdef __linux__
 void   dumpdirino __P((struct dinode *dp, dump_ino_t ino));
@@ -169,7 +169,7 @@ void        mkchecksum __P((union u_spcl *tmpspcl));
 /* tape writing routines */
 int    alloctape __P((void));
 void   close_rewind __P((void));
 /* tape writing routines */
 int    alloctape __P((void));
 void   close_rewind __P((void));
-void   dumpblock __P((daddr_t blkno, int size));
+void   dumpblock __P((blk_t blkno, int size));
 void   startnewtape __P((int top));
 time_t trewind __P((void));
 void   writerec __P((const void *dp, int isspcl));
 void   startnewtape __P((int top));
 time_t trewind __P((void));
 void   writerec __P((const void *dp, int isspcl));
index bd1e2f90c0bde55892a4e4365b1ad0dc1c230984..d615960b1dc05b3cedfde591d9ed50002e041dca 100644 (file)
@@ -37,7 +37,7 @@
 
 #ifndef lint
 static const char rcsid[] =
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: tape.c,v 1.84 2004/05/25 10:39:29 stelian Exp $";
+       "$Id: tape.c,v 1.85 2004/07/01 09:14:49 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
 #endif /* not lint */
 
 #include <config.h>
@@ -142,7 +142,7 @@ static int MkTapeString __P((struct s_spcl *, long long));
  * The following structure defines the instruction packets sent to slaves.
  */
 struct req {
  * The following structure defines the instruction packets sent to slaves.
  */
 struct req {
-       daddr_t dblk;
+       ext2_loff_t dblk;
        int count;
 };
 int reqsiz;
        int count;
 };
 int reqsiz;
@@ -234,7 +234,7 @@ void
 writerec(const void *dp, int isspcl)
 {
 
 writerec(const void *dp, int isspcl)
 {
 
-       slp->req[trecno].dblk = (daddr_t)0;
+       slp->req[trecno].dblk = (ext2_loff_t)0;
        slp->req[trecno].count = 1;
        /* XXX post increment triggers an egcs-1.1.2-12 bug on alpha/sparc */
        *(union u_spcl *)(*(nextblock)) = *(union u_spcl *)dp;
        slp->req[trecno].count = 1;
        /* XXX post increment triggers an egcs-1.1.2-12 bug on alpha/sparc */
        *(union u_spcl *)(*(nextblock)) = *(union u_spcl *)dp;
@@ -272,9 +272,10 @@ writerec(const void *dp, int isspcl)
 }
 
 void
 }
 
 void
-dumpblock(daddr_t blkno, int size)
+dumpblock(blk_t blkno, int size)
 {
 {
-       int avail, tpblks, dblkno;
+       int avail, tpblks;
+       ext2_loff_t dblkno;
 
        dblkno = fsbtodb(sblock, blkno);
        tpblks = size >> tp_bshift;
 
        dblkno = fsbtodb(sblock, blkno);
        tpblks = size >> tp_bshift;
index b0a1f145ddbb8f8e9323767fb0ec8101cfbd5b49..41047999c7d921c07237655e50db09f3840136b3 100644 (file)
@@ -37,7 +37,7 @@
 
 #ifndef lint
 static const char rcsid[] =
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: traverse.c,v 1.60 2004/03/10 16:26:30 stelian Exp $";
+       "$Id: traverse.c,v 1.61 2004/07/01 09:14:49 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
 #endif /* not lint */
 
 #include <config.h>
@@ -771,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;
             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;
 
        if (blockcnt < NDADDR)
                return 0;
@@ -1198,9 +1198,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
  * 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);
        int i, j, count, blks, tbperdb;
 
        blks = howmany(frags * sblock->fs_fsize, TP_BSIZE);
@@ -1325,14 +1325,14 @@ getino(dump_ino_t inum)
 int    breaderrors = 0;
 
 void
 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__
 {
        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))
 #else
        if (lseek(diskfd, ((off_t)blkno << dev_bshift), 0) !=
                                                ((off_t)blkno << dev_bshift))
@@ -1378,8 +1378,8 @@ loop:
        memset(buf, 0, size);
        for (i = 0; i < size; i += dev_bsize, buf += dev_bsize, blkno++) {
 #ifdef __linux__
        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))
 #else
                if (lseek(diskfd, ((off_t)blkno << dev_bshift), 0) !=
                                                ((off_t)blkno << dev_bshift))