]> git.wh0rd.org - dump.git/commitdiff
Made restore understand FreeBSD UFS2 dumps.
authorStelian Pop <stelian@popies.net>
Tue, 13 Apr 2004 13:03:55 +0000 (13:03 +0000)
committerStelian Pop <stelian@popies.net>
Tue, 13 Apr 2004 13:03:55 +0000 (13:03 +0000)
CHANGES
compat/include/protocols/dumprestore.h
restore/dirs.c
restore/main.c
restore/restore.h
restore/tape.c

diff --git a/CHANGES b/CHANGES
index 5be4e9eeeefe7ca99d58f5be6b93c32eb286976e..49f425a681dc3a5c30903e0116778083a8e222fc 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,4 @@
-$Id: CHANGES,v 1.244 2004/03/29 13:57:28 stelian Exp $
+$Id: CHANGES,v 1.245 2004/04/13 13:03:55 stelian Exp $
 
 Changes between versions 0.4b35 and 0.4b36 (released ?????????????????)
 =======================================================================
@@ -39,6 +39,10 @@ Changes between versions 0.4b35 and 0.4b36 (released ?????????????????)
        Raphael Jaffey <rjaffey@artic.edu> for reporting this, 
        debugging the issue and making the patch.
 
+10.    Made restore understand FreeBSD UFS2 tapes. Thanks to
+       David <vrtin@users.sourceforge.net> for submitting the bug
+       and providing a test case.
+
 Changes between versions 0.4b34 and 0.4b35 (released December 21, 2003)
 =======================================================================
 
index 9c6844fd52f2eca58fdb71f4f121720a631487a7..54bc19071de249d14b3b3badcab05db33d68eb19 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
  *
- *     $Id: dumprestore.h,v 1.20 2003/10/26 16:05:46 stelian Exp $
+ *     $Id: dumprestore.h,v 1.21 2004/04/13 13:03:55 stelian Exp $
  */
 
 /*
@@ -69,6 +69,7 @@
 
 #define OFS_MAGIC      (int)60011
 #define NFS_MAGIC      (int)60012
+#define FS_UFS2_MAGIC   (int)0x19540119
 #define CHECKSUM       (int)84446
 
 #ifdef __linux__
index f93e19f32d064200e760c89cdb41b4ee26356e03..3a8a94d4fd0dfc1a15016ac9f7b339eb7fbe5077 100644 (file)
@@ -42,7 +42,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: dirs.c,v 1.25 2004/03/29 13:57:29 stelian Exp $";
+       "$Id: dirs.c,v 1.26 2004/04/13 13:04:33 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
@@ -384,7 +384,7 @@ putdir(char *buf, size_t size)
        struct direct *dp;
        long loc, i;
 
-       if (cvtflag) {
+       if (cvtflag && !ufs2flag) {
                eodp = (struct odirect *)&buf[size];
                for (odp = (struct odirect *)buf; odp < eodp; odp++)
                        if (odp->d_ino != 0) {
index 77b9d7daf13fd787e8b72633fa94da618c73ad45..f53d740513c1718b9c156bde174737c15e1edc7a 100644 (file)
@@ -37,7 +37,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: main.c,v 1.45 2003/10/26 16:05:48 stelian Exp $";
+       "$Id: main.c,v 1.46 2004/04/13 13:04:33 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
@@ -92,6 +92,7 @@ int abortifconnerr = 1;               /* set to 1 if lib dumprmt.o should exit on connection
 int    aflag = 0, bflag = 0, cvtflag = 0, dflag = 0, vflag = 0, yflag = 0;
 int    hflag = 1, mflag = 1, Mflag = 0, Nflag = 0, Vflag = 0, zflag = 0;
 int    uflag = 0, lflag = 0, Lflag = 0, oflag = 0;
+int    ufs2flag = 0;
 char   *Afile = NULL;
 int    dokerberos = 0;
 char   command = '\0';
index 9239b07ea8dc0a576557ab2ee4b283a9fe5cfc27..bf6284b126c986950fc50c75284b94fafad0ec6e 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
  *
- *     $Id: restore.h,v 1.28 2003/10/26 16:05:48 stelian Exp $
+ *     $Id: restore.h,v 1.29 2004/04/13 13:04:33 stelian Exp $
  */
 
 /*
@@ -64,6 +64,7 @@ extern int    uflag;          /* unlink symlink targets */
 extern int     vflag;          /* print out actions taken */
 extern int     yflag;          /* always try to recover from tape errors */
 extern int     zflag;          /* tape is in compressed format */
+extern int     ufs2flag;       /* tape is a FreeBSD UFS2 dump */
 extern char*   bot_script;     /* beginning of tape script */
 /*
  * Global variables
index cc98e716d69566c55d78fede7fb94360d15622e2..560a6c96c5f220d00e04eaefc427a1011a7106d4 100644 (file)
@@ -42,7 +42,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: tape.c,v 1.78 2004/01/28 10:02:35 stelian Exp $";
+       "$Id: tape.c,v 1.79 2004/04/13 13:04:33 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
@@ -2457,34 +2457,47 @@ converthead(struct s_spcl *buf)
                goto good;
        }
        memcpy(&u_ospcl.s_ospcl, buf, TP_BSIZE);
-       memset((char *)buf, 0, (long)TP_BSIZE);
-       buf->c_type = u_ospcl.s_ospcl.c_type;
-       buf->c_date = u_ospcl.s_ospcl.c_date;
-       buf->c_ddate = u_ospcl.s_ospcl.c_ddate;
-       buf->c_volume = u_ospcl.s_ospcl.c_volume;
-       buf->c_tapea = u_ospcl.s_ospcl.c_tapea;
-       buf->c_inumber = u_ospcl.s_ospcl.c_inumber;
-       buf->c_checksum = u_ospcl.s_ospcl.c_checksum;
-       buf->c_magic = u_ospcl.s_ospcl.c_magic;
-       buf->c_dinode.di_mode = u_ospcl.s_ospcl.c_dinode.odi_mode;
-       buf->c_dinode.di_nlink = u_ospcl.s_ospcl.c_dinode.odi_nlink;
-       buf->c_dinode.di_uid = u_ospcl.s_ospcl.c_dinode.odi_uid;
-       buf->c_dinode.di_gid = u_ospcl.s_ospcl.c_dinode.odi_gid;
-       buf->c_dinode.di_size = u_ospcl.s_ospcl.c_dinode.odi_size;
-       buf->c_dinode.di_rdev = u_ospcl.s_ospcl.c_dinode.odi_rdev;
+       if (checksum((int *)(&u_ospcl.s_ospcl)) == FAIL)
+               return(FAIL);
+       if (u_ospcl.s_ospcl.c_magic == OFS_MAGIC) {
+               memset((char *)buf, 0, (long)TP_BSIZE);
+               buf->c_type = u_ospcl.s_ospcl.c_type;
+               buf->c_date = u_ospcl.s_ospcl.c_date;
+               buf->c_ddate = u_ospcl.s_ospcl.c_ddate;
+               buf->c_volume = u_ospcl.s_ospcl.c_volume;
+               buf->c_tapea = u_ospcl.s_ospcl.c_tapea;
+               buf->c_inumber = u_ospcl.s_ospcl.c_inumber;
+               buf->c_checksum = u_ospcl.s_ospcl.c_checksum;
+               buf->c_magic = u_ospcl.s_ospcl.c_magic;
+               buf->c_dinode.di_mode = u_ospcl.s_ospcl.c_dinode.odi_mode;
+               buf->c_dinode.di_nlink = u_ospcl.s_ospcl.c_dinode.odi_nlink;
+               buf->c_dinode.di_uid = u_ospcl.s_ospcl.c_dinode.odi_uid;
+               buf->c_dinode.di_gid = u_ospcl.s_ospcl.c_dinode.odi_gid;
+               buf->c_dinode.di_size = u_ospcl.s_ospcl.c_dinode.odi_size;
+               buf->c_dinode.di_rdev = u_ospcl.s_ospcl.c_dinode.odi_rdev;
 #if defined(__linux__) || defined(sunos)
-       buf->c_dinode.di_atime.tv_sec = u_ospcl.s_ospcl.c_dinode.odi_atime;
-       buf->c_dinode.di_mtime.tv_sec = u_ospcl.s_ospcl.c_dinode.odi_mtime;
-       buf->c_dinode.di_ctime.tv_sec = u_ospcl.s_ospcl.c_dinode.odi_ctime;
+               buf->c_dinode.di_atime.tv_sec = u_ospcl.s_ospcl.c_dinode.odi_atime;
+               buf->c_dinode.di_mtime.tv_sec = u_ospcl.s_ospcl.c_dinode.odi_mtime;
+               buf->c_dinode.di_ctime.tv_sec = u_ospcl.s_ospcl.c_dinode.odi_ctime;
 #else  /* __linux__ || sunos */
-       buf->c_dinode.di_atime = u_ospcl.s_ospcl.c_dinode.odi_atime;
-       buf->c_dinode.di_mtime = u_ospcl.s_ospcl.c_dinode.odi_mtime;
-       buf->c_dinode.di_ctime = u_ospcl.s_ospcl.c_dinode.odi_ctime;
+               buf->c_dinode.di_atime = u_ospcl.s_ospcl.c_dinode.odi_atime;
+               buf->c_dinode.di_mtime = u_ospcl.s_ospcl.c_dinode.odi_mtime;
+               buf->c_dinode.di_ctime = u_ospcl.s_ospcl.c_dinode.odi_ctime;
 #endif /* __linux__ || sunos */
-       buf->c_count = u_ospcl.s_ospcl.c_count;
-       memmove(buf->c_addr, u_ospcl.s_ospcl.c_fill, (long)256);
-       if (u_ospcl.s_ospcl.c_magic != OFS_MAGIC ||
-           checksum((int *)(&u_ospcl.s_ospcl)) == FAIL)
+               buf->c_count = u_ospcl.s_ospcl.c_count;
+               memmove(buf->c_addr, u_ospcl.s_ospcl.c_fill, (long)256);
+       }
+       else if (u_ospcl.s_ospcl.c_magic == FS_UFS2_MAGIC) {
+               buf->c_date = (int32_t)(*(int64_t *)&u_ospcl.dummy[896]);
+               buf->c_ddate = (int32_t)(*(int64_t *)&u_ospcl.dummy[904]);
+               buf->c_tapea = (int32_t)(*(int64_t *)&u_ospcl.dummy[912]);
+               buf->c_firstrec = (int32_t)(*(int64_t *)&u_ospcl.dummy[920]);
+               buf->c_ntrec = 0;
+               buf->c_extattributes = 0;
+               buf->c_flags |= DR_NEWINODEFMT;
+               ufs2flag = 1;
+       }
+       else
                return(FAIL);
        buf->c_magic = NFS_MAGIC;