From e531c44203905d5554118c09c8d0267f17879ee6 Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Fri, 15 Nov 2002 09:25:25 +0000 Subject: [PATCH] Fix maps overflow in restore when doing incremental restores (and MAXINO becomes bigger on later tapes). --- CHANGES | 8 +++++++- THANKS | 3 ++- restore/extern.h | 3 ++- restore/main.c | 6 +++--- restore/symtab.c | 3 ++- restore/tape.c | 10 ++-------- restore/utilities.c | 24 +++++++++++++++++++++++- 7 files changed, 41 insertions(+), 16 deletions(-) diff --git a/CHANGES b/CHANGES index e6dd0f7..7d5273e 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,4 @@ -$Id: CHANGES,v 1.196 2002/10/07 19:27:35 stelian Exp $ +$Id: CHANGES,v 1.197 2002/11/15 09:25:25 stelian Exp $ Changes between versions 0.4b31 and 0.4b32 (released ?????????????) =================================================================== @@ -29,6 +29,12 @@ Changes between versions 0.4b31 and 0.4b32 (released ?????????????) of whitespace. Thanks to Jeffrey Sofferin for reporting this bug. +6. Fixed a bug which caused restore, in some particular cases, + to ask some 'scary' questions and leave a bunch of RSTTMP + directories behind when restoring incremental tapes. Thanks + to Philippe Troin for reporting this bug and + providing the test cases. + Changes between versions 0.4b30 and 0.4b31 (released July 30, 2002) =================================================================== diff --git a/THANKS b/THANKS index 37aaaae..bd8df1e 100644 --- a/THANKS +++ b/THANKS @@ -1,4 +1,4 @@ -$Id: THANKS,v 1.68 2002/10/07 19:27:35 stelian Exp $ +$Id: THANKS,v 1.69 2002/11/15 09:25:28 stelian Exp $ Dump and restore were written by the people of the CSRG at the University of California, Berkeley. @@ -97,6 +97,7 @@ Jason L Tibbitts III tibbs@math.uh.edu Mike Tibor tibor@lib.uaa.alaska.edu Dirk Traenapp dtraenapp@users.sourceforge.net Erik Troan ewt@redhat.com +Philippe Troin phil@fifi.org Theodore Y. Ts'o tytso@valinux.com Stephen Tweedie sct@dcs.ed.ac.uk Amith Varghese amithv@yahoo.com diff --git a/restore/extern.h b/restore/extern.h index 62deb0d..6ea57e3 100644 --- a/restore/extern.h +++ b/restore/extern.h @@ -5,7 +5,7 @@ * Stelian Pop , 1999-2000 * Stelian Pop - AlcĂ´ve , 2000-2002 * - * $Id: extern.h,v 1.19 2002/07/29 12:00:34 stelian Exp $ + * $Id: extern.h,v 1.20 2002/11/15 09:25:41 stelian Exp $ */ /*- @@ -97,6 +97,7 @@ void removeoldleaves __P((void)); void removeoldnodes __P((void)); void renameit __P((char *, char *)); int reply __P((const char *)); +void resizemaps __P((dump_ino_t, dump_ino_t)); RST_DIR *rst_opendir __P((const char *)); struct direct *rst_readdir __P((RST_DIR *)); void rst_closedir __P((RST_DIR *dirp)); diff --git a/restore/main.c b/restore/main.c index 723a88f..c8c76a9 100644 --- a/restore/main.c +++ b/restore/main.c @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: main.c,v 1.41 2002/07/19 14:57:39 stelian Exp $"; + "$Id: main.c,v 1.42 2002/11/15 09:25:41 stelian Exp $"; #endif /* not lint */ #include @@ -90,8 +90,8 @@ char command = '\0'; long dumpnum = 1; long volno = 0; long ntrec; -char *dumpmap; -char *usedinomap; +char *dumpmap = NULL; +char *usedinomap = NULL; dump_ino_t maxino; time_t dumptime; time_t dumpdate; diff --git a/restore/symtab.c b/restore/symtab.c index 96dee35..3a6b1fb 100644 --- a/restore/symtab.c +++ b/restore/symtab.c @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: symtab.c,v 1.19 2002/07/19 14:57:40 stelian Exp $"; + "$Id: symtab.c,v 1.20 2002/11/15 09:25:42 stelian Exp $"; #endif /* not lint */ /* @@ -611,6 +611,7 @@ initsymtable(char *filename) panic("initsymtable called from command %c\n", command); break; } + resizemaps(maxino, hdr.maxino); maxino = hdr.maxino; entrytblsize = hdr.entrytblsize; entry = (struct entry **) diff --git a/restore/tape.c b/restore/tape.c index 3195ab5..8b54679 100644 --- a/restore/tape.c +++ b/restore/tape.c @@ -46,7 +46,7 @@ #ifndef lint static const char rcsid[] = - "$Id: tape.c,v 1.64 2002/07/29 12:00:34 stelian Exp $"; + "$Id: tape.c,v 1.65 2002/11/15 09:25:42 stelian Exp $"; #endif /* not lint */ #include @@ -374,15 +374,9 @@ setup(void) getfile(xtrmap, xtrmapskip); while (spcl.c_type == TS_ADDR) { /* Recompute maxino and the map */ - char *oldmap = usedinomap; dump_ino_t oldmaxino = maxino; maxino += (spcl.c_count * TP_BSIZE * NBBY) + 1; - map = calloc((unsigned)1, (unsigned)howmany(maxino, NBBY)); - if (map == NULL) - errx(1, "no memory for active inode map"); - usedinomap = map; - memcpy(usedinomap, oldmap, howmany(oldmaxino, NBBY)); - free(oldmap); + resizemaps(oldmaxino, maxino); spcl.c_dinode.di_size = spcl.c_count * TP_BSIZE; getfile(xtrmap, xtrmapskip); diff --git a/restore/utilities.c b/restore/utilities.c index e897344..16d1674 100644 --- a/restore/utilities.c +++ b/restore/utilities.c @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: utilities.c,v 1.20 2002/02/04 11:18:46 stelian Exp $"; + "$Id: utilities.c,v 1.21 2002/11/15 09:25:42 stelian Exp $"; #endif /* not lint */ #include @@ -543,3 +543,25 @@ Inode2Tapepos(dump_ino_t ino, long *tnum, long long *tpos, int exactmatch) return 0; } #endif /* USE_QFA */ + +void resizemaps(dump_ino_t oldmax, dump_ino_t newmax) +{ + char *map; + + if (usedinomap) { + map = calloc((unsigned)1, (unsigned)howmany(newmax, NBBY)); + if (map == NULL) + errx(1, "no memory for active inode map"); + memcpy(map, usedinomap, howmany(oldmax, NBBY)); + free(usedinomap); + usedinomap = map; + } + if (dumpmap) { + map = calloc((unsigned)1, (unsigned)howmany(newmax, NBBY)); + if (map == NULL) + errx(1, "no memory for file dump list"); + memcpy(map, dumpmap, howmany(oldmax, NBBY)); + free(dumpmap); + dumpmap = map; + } +} -- 2.39.5