From c930abff2469b9571a22fc49d16f50f36f5a9301 Mon Sep 17 00:00:00 2001
From: Stelian Pop <stelian@popies.net>
Date: Sun, 21 Nov 1999 02:24:45 +0000
Subject: [PATCH] Dump accepts ext3 filesystems. Checking the superblock
 features.

---
 CHANGES         | 12 +++++++++++-
 MCONFIG.in      |  4 ++--
 THANKS          |  3 ++-
 TODO            | 11 ++++++++++-
 dump.lsm        |  6 +++---
 dump.spec       |  5 ++++-
 dump/dump.h     |  4 +++-
 dump/main.c     |  4 ++--
 dump/tape.c     |  9 +++++----
 dump/traverse.c | 31 ++++++++++++++++++++++++++++++-
 rmt/rmt.c       |  8 +-------
 11 files changed, 73 insertions(+), 24 deletions(-)

diff --git a/CHANGES b/CHANGES
index 9448a0b..557acb1 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,4 @@
-$Id: CHANGES,v 1.17 1999/11/21 00:17:12 tiniou Exp $
+$Id: CHANGES,v 1.18 1999/11/21 02:24:45 tiniou Exp $
 
 Changes between versions 0.4b9 and 0.4b10 (released ???????????????)
 ====================================================================
@@ -19,6 +19,16 @@ Changes between versions 0.4b9 and 0.4b10 (released ???????????????)
 	has the nodump flag gets never dumped, regardless of its
 	contents.
 
+4.	Integrate a patch from Jeremy Fitzhardinge <jeremy@goop.org>
+	which allows dump on an active ext3 filesystem. However, this
+	is a "quick and dirty" patch which enables backup of an ext3
+	filesystem through the ext2 compatibility (by ignoring the
+	NEEDS_RECOVERY bit). The journal file is not recognized and
+	it is dumped (it should not). 
+
+5.	Test the superblock compatibility flags when dumping, in order
+	to be sure that we know how to deal with specific features.
+
 Changes between versions 0.4b8 and 0.4b9 (released November 5, 1999)
 ====================================================================
 
diff --git a/MCONFIG.in b/MCONFIG.in
index 871a8d9..6f2a0fb 100644
--- a/MCONFIG.in
+++ b/MCONFIG.in
@@ -2,8 +2,8 @@ VPATH=		$(srcdir)
 
 top_builddir=	@top_builddir@
 
-VERSION=	0.4b9
-DATE=		November 5, 1999
+VERSION=	0.4b10
+DATE=		November 21, 1999
 
 AR=		@AR@
 CC=		@CC@
diff --git a/THANKS b/THANKS
index 448efd0..b43b7b8 100644
--- a/THANKS
+++ b/THANKS
@@ -1,4 +1,4 @@
-$Id: THANKS,v 1.9 1999/11/17 22:46:40 tiniou Exp $
+$Id: THANKS,v 1.10 1999/11/21 02:24:45 tiniou Exp $
 
 Dump and restore were written by the people of the CSRG at the University
 of California, Berkeley.
@@ -24,6 +24,7 @@ Here is a partial list of them (if I have forgotten someone, please complain):
 
 Stephen Carr		sgcarr@civeng.adelaide.edu.au
 Abhijit Dasgupta	abhijit@ans.net
+Jeremy Fitzhardinge	jeremy@goop.org
 Eirik Fuller		eirik@netcom.com
 Henry Katz		hkatz@hkatz.dialup.access.net
 Klaus Kudielka		kkudielk@cacofonix.nt.tuwien.ac.at
diff --git a/TODO b/TODO
index d0a723e..bdb4783 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1,4 @@
-$Id: TODO,v 1.7 1999/11/21 00:17:12 tiniou Exp $
+$Id: TODO,v 1.8 1999/11/21 02:24:45 tiniou Exp $
 
 Need to verify:
 ---------------
@@ -31,3 +31,12 @@ All others:
 5.	Implement a DEBUG option which doesn't fork on each tape, making
 	it able to debug dump with gdb.
 
+6.	Add a compression mode using zlib on each file (see
+	http://www.cdrom.com/pub/infozip/zlib).
+
+7.	Add some support in dump and restore for numbering in sequence
+	the output files (when dumping to a file). Something like -N <prefix>
+	which creates (or reads) <prefix>-1, <prefix>-2 etc...
+
+8.	Make a bootable dump tape? I don't know if it is possible...
+
diff --git a/dump.lsm b/dump.lsm
index 41c975e..0c8b42e 100644
--- a/dump.lsm
+++ b/dump.lsm
@@ -1,13 +1,13 @@
 Begin3
 Title:          dump and restore for Ext2fs
-Version:        0.4b9
-Entered-date:   05NOV99
+Version:        0.4b10
+Entered-date:   21NOV99
 Description:    Port of the 4.4BSD dump and restore backup suite
 Keywords:       backup, filesystem, Ext2fs
 Author:         University of California, Berkeley
 Maintained-by:  pop@cybercable.fr (Stelian Pop)
 Primary-site:   tsx-11.mit.edu /pub/linux/ALPHA/ext2fs
-                135kB dump-0.4b9.tar.gz
+                135kB dump-0.4b10.tar.gz
                 677 dump.lsm
 Alternate-site: http://perso.cybercable.fr/pop/dump
 Original-site:  ftp.freebsd.org /pub/bsd-sources/4.4BSD-Lite2/sbin
diff --git a/dump.spec b/dump.spec
index 60e117d..e5f6222 100644
--- a/dump.spec
+++ b/dump.spec
@@ -1,6 +1,6 @@
 Summary: Programs for backing up and restoring filesystems.
 Name: dump
-Version: 0.4b9
+Version: 0.4b10
 Release: 1
 Copyright: UCB
 Group: Applications/Archiving
@@ -117,6 +117,9 @@ rm -rf $RPM_BUILD_ROOT
 /sbin/rrestore.static
 
 %changelog
+* Sun Nov 21 1999 Stelian Pop <pop@cybercable.fr>
+- dump 0.4b10 released, first packaging.
+
 * Thu Nov 11 1999 Stelian Pop <pop@cybercable.fr>
 - make static versions also for rescue purposes.
 
diff --git a/dump/dump.h b/dump/dump.h
index 12228ec..148e656 100644
--- a/dump/dump.h
+++ b/dump/dump.h
@@ -4,7 +4,7 @@
  *	Remy Card <card@Linux.EU.Org>, 1994-1997
  *	Stelian Pop <pop@cybercable.fr>, 1999
  *
- *	$Id: dump.h,v 1.6 1999/10/13 09:57:19 stelian Exp $
+ *	$Id: dump.h,v 1.7 1999/11/21 02:24:47 tiniou Exp $
  */
 
 /*-
@@ -229,6 +229,8 @@ extern int errno;
 
 #ifdef	__linux__
 #define	DUMP_CURRENT_REV	1
+
+int dump_fs_open(const char *disk, ext2_filsys *fs);
 #endif
 
 #ifndef	__linux__
diff --git a/dump/main.c b/dump/main.c
index 3348e18..1ccbf36 100644
--- a/dump/main.c
+++ b/dump/main.c
@@ -40,7 +40,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-	"$Id: main.c,v 1.6 1999/10/13 09:57:19 stelian Exp $";
+	"$Id: main.c,v 1.7 1999/11/21 02:24:47 tiniou Exp $";
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -414,7 +414,7 @@ main(int argc, char *argv[])
 	msg("Label: %s\n", labelstr);
 
 #ifdef	__linux__
-	retval = ext2fs_open(disk, 0, 0, 0, unix_io_manager, &fs);
+	retval = dump_fs_open(disk, &fs);
 	if (retval) {
 		com_err(disk, retval, "while opening filesystem");
 		if (retval == EXT2_ET_REV_TOO_HIGH)
diff --git a/dump/tape.c b/dump/tape.c
index 1b28c41..a0cc7e3 100644
--- a/dump/tape.c
+++ b/dump/tape.c
@@ -40,7 +40,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-	"$Id: tape.c,v 1.7 1999/11/02 09:35:56 tiniou Exp $";
+	"$Id: tape.c,v 1.8 1999/11/21 02:24:47 tiniou Exp $";
 #endif /* not lint */
 
 #ifdef __linux__
@@ -81,9 +81,10 @@ static const char rcsid[] =
 int	write(), read();
 #endif
 
-#ifdef	__linux__
+#ifdef __linux__
 #include <ext2fs/ext2fs.h>
 #endif
+
 #include "dump.h"
 
 int	writesize;		/* size of malloc()ed buffer for tape */
@@ -908,9 +909,9 @@ doslave(int cmd, int slave_number)
 		quit("slave couldn't reopen disk: %s\n", strerror(errno));
 #ifdef	__linux__
 	ext2fs_close(fs);
-	retval = ext2fs_open(disk, 0, 0, 0, unix_io_manager, &fs);
+	retval = dump_fs_open(disk, &fs);
 	if (retval)
-		quit("slave couldn't reopen disk: %s\n", strerror(errno));
+		quit("slave couldn't reopen disk: %s\n", error_message(retval));
 #endif	/* __linux__ */
 
 	/*
diff --git a/dump/traverse.c b/dump/traverse.c
index 32ffd7e..7d6a38f 100644
--- a/dump/traverse.c
+++ b/dump/traverse.c
@@ -40,7 +40,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-	"$Id: traverse.c,v 1.9 1999/11/21 00:17:16 tiniou Exp $";
+	"$Id: traverse.c,v 1.10 1999/11/21 02:24:47 tiniou Exp $";
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -100,6 +100,35 @@ static	int searchdir __P((ino_t ino, daddr_t blkno, long size, long filesize));
 #endif
 static	void mapfileino __P((ino_t ino, long *tapesize, int *dirskipped));
 
+/* #define EXT3_FEATURE_INCOMPAT_RECOVER */
+
+int dump_fs_open(const char *disk, ext2_filsys *fs)
+{
+	int retval;
+	struct ext2fs_sb *s;
+
+#ifdef EXT3_FEATURE_INCOMPAT_RECOVER
+	retval = ext2fs_open(disk, EXT2_FLAG_FORCE, 0, 0, unix_io_manager, fs);
+#else
+	retval = ext2fs_open(disk, 0, 0, 0, unix_io_manager, fs);
+#endif
+	if (!retval) {
+		s = (struct ext2fs_sb *) (*fs)->super;
+		if ((s->s_feature_compat & ~EXT2_LIB_FEATURE_COMPAT_SUPP) ||
+#ifdef EXT3_FEATURE_INCOMPAT_RECOVER
+		    (s->s_feature_incompat & ~(EXT3_FEATURE_INCOMPAT_RECOVER | EXT2_LIB_FEATURE_INCOMPAT_SUPP))) {
+#else
+		    (s->s_feature_incompat & ~EXT2_LIB_FEATURE_INCOMPAT_SUPP)) {
+#endif
+			retval = EXT2_ET_UNSUPP_FEATURE;
+		}
+		else if (s->s_feature_ro_compat & ~EXT2_LIB_FEATURE_RO_COMPAT_SUPP) {
+			retval = EXT2_ET_RO_UNSUPP_FEATURE;
+		}
+	}
+	return retval;
+}
+
 /*
  * This is an estimation of the number of TP_BSIZE blocks in the file.
  * It estimates the number of blocks in files with holes by assuming
diff --git a/rmt/rmt.c b/rmt/rmt.c
index 7d55b2d..f52c36b 100644
--- a/rmt/rmt.c
+++ b/rmt/rmt.c
@@ -40,7 +40,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-	"$Id: rmt.c,v 1.7 1999/11/11 16:14:01 tiniou Exp $";
+	"$Id: rmt.c,v 1.8 1999/11/21 02:24:47 tiniou Exp $";
 #endif /* not linux */
 
 /*
@@ -59,12 +59,6 @@ static const char rcsid[] =
 #include <string.h>
 #include <unistd.h>
 
-#ifdef __linux__
-#include <linux/ext2_fs.h>
-#include <ext2fs/ext2fs.h>
-#include <bsdcompat.h>
-#endif
-
 int	tape = -1;
 
 char	*record;
-- 
2.39.5