From 8eb05297aafdfd88bbd946a35d4db771604503bd Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Thu, 10 Feb 2000 09:42:32 +0000 Subject: [PATCH] Compatibility between dumps made on little endian machines vs. big endian machines (the last one was incorrect). Fixed the way dump reports the remaining percent/time, if the number of blocks actually dumped exceeds the estimated number of blocks. --- CHANGES | 18 +++++++++++++++++- THANKS | 3 ++- compat/include/bsdcompat.h | 28 ++++++++++++++++++++-------- dump/optr.c | 4 +++- dump/tape.c | 4 +++- dump/traverse.c | 9 ++++----- restore/dirs.c | 14 +------------- 7 files changed, 50 insertions(+), 30 deletions(-) diff --git a/CHANGES b/CHANGES index 5f45d06..07cd7db 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,4 @@ -$Id: CHANGES,v 1.41 2000/02/08 12:22:42 stelian Exp $ +$Id: CHANGES,v 1.42 2000/02/10 09:42:32 stelian Exp $ Changes between versions 0.4b13 and 0.4b14 (released ????????????????) ====================================================================== @@ -28,6 +28,22 @@ Changes between versions 0.4b13 and 0.4b14 (released ????????????????) having the immutable or append-only attribute set. Thanks to Ambrose Li for submitting the patch. +7. Fixed a compatibility problem between dumps made on little + endian machines (the format was correct) and big endian + machines (the format was incorrect). This fix break the + compatibility with the older dumps made on big endian + machines (sparc, m86k, ppc etc). For the first time in + linux dump's history (I believe), the dumps made by *BSD, + Linux/alpha, Linux/sparc and Linux/x86 are compatible, + so interchangeable. Thanks to Rob Cermak + for submitting the bug and + helping me test the fix. + +8. Fixed the way dump reports the remaining percent/time, if + the number of blocks actually dumped exceeds the estimated + number of blocks. Thanks to Jean-Paul van der Jagt + for reporting the bug. + Changes between versions 0.4b12 and 0.4b13 (released January 21, 2000) ====================================================================== diff --git a/THANKS b/THANKS index 42b5f85..7c464d5 100644 --- a/THANKS +++ b/THANKS @@ -1,4 +1,4 @@ -$Id: THANKS,v 1.20 2000/02/08 12:35:07 stelian Exp $ +$Id: THANKS,v 1.21 2000/02/10 09:42:32 stelian Exp $ Dump and restore were written by the people of the CSRG at the University of California, Berkeley. @@ -30,6 +30,7 @@ Abhijit Dasgupta abhijit@ans.net Jason Fearon jasonf@netrider.org.au Jeremy Fitzhardinge jeremy@goop.org Eirik Fuller eirik@netcom.com +Jean-Paul van der Jagt jeanpaul@dutepp0.et.tudelft.nl Eric Jergensen eric@dvns.com Henry Katz hkatz@hkatz.dialup.access.net Klaus Kudielka kkudielk@cacofonix.nt.tuwien.ac.at diff --git a/compat/include/bsdcompat.h b/compat/include/bsdcompat.h index 8aad397..bb39fe8 100644 --- a/compat/include/bsdcompat.h +++ b/compat/include/bsdcompat.h @@ -4,7 +4,7 @@ * Remy Card , 1994-1997 * Stelian Pop , 1999-2000 * - * $Id: bsdcompat.h,v 1.9 2000/01/21 10:17:41 stelian Exp $ + * $Id: bsdcompat.h,v 1.10 2000/02/10 09:42:32 stelian Exp $ */ #include @@ -131,18 +131,30 @@ struct dinode { #define d_fileno d_ino #endif -struct direct { +/* + * This is the direct structure used by dump. In needs to be + * different from direct because linux dump generates only + * 'old inode format' dumps. And BSD supposes that the old + * inode dumps have the d_namelen field written in machine byte + * order... + */ +struct olddirect { __u32 d_ino; __u16 d_reclen; -#if 1 - __u8 d_namlen; - __u8 d_type; -#else __u16 d_namlen; -#endif - char d_name[MAXNAMLEN + 1]; + char d_name[MAXNAMLEN + 1]; }; +/* + * The direct structure used by restore. + */ +struct direct { + __u32 d_ino; + __u16 d_reclen; + __u8 d_type; + __u8 d_namlen; + char d_name[MAXNAMLEN + 1]; +}; /* * Convert between stat structure types and directory types. */ diff --git a/dump/optr.c b/dump/optr.c index fdda1c4..de1d6f6 100644 --- a/dump/optr.c +++ b/dump/optr.c @@ -40,7 +40,7 @@ #ifndef lint static const char rcsid[] = - "$Id: optr.c,v 1.9 2000/01/26 11:38:08 stelian Exp $"; + "$Id: optr.c,v 1.10 2000/02/10 09:42:32 stelian Exp $"; #endif /* not lint */ #include @@ -328,6 +328,8 @@ timeest(void) tschedule = tnow + 300; if (blockswritten < 500) return; + if (blockswritten > tapesize) + tapesize = blockswritten; deltat = tstart_writing - tnow + (1.0 * (tnow - tstart_writing)) / blockswritten * tapesize; diff --git a/dump/tape.c b/dump/tape.c index 40dd427..b3964a8 100644 --- a/dump/tape.c +++ b/dump/tape.c @@ -40,7 +40,7 @@ #ifndef lint static const char rcsid[] = - "$Id: tape.c,v 1.11 2000/01/21 10:17:41 stelian Exp $"; + "$Id: tape.c,v 1.12 2000/02/10 09:42:32 stelian Exp $"; #endif /* not lint */ #ifdef __linux__ @@ -311,6 +311,8 @@ statussig(int notused) #else (void) time((time_t *) &tnow); #endif + if (blockswritten > tapesize) + tapesize = blockswritten; deltat = tstart_writing - tnow + (1.0 * (tnow - tstart_writing)) / blockswritten * tapesize; (void)snprintf(msgbuf, sizeof(msgbuf), diff --git a/dump/traverse.c b/dump/traverse.c index ed52904..204f518 100644 --- a/dump/traverse.c +++ b/dump/traverse.c @@ -40,7 +40,7 @@ #ifndef lint static const char rcsid[] = - "$Id: traverse.c,v 1.15 2000/02/04 20:22:21 stelian Exp $"; + "$Id: traverse.c,v 1.16 2000/02/10 09:42:32 stelian Exp $"; #endif /* not lint */ #include @@ -803,22 +803,21 @@ static int convert_dir(struct ext2_dir_entry *dirent, int offset, int blocksize, char *buf, void *private) { struct convert_dir_context *p; - struct direct *dp; + struct olddirect *dp; int reclen; p = (struct convert_dir_context *)private; reclen = EXT2_DIR_REC_LEN((dirent->name_len & 0xFF) + 1); if (((p->offset + reclen - 1) / p->bs) != (p->offset / p->bs)) { - dp = (struct direct *)(p->buf + p->prev_offset); + dp = (struct olddirect *)(p->buf + p->prev_offset); dp->d_reclen += p->bs - (p->offset % p->bs); p->offset += p->bs - (p->offset % p->bs); } - dp = (struct direct *)(p->buf + p->offset); + dp = (struct olddirect *)(p->buf + p->offset); dp->d_ino = dirent->inode; dp->d_reclen = reclen; - dp->d_type = 0; dp->d_namlen = dirent->name_len & 0xFF; strncpy(dp->d_name, dirent->name, dp->d_namlen); dp->d_name[dp->d_namlen] = '\0'; diff --git a/restore/dirs.c b/restore/dirs.c index 777a6a6..558b2b6 100644 --- a/restore/dirs.c +++ b/restore/dirs.c @@ -45,7 +45,7 @@ #ifndef lint static const char rcsid[] = - "$Id: dirs.c,v 1.7 2000/01/21 10:17:41 stelian Exp $"; + "$Id: dirs.c,v 1.8 2000/02/10 09:42:32 stelian Exp $"; #endif /* not lint */ #include @@ -379,10 +379,6 @@ putdir(char *buf, size_t size) if (Bcvt) swabst((u_char *)"is", (u_char *) dp); if (oldinofmt && dp->d_ino != 0) { -#ifdef __linux__ - if (Bcvt) - swabst((u_char *)"s", (u_char *)&dp->d_namlen); -#else # if BYTE_ORDER == BIG_ENDIAN if (Bcvt) dp->d_namlen = dp->d_type; @@ -390,16 +386,8 @@ putdir(char *buf, size_t size) if (!Bcvt) dp->d_namlen = dp->d_type; # endif -#endif /* __linux__ */ dp->d_type = DT_UNKNOWN; } -#ifdef __linux__ - /* - * Horrible hack to read FreeBSD 2.0 dumps - */ - if (!oldinofmt) - swabst((u_char *)"6bs", (u_char *) dp); -#endif /* __linux__ */ #ifdef DIRDEBUG printf ("reclen = %d, namlen = %d, type = %d\n", dp->d_reclen, dp->d_namlen, dp->d_type); -- 2.39.5