From: Stelian Pop Date: Thu, 1 Jul 2004 09:14:48 +0000 (+0000) Subject: Fixed an offset calculation leading to bread lseek errors. X-Git-Tag: release_0_4b38~16 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=e1e4be20b0192a2988eab70a31fb1428c4c81eec;p=dump.git Fixed an offset calculation leading to bread lseek errors. --- diff --git a/CHANGES b/CHANGES index cc9eb64..fdf96ee 100644 --- 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 ??????????????) ==================================================================== @@ -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. +4. Fixed some offset calculations in dump code which could + lead to "bread lseek errors" on large filesystems. Thanks + to Bruce Lowekamp for + reporting this bug and debugging the issue. + Changes between versions 0.4b35 and 0.4b36 (released April 21, 2004) ==================================================================== diff --git a/THANKS b/THANKS index 0869803..3e2854c 100644 --- 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. @@ -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 +Bruce Lowekamp lowekamp@users.sourceforge.net Greg Lutz greglutz@ix.netcom.com Eric Maisonobe virnet@nat.fr Kai Makisara Kai.Makisara@kolumbus.fi diff --git a/compat/include/bsdcompat.h b/compat/include/bsdcompat.h index 3e9895b..4b9b907 100644 --- a/compat/include/bsdcompat.h +++ b/compat/include/bsdcompat.h @@ -5,12 +5,13 @@ * Stelian Pop , 1999-2000 * Stelian Pop - Alcôve , 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 #include #include +#include #define __dead volatile #define UNUSED(x) x __attribute__ ((unused)) @@ -47,7 +48,7 @@ #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 @@ -117,8 +118,8 @@ struct dinode { __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; @@ -248,8 +249,8 @@ struct old_bsd_inode { 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; @@ -277,8 +278,8 @@ struct new_bsd_inode { 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; diff --git a/compat/include/protocols/dumprestore.h b/compat/include/protocols/dumprestore.h index 54bc190..fc43715 100644 --- a/compat/include/protocols/dumprestore.h +++ b/compat/include/protocols/dumprestore.h @@ -5,7 +5,7 @@ * Stelian Pop , 1999-2000 * Stelian Pop - Alcôve , 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 */ - 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 */ diff --git a/dump/dump.h b/dump/dump.h index 8960c88..fafd4c3 100644 --- a/dump/dump.h +++ b/dump/dump.h @@ -5,7 +5,7 @@ * Stelian Pop , 1999-2000 * Stelian Pop - Alcôve , 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 #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 */ /* @@ -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 */ -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)); @@ -169,7 +169,7 @@ void mkchecksum __P((union u_spcl *tmpspcl)); /* 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)); diff --git a/dump/tape.c b/dump/tape.c index bd1e2f9..d615960 100644 --- a/dump/tape.c +++ b/dump/tape.c @@ -37,7 +37,7 @@ #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 @@ -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 { - daddr_t dblk; + ext2_loff_t dblk; int count; }; int reqsiz; @@ -234,7 +234,7 @@ void 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; @@ -272,9 +272,10 @@ writerec(const void *dp, int isspcl) } 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; diff --git a/dump/traverse.c b/dump/traverse.c index b0a1f14..4104799 100644 --- a/dump/traverse.c +++ b/dump/traverse.c @@ -37,7 +37,7 @@ #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 @@ -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; - int i; + e2_blkcnt_t i; 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 -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); @@ -1325,14 +1325,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)) @@ -1378,8 +1378,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))