]> git.wh0rd.org - dump.git/commitdiff
Fixed LFS problems when restoring huge dumps (with temporary files being over 2 GB).
authorStelian Pop <stelian@popies.net>
Mon, 29 Mar 2004 13:57:28 +0000 (13:57 +0000)
committerStelian Pop <stelian@popies.net>
Mon, 29 Mar 2004 13:57:28 +0000 (13:57 +0000)
CHANGES
THANKS
compat/include/compatlfs.h
restore/dirs.c

diff --git a/CHANGES b/CHANGES
index 86910e4970a9e1c8c7925e06e9313c108bb8d06d..5be4e9eeeefe7ca99d58f5be6b93c32eb286976e 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,4 @@
-$Id: CHANGES,v 1.243 2004/03/08 14:04:02 stelian Exp $
+$Id: CHANGES,v 1.244 2004/03/29 13:57:28 stelian Exp $
 
 Changes between versions 0.4b35 and 0.4b36 (released ?????????????????)
 =======================================================================
@@ -34,6 +34,11 @@ Changes between versions 0.4b35 and 0.4b36 (released ?????????????????)
        or multiple -f were NOT specified. Some users rely on this
        feature even when it is combined with -M/-f.
 
+9.     Fixed restore when restoring huge backups (where rstdir...
+       temporary files are over 2GB). Thanks to 
+       Raphael Jaffey <rjaffey@artic.edu> for reporting this, 
+       debugging the issue and making the patch.
+
 Changes between versions 0.4b34 and 0.4b35 (released December 21, 2003)
 =======================================================================
 
diff --git a/THANKS b/THANKS
index 031d70a955f35c983faf92bc214becfe55b91d8e..0869803a4a43b5e341373671bd514c5db3bde522 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -1,4 +1,4 @@
-$Id: THANKS,v 1.83 2003/05/12 14:16:35 stelian Exp $
+$Id: THANKS,v 1.84 2004/03/29 13:57:28 stelian Exp $
 
 Dump and restore were written by the people of the CSRG at the University
 of California, Berkeley.
@@ -30,6 +30,7 @@ Gerd Bavendiek                bav@epost.de
 Fabrice Bellet         fabrice@bellet.info
 Stan Bubrouski         satan@fastdial.net
 Stephen Carr           sgcarr@civeng.adelaide.edu.au
+Mike Castle            dalgoda@users.sourceforge.net
 Rob Cermak             cermak@ahab.rutgers.edu
 Antonios Christofides  A.Christofides@itia.ntua.gr
 Isaac Chuang           ike@isl.stanford.edu
@@ -51,16 +52,20 @@ Arcady Genkin               antipode@users.sourceforge.net
 Uwe Gohlke             uwe@ugsoft.de
 Ian Gordon             iangordon@users.sourceforge.net
 Ted Grzesik            tedgyz@roostme.com
+Mike Harris            mharris@redhat.com
 Andreas Hasenack       andreas@conectiva.com.br
 Christian Haul         haul@informatik.tu-darmstadt.de
 George Helffrich       george@geology.bristol.ac.uk
+Patrick Higgins                phiggins@transzap.com
 Kjetil Torgrim Homme   kjetilho@ifi.uio.no
+Raphael Jaffey         rjaffey@artic.edu
 Jean-Paul van der Jagt jeanpaul@dutepp0.et.tudelft.nl
 Helmut Jarausch                jarausch@igpm.rwth-aachen.de
 Eric Jergensen         eric@dvns.com
 Jeff Johnson           jbj@redhat.com
 Richard Johnson                Richard.Johnson3@ey.com
 Richard Jones           rich@annexia.org
+Zhang Jun              zhangjun@nanjing-fnst.com
 Charles Karney         karney@users.sourceforge.net
 Henry Katz             hkatz@hkatz.dialup.access.net
 Dragan Krnic           dkrnic@lycos.com
@@ -81,6 +86,7 @@ Elliott Mitchell      ehem@m5p.com
 David Monro            davidm@cs.su.oz.au
 Dejan Muhamedagic      dejan@quant-x.com
 Lukas Nellen           L.Nellen@ThPhys.Uni-Heidelberg.DE
+Markus Oberhumer       markus@oberhumer.com
 Nuno Oliveira          nuno@eq.uc.pt
 Brent Olson            night@halcyon.com
 Jorgen Ostling         jorgen_ostling@users.sourceforge.net
@@ -124,3 +130,4 @@ Christian Weisgerber        naddy@mips.rhein-neckar.de
 Kim Yong-jun           loveyou@hackerslab.org
 John Yu                        jky@it.bu.edu
 Ian Zimmerman          itz@speakeasy.org
+Florian Zumbiehl       florz@gmx.de
index 7b95b873c57760fe1eec5ef6b4f13c5d39c0915c..fe7db5f2fb7857dbbe17d1d0e0b0f3d6ebf21ecf 100644 (file)
@@ -3,7 +3,7 @@
  *     dump and restore backup suit
  *     Stelian Pop <stelian@popies.net> - AlcĂ´ve <www.alcove.com>, 2000-2002
  *
- *     $Id: compatlfs.h,v 1.4 2003/03/30 15:40:34 stelian Exp $
+ *     $Id: compatlfs.h,v 1.5 2004/03/29 13:57:29 stelian Exp $
  */
 
 /*-
@@ -49,6 +49,8 @@
 #define LSTAT lstat64
 #define FTRUNCATE ftruncate64
 #define OFF_T __off64_t
+#define MKSTEMP mkstemp64
+#define FTELL ftello64
 
 #else
 
@@ -58,6 +60,8 @@
 #define LSTAT lstat
 #define FTRUNCATE ftruncate
 #define OFF_T off_t
+#define MKSTEMP mkstemp
+#define FTELL ftell
 
 #endif /* USE_LFS */
 
index 239248809daf0ac99630721b753c5499ba9e9d24..f93e19f32d064200e760c89cdb41b4ee26356e03 100644 (file)
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: dirs.c,v 1.24 2003/10/26 16:05:47 stelian Exp $";
+       "$Id: dirs.c,v 1.25 2004/03/29 13:57:29 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
+#include <compatlfs.h>
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/file.h>
@@ -98,8 +99,8 @@ static const char rcsid[] =
 struct inotab {
        struct  inotab *t_next;
        dump_ino_t t_ino;
-       int32_t t_seekpt;
-       int32_t t_size;
+       OFF_T   t_seekpt;
+       OFF_T   t_size;
 };
 static struct inotab *inotab[HASHSIZE];
 
@@ -130,7 +131,7 @@ struct rstdirdesc {
 /*
  * Global variables for this file.
  */
-static long    seekpt;
+static OFF_T   seekpt;
 static FILE    *df, *mf;
 static RST_DIR *dirp;
 static char    dirfile[MAXPATHLEN] = "#";      /* No file */
@@ -147,9 +148,9 @@ struct odirect {
 };
 
 #if defined(__linux__) || defined(sunos)
-static struct inotab   *allocinotab __P((dump_ino_t, struct new_bsd_inode *, long));
+static struct inotab   *allocinotab __P((dump_ino_t, struct new_bsd_inode *, OFF_T));
 #else
-static struct inotab   *allocinotab __P((dump_ino_t, struct dinode *, long));
+static struct inotab   *allocinotab __P((dump_ino_t, struct dinode *, OFF_T));
 #endif
 static void             dcvt __P((struct odirect *, struct direct *));
 static void             flushent __P((void));
@@ -157,8 +158,8 @@ static struct inotab        *inotablookup __P((dump_ino_t));
 static RST_DIR         *opendirfile __P((const char *));
 static void             putdir __P((char *, size_t));
 static void             putent __P((struct direct *));
-static void             rst_seekdir __P((RST_DIR *, long, long));
-static long             rst_telldir __P((RST_DIR *));
+static void            rst_seekdir __P((RST_DIR *, OFF_T, OFF_T));
+static OFF_T           rst_telldir __P((RST_DIR *));
 static struct direct   *searchdir __P((dump_ino_t, char *));
 
 #ifdef sunos
@@ -190,9 +191,9 @@ extractdirs(int genmode)
        if (command != 'r' && command != 'R') {
                (void) strncat(dirfile, "-XXXXXX",
                        sizeof(dirfile) - strlen(dirfile));
-               fd = mkstemp(dirfile);
+               fd = MKSTEMP(dirfile);
        } else
-               fd = open(dirfile, O_RDWR|O_CREAT|O_EXCL, 0666);
+               fd = OPEN(dirfile, O_RDWR|O_CREAT|O_EXCL, 0666);
        if (fd == -1 || (df = fdopen(fd, "w")) == NULL) {
                if (fd != -1)
                        close(fd);
@@ -203,9 +204,9 @@ extractdirs(int genmode)
                if (command != 'r' && command != 'R') {
                        (void) strncat(modefile, "-XXXXXX",
                                sizeof(modefile) - strlen(modefile));
-                       fd = mkstemp(modefile);
+                       fd = MKSTEMP(modefile);
                } else
-                       fd = open(modefile, O_RDWR|O_CREAT|O_EXCL, 0666);
+                       fd = OPEN(modefile, O_RDWR|O_CREAT|O_EXCL, 0666);
                if (fd == -1 || (mf = fdopen(fd, "w")) == NULL) {
                        if (fd != -1)
                                close(fd);
@@ -265,7 +266,7 @@ treescan(char *pname, dump_ino_t ino, long (*todo) __P((char *, dump_ino_t, int)
        struct inotab *itp;
        struct direct *dp;
        int namelen;
-       long bpt;
+       OFF_T bpt;
        char locname[MAXPATHLEN + 1];
 
        itp = inotablookup(ino);
@@ -479,7 +480,7 @@ flushent(void)
        ((struct direct *)(dirbuf + prev))->d_reclen = DIRBLKSIZ - prev;
        if ( fwrite(dirbuf, (int)dirloc, 1, df) != 1 )
                err(1, "cannot write to file %s", dirfile);
-       seekpt = ftell(df);
+       seekpt = FTELL(df);
        if (seekpt == -1)
                err(1, "cannot write to file %s", dirfile);
        dirloc = 0;
@@ -505,15 +506,15 @@ dcvt(struct odirect *odp, struct direct *ndp)
  * the desired seek offset into it.
  */
 static void
-rst_seekdir(RST_DIR *dirp, long loc, long base)
+rst_seekdir(RST_DIR *dirp, OFF_T loc, OFF_T base)
 {
 
        if (loc == rst_telldir(dirp))
                return;
        loc -= base;
        if (loc < 0)
-               fprintf(stderr, "bad seek pointer to rst_seekdir %ld\n", loc);
-       (void) lseek(dirp->dd_fd, base + (loc & ~(DIRBLKSIZ - 1)), SEEK_SET);
+               fprintf(stderr, "bad seek pointer to rst_seekdir %lld\n", loc);
+       (void) LSEEK(dirp->dd_fd, base + (loc & ~(DIRBLKSIZ - 1)), SEEK_SET);
        dirp->dd_loc = loc & (DIRBLKSIZ - 1);
        if (dirp->dd_loc != 0)
                dirp->dd_size = read(dirp->dd_fd, dirp->dd_buf, DIRBLKSIZ);
@@ -593,11 +594,11 @@ rst_closedir(RST_DIR *dirp)
 /*
  * Simulate finding the current offset in the directory.
  */
-static long
+static OFF_T
 rst_telldir(RST_DIR *dirp)
 {
-       return ((long)lseek(dirp->dd_fd,
-           (OFF_T)0, SEEK_CUR) - dirp->dd_size + dirp->dd_loc);
+       return ((OFF_T)LSEEK(dirp->dd_fd,
+               (OFF_T)0, SEEK_CUR) - dirp->dd_size + dirp->dd_loc);
 }
 
 /*
@@ -609,7 +610,7 @@ opendirfile(const char *name)
        RST_DIR *dirp;
        int fd;
 
-       if ((fd = open(name, O_RDONLY)) == -1)
+       if ((fd = OPEN(name, O_RDONLY)) == -1)
                return (NULL);
        if ((dirp = malloc(sizeof(RST_DIR))) == NULL) {
                (void)close(fd);
@@ -745,9 +746,9 @@ inodetype(dump_ino_t ino)
  */
 static struct inotab *
 #if defined(__linux__) || defined(sunos)
-allocinotab(dump_ino_t ino, struct new_bsd_inode *dip, long seekpt)
+allocinotab(dump_ino_t ino, struct new_bsd_inode *dip, OFF_T seekpt)
 #else
-allocinotab(dump_ino_t ino, struct dinode *dip, long seekpt)
+allocinotab(dump_ino_t ino, struct dinode *dip, OFF_T seekpt)
 #endif
 {
        struct inotab   *itp;