From: Stelian Pop Date: Tue, 13 Apr 2004 13:03:55 +0000 (+0000) Subject: Made restore understand FreeBSD UFS2 dumps. X-Git-Tag: release_0_4b36~3 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=cc7747ebe3cb5b31e059155a8bb1ee4cecc67236;p=dump.git Made restore understand FreeBSD UFS2 dumps. --- diff --git a/CHANGES b/CHANGES index 5be4e9e..49f425a 100644 --- 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 for reporting this, debugging the issue and making the patch. +10. Made restore understand FreeBSD UFS2 tapes. Thanks to + David for submitting the bug + and providing a test case. + Changes between versions 0.4b34 and 0.4b35 (released December 21, 2003) ======================================================================= diff --git a/compat/include/protocols/dumprestore.h b/compat/include/protocols/dumprestore.h index 9c6844f..54bc190 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.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__ diff --git a/restore/dirs.c b/restore/dirs.c index f93e19f..3a8a94d 100644 --- a/restore/dirs.c +++ b/restore/dirs.c @@ -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 @@ -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) { diff --git a/restore/main.c b/restore/main.c index 77b9d7d..f53d740 100644 --- a/restore/main.c +++ b/restore/main.c @@ -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 @@ -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'; diff --git a/restore/restore.h b/restore/restore.h index 9239b07..bf6284b 100644 --- a/restore/restore.h +++ b/restore/restore.h @@ -5,7 +5,7 @@ * Stelian Pop , 1999-2000 * Stelian Pop - Alcôve , 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 diff --git a/restore/tape.c b/restore/tape.c index cc98e71..560a6c9 100644 --- a/restore/tape.c +++ b/restore/tape.c @@ -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 @@ -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;