-$Id: CHANGES,v 1.133 2001/08/16 13:12:30 stelian Exp $
+$Id: CHANGES,v 1.134 2001/08/16 15:24:21 stelian Exp $
Changes between versions 0.4b23 and 0.4b24 (released ?????????????)
===================================================================
5. Detect the use of incompatible options to dump and
refuse them (like -a and -B options together).
+6. Added bzip2 compression to dump/restore (use option -j level
+ to select it). Note that you will need a restore version
+ >= 0.4b24 in order to restore a bzip2 compressed dump.
+ The same warning as for the zlib compression applies:
+ the tape format of a bzip2 dump is not compatible with the
+ original BSD tape format.
+
Changes between versions 0.4b22 and 0.4b23 (released July 20, 2001)
===================================================================
-$Id: TODO,v 1.22 2001/08/16 13:15:21 stelian Exp $
+$Id: TODO,v 1.23 2001/08/16 15:24:21 stelian Exp $
Need to verify:
---------------
4. Implement a DEBUG option which doesn't fork on each tape, making
it able to debug dump with gdb.
-5. Extend the compression patch to use bzip2.
+5. Make a bootable dump tape? I don't know if it is possible...
-6. Make a bootable dump tape? I don't know if it is possible...
-
-7. From Kjetil Torgrim Homme <kjetilho@ifi.uio.no>:
+6. From Kjetil Torgrim Homme <kjetilho@ifi.uio.no>:
a archive_file
Archive file. Archive a dump table-of-contents in
the specified archive_file to be used by
ufsrestore(1M) to determine whether a file is in
the dump file that is being restored.
-8. EA/ACL support in dump (requested by Michael Ju. Tokarev
+7. EA/ACL support in dump (requested by Michael Ju. Tokarev
<mjt@tls.msk.ru>.
-9. Better readline completition in restore (escape spaces etc).
+8. Better readline completition in restore (escape spaces etc).
-10. Dump compiled with RedHat's 7.0 gcc seems to hang for some
+9. Dump compiled with RedHat's 7.0 gcc seems to hang for some
people. When compiled with kgcc all the problems disappear.
Will the RedHat's 7.1 gcc resolve this ?
* Stelian Pop <pop@noos.fr>, 1999-2000
* Stelian Pop <pop@noos.fr> - AlcĂ´ve <www.alcove.fr>, 2000
*
- * $Id: dumprestore.h,v 1.13 2001/05/12 11:36:12 stelian Exp $
+ * $Id: dumprestore.h,v 1.14 2001/08/16 15:24:21 stelian Exp $
*/
/*
#define DR_NEWINODEFMT 0x0002 /* new format inodes on tape */
#define DR_COMPRESSED 0x0080 /* dump tape is compressed */
+/*
+ * compression flags for the tapebuf header.
+ */
+#define COMPRESS_ZLIB 0
+#define COMPRESS_BZLIB 1
+
/* used for compressed dump tapes */
struct tapebuf {
unsigned int compressed:1;
/* Define this if you have zlib compression library */
#undef HAVE_ZLIB
+/* Define this if you have bzlib compression library */
+#undef HAVE_BZLIB
+
/* Define this if you want Quick File Access support */
#undef USE_QFA
fi
+ac_safe=`echo "bzlib.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for bzlib.h""... $ac_c" 1>&6
+echo "configure:2056: checking for bzlib.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2061 "configure"
+#include "confdefs.h"
+#include <bzlib.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:2066: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ bzlib_h=yes
+else
+ echo "$ac_t""no" 1>&6
+bzlib_h=no
+fi
+
+echo $ac_n "checking for BZ2_bzBuffToBuffCompress in -lbz2""... $ac_c" 1>&6
+echo "configure:2089: checking for BZ2_bzBuffToBuffCompress in -lbz2" >&5
+ac_lib_var=`echo bz2'_'BZ2_bzBuffToBuffCompress | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lbz2 $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 2097 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char BZ2_bzBuffToBuffCompress();
+
+int main() {
+BZ2_bzBuffToBuffCompress()
+; return 0; }
+EOF
+if { (eval echo configure:2108: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ bzlib_lib=yes
+else
+ echo "$ac_t""no" 1>&6
+bzlib_lib=no
+fi
+
+if test "$bzlib_h" = yes -a "$bzlib_lib" = yes; then
+ BZLIB="-lbz2"
+ cat >> confdefs.h <<\EOF
+#define HAVE_BZLIB 1
+EOF
+
+else
+ BZLIB=""
+fi
+
+
for ac_func in err errx verr verrx vwarn vwarnx warn warnx realpath lchown
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2057: checking for $ac_func" >&5
+echo "configure:2143: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2062 "configure"
+#line 2148 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:2085: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2171: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
done
echo $ac_n "checking for glob""... $ac_c" 1>&6
-echo "configure:2110: checking for glob" >&5
+echo "configure:2196: checking for glob" >&5
if eval "test \"`echo '$''{'ac_cv_func_glob'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2115 "configure"
+#line 2201 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char glob(); below. */
; return 0; }
EOF
-if { (eval echo configure:2138: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2224: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_glob=yes"
else
echo $ac_n "checking for extended glob routines""... $ac_c" 1>&6
-echo "configure:2159: checking for extended glob routines" >&5
+echo "configure:2245: checking for extended glob routines" >&5
if test "$ac_cv_func_glob" = "yes"; then
cat > conftest.$ac_ext <<EOF
-#line 2162 "configure"
+#line 2248 "configure"
#include "confdefs.h"
# include <glob.h>
fi
echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:2193: checking for ANSI C header files" >&5
+echo "configure:2279: checking for ANSI C header files" >&5
if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2198 "configure"
+#line 2284 "configure"
#include "confdefs.h"
#include <stdlib.h>
#include <stdarg.h>
#include <float.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2206: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2292: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 2223 "configure"
+#line 2309 "configure"
#include "confdefs.h"
#include <string.h>
EOF
if test $ac_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 2241 "configure"
+#line 2327 "configure"
#include "confdefs.h"
#include <stdlib.h>
EOF
:
else
cat > conftest.$ac_ext <<EOF
-#line 2262 "configure"
+#line 2348 "configure"
#include "confdefs.h"
#include <ctype.h>
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
exit (0); }
EOF
-if { (eval echo configure:2273: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2359: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
:
else
fi
echo $ac_n "checking for quad_t""... $ac_c" 1>&6
-echo "configure:2297: checking for quad_t" >&5
+echo "configure:2383: checking for quad_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_quad_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2302 "configure"
+#line 2388 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
fi
echo $ac_n "checking for u_quad_t""... $ac_c" 1>&6
-echo "configure:2330: checking for u_quad_t" >&5
+echo "configure:2416: checking for u_quad_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_u_quad_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2335 "configure"
+#line 2421 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
s%@DUMPDATESPATH@%$DUMPDATESPATH%g
s%@CPP@%$CPP%g
s%@ZLIB@%$ZLIB%g
+s%@BZLIB@%$BZLIB%g
s%@top_builddir@%$top_builddir%g
CEOF
fi
AC_SUBST(ZLIB)
+dnl
+dnl Check for bzlib headers and libraries
+dnl
+AC_CHECK_HEADER(bzlib.h, [bzlib_h=yes], [bzlib_h=no])
+AC_CHECK_LIB(bz2, BZ2_bzBuffToBuffCompress, [bzlib_lib=yes], [bzlib_lib=no])
+if test "$bzlib_h" = yes -a "$bzlib_lib" = yes; then
+ BZLIB="-lbz2"
+ AC_DEFINE(HAVE_BZLIB)
+else
+ BZLIB=""
+fi
+AC_SUBST(BZLIB)
+
dnl
dnl Check for library functions
dnl
-# $Id: Makefile.in,v 1.7 2001/04/12 16:03:29 stelian Exp $
+# $Id: Makefile.in,v 1.8 2001/08/16 15:24:21 stelian Exp $
top_srcdir= @top_srcdir@
srcdir= @srcdir@
CFLAGS= @CCOPTS@ -pipe $(OPT) $(GINC) $(INC) $(DEFS) @DUMPDEBUG@
LDFLAGS:= $(LDFLAGS) @STATIC@
-LIBS= $(GLIBS) @ZLIB@
+LIBS= $(GLIBS) @ZLIB@ @BZLIB@
DEPLIBS= ../compat/lib/libcompat.a
PROG= dump
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: dump.8.in,v 1.31 2001/08/16 09:37:59 stelian Exp $
+.\" $Id: dump.8.in,v 1.32 2001/08/16 15:24:21 stelian Exp $
.\"
.Dd __DATE__
.Dt DUMP 8
.Op Fl f Ar file
.Op Fl F Ar script
.Op Fl h Ar level
+.Op Fl j Ar compression level
.Op Fl L Ar label
.Op Fl Q Ar file
.Op Fl s Ar feet
.Nm
reverts back to the real user ID and the real group ID before
running the script.
+.It Fl j Ar compression level
+Compress every block to be written on the tape using bzlib library. This
+option will work only when dumping to a file or pipe or, when dumping
+to a tape drive, if the tape drive is capable of writing variable
+length blocks. You will need at least the 0.4b24 version of restore in
+order to extract compressed tapes. Tapes written using compression will
+not be compatible with the BSD tape format. The (optional) parameter
+specifies the compression level bzlib will use. The default compression
+level is 2.
.It Fl k
Use Kerberos authentication to talk to remote tape servers. (Only
available if this option was enabled when
* Stelian Pop <pop@noos.fr>, 1999-2000
* Stelian Pop <pop@noos.fr> - AlcĂ´ve <www.alcove.fr>, 2000
*
- * $Id: dump.h,v 1.31 2001/08/16 09:37:59 stelian Exp $
+ * $Id: dump.h,v 1.32 2001/08/16 15:24:21 stelian Exp $
*/
/*-
extern char *dumpdates; /* name of the file containing dump date information*/
extern char lastlevel; /* dump level of previous dump */
extern char level; /* dump level of this dump */
+extern int bzipflag; /* compression is done using bzlib */
extern int uflag; /* update flag */
extern int Mflag; /* multi-volume flag */
extern int qflag; /* quit on errors flag */
#ifndef lint
static const char rcsid[] =
- "$Id: main.c,v 1.58 2001/08/16 13:12:30 stelian Exp $";
+ "$Id: main.c,v 1.59 2001/08/16 15:24:21 stelian Exp $";
#endif /* not lint */
#include <config.h>
char *dumpdates; /* name of the file containing dump date information*/
char lastlevel; /* dump level of previous dump */
char level; /* dump level of this dump */
+int bzipflag; /* compression is done using bzlib */
int uflag; /* update flag */
int Mflag; /* multi-volume flag */
int qflag; /* quit on errors flag */
#endif /* USE_QFA */
while ((ch = getopt(argc, argv,
- "0123456789aB:b:cd:e:E:f:F:h:L:"
+ "0123456789aB:b:cd:e:E:f:F:h:"
+#ifdef HAVE_BZLIB
+ "j::"
+#endif
+ "L:"
#ifdef KERBEROS
"k"
#endif
honorlevel = numarg("honor level", 0L, 10L);
break;
+#ifdef HAVE_BZLIB
+ case 'j':
+ compressed = 2;
+ bzipflag = 1;
+ if (optarg)
+ compressed = numarg("compress level", 1L, 9L);
+ break;
+#endif /* HAVE_BZLIB */
+
#ifdef KERBEROS
case 'k':
dokerberos = 1;
msg("Label: %s\n", spcl.c_label);
if (compressed)
- msg("Compressing output at compression level %d\n",
- compressed);
+ msg("Compressing output at compression level %d (%s)\n",
+ compressed, bzipflag ? "bzlib" : "zlib");
}
#if defined(SIGINFO)
"MnqSu"
"] [-B records] [-b blocksize] [-d density]\n"
"\t%s [-e inode#,inode#,...] [-E file] [-f file] [-h level] "
+#ifdef HAVE_BZLIB
+ "[-j zlevel] "
+#endif
+ "\n\t%s "
#ifdef USE_QFA
"[-Q file] "
#endif
- "\n\t%s [-s feet] [-T date] "
+ "[-s feet] [-T date] "
#ifdef HAVE_ZLIB
"[-z zlevel] "
#endif
#ifndef lint
static const char rcsid[] =
- "$Id: tape.c,v 1.53 2001/07/20 11:02:45 stelian Exp $";
+ "$Id: tape.c,v 1.54 2001/08/16 15:24:21 stelian Exp $";
#endif /* not lint */
#include <config.h>
#include <zlib.h>
#endif /* HAVE_ZLIB */
+#ifdef HAVE_BZLIB
+#include <bzlib.h>
+#endif /* HAVE_BZLIB */
+
#include "dump.h"
int writesize; /* size of malloc()ed buffer for tape */
int nextslave, size, eot_count, bufsize;
volatile int wrote = 0;
char *buffer;
-#ifdef HAVE_ZLIB
+#if defined(HAVE_ZLIB) || defined(HAVE_BZLIB)
struct tapebuf *comp_buf = NULL;
int compresult, do_compress = !first;
unsigned long worklen;
-#endif /* HAVE_ZLIB */
+#ifdef HAVE_BZLIB
+ unsigned int worklen2;
+#endif
+#endif /* HAVE_ZLIB || HAVE_BZLIB */
struct slave_results returns;
#ifdef __linux__
errcode_t retval;
quit("master/slave protocol botched - didn't get pid of next slave.\n");
}
-#ifdef HAVE_ZLIB
+#if defined(HAVE_ZLIB) || defined(HAVE_BZLIB)
/* if we're doing a compressed dump, allocate the compress buffer */
if (compressed) {
comp_buf = malloc(sizeof(struct tapebuf) + TP_BSIZE + writesize);
if (comp_buf == NULL)
quit("couldn't allocate a compress buffer.\n");
- comp_buf->flags = 0;
+ if (bzipflag)
+ comp_buf->flags = COMPRESS_BZLIB;
+ else
+ comp_buf->flags = COMPRESS_ZLIB;
}
-#endif /* HAVE_ZLIB */
+#endif /* HAVE_ZLIB || HAVE_BZLIB */
/*
* Get list of blocks to dump, read the blocks into tape buffer
bufsize = writesize; /* length to write */
returns.clen = returns.unclen = bufsize;
-#ifdef HAVE_ZLIB
+#if defined(HAVE_ZLIB) || defined(HAVE_BZLIB)
/*
* When writing a compressed dump, each block except
* the first one on each tape is written
if (compressed && do_compress) {
comp_buf->length = bufsize;
worklen = TP_BSIZE + writesize;
- compresult = compress2(comp_buf->buf, &worklen,
- (char *)slp->tblock[0], writesize, compressed);
- if (compresult == Z_OK && worklen <= (writesize - 16)) {
+#ifdef HAVE_ZLIB
+ if (!bzipflag) {
+ compresult = compress2(comp_buf->buf,
+ &worklen,
+ (char *)slp->tblock[0],
+ writesize,
+ compressed);
+ if (compresult == Z_OK)
+ compresult = 1;
+ else
+ compresult = 0;
+ }
+#endif /* HAVE_ZLIB */
+#ifdef HAVE_BZLIB
+ if (bzipflag) {
+ worklen2 = worklen;
+ compresult = BZ2_bzBuffToBuffCompress(
+ comp_buf->buf,
+ &worklen2,
+ (char *)slp->tblock[0],
+ writesize,
+ compressed,
+ 0, 30);
+ worklen = worklen2;
+ if (compresult == BZ_OK)
+ compresult = 1;
+ else
+ compresult = 0;
+ }
+
+#endif /* HAVE_BZLIB */
+ if (compresult && worklen <= (writesize - 16)) {
/* write the compressed buffer */
comp_buf->length = worklen;
comp_buf->compressed = 1;
}
/* compress the remaining blocks if we're compressing */
do_compress = compressed;
-#endif /* HAVE_ZLIB */
+#endif /* HAVE_ZLIB || HAVE_BZLIB */
if (sigsetjmp(jmpbuf, 1) == 0) {
ready = 1;
-# $Id: Makefile.in,v 1.8 2001/04/12 16:03:30 stelian Exp $
+# $Id: Makefile.in,v 1.9 2001/08/16 15:24:21 stelian Exp $
top_srcdir= @top_srcdir@
srcdir= @srcdir@
CFLAGS= @CCOPTS@ -pipe $(OPT) $(DEFS) $(GINC) $(INC) @RESTOREDEBUG@
LDFLAGS:= $(LDFLAGS) @STATIC@
-LIBS= $(GLIBS) -le2p @READLINE@ @ZLIB@
+LIBS= $(GLIBS) -le2p @READLINE@ @ZLIB@ @BZLIB@
DEPLIBS= ../compat/lib/libcompat.a
PROG= restore
#ifndef lint
static const char rcsid[] =
- "$Id: tape.c,v 1.45 2001/07/20 09:01:46 stelian Exp $";
+ "$Id: tape.c,v 1.46 2001/08/16 15:24:22 stelian Exp $";
#endif /* not lint */
#include <config.h>
#include <zlib.h>
#endif /* HAVE_ZLIB */
+#ifdef HAVE_BZLIB
+#include <bzlib.h>
+#endif /* HAVE_BZLIB */
+
#include "restore.h"
#include "extern.h"
#include "pathnames.h"
static char *tapebuf; /* input buffer for read */
static int bufsize; /* buffer size without prefix */
static char *tbufptr = NULL; /* active tape buffer */
-#ifdef HAVE_ZLIB
+#if defined(HAVE_ZLIB) || defined(HAVE_BZLIB)
static char *comprbuf; /* uncompress work buf */
static size_t comprlen; /* size including prefix */
#endif
static void xtrskip __P((char *, size_t));
static void setmagtapein __P((void));
-#ifdef HAVE_ZLIB
+#if defined(HAVE_ZLIB) || defined(HAVE_BZLIB)
static void newcomprbuf __P((int));
static void readtape_set __P((char *));
static void readtape_uncompr __P((char *));
tapebufsize = size;
}
-#ifdef HAVE_ZLIB
+#if defined(HAVE_ZLIB) || defined(HAVE_BZLIB)
static void
newcomprbuf(int size)
{
if (comprbuf == NULL)
errx(1, "Cannot allocate space for decompress buffer");
}
-#endif /* HAVE_ZLIB */
+#endif /* HAVE_ZLIB || HAVE_BZLIB */
/*
* Verify that the tape drive can be accessed and
if (zflag) {
fprintf(stderr, "Dump tape is compressed.\n");
-#ifdef HAVE_ZLIB
+#if defined(HAVE_ZLIB) || defined(HAVE_BZLIB)
newcomprbuf(ntrec);
#else
errx(1,"This restore version doesn't support decompression");
/* NOTREACHED */
}
-#ifdef HAVE_ZLIB
+#if defined(HAVE_ZLIB) || defined(HAVE_BZLIB)
static void (*readtape_func)(char *) = readtape_set;
/*
readtape(buf);
}
-#endif /* HAVE_ZLIB */
+#endif /* HAVE_ZLIB || HAVE_BZLIB */
/*
* This is the original readtape(), it's used for reading uncompressed input.
* Handle read errors, and end of media.
*/
static void
-#ifdef HAVE_ZLIB
+#if defined(HAVE_ZLIB) || defined(HAVE_BZLIB)
readtape_uncompr(char *buf)
#else
readtape(char *buf)
tpblksread++;
}
-#ifdef HAVE_ZLIB
+#if defined(HAVE_ZLIB) || defined(HAVE_BZLIB)
/*
* Read a compressed format block from a file or pipe and uncompress it.
/* zflag gets set in setup() from the dump header */
int cresult, blocklen;
unsigned long worklen;
+#ifdef HAVE_BZLIB
+ unsigned int worklen2;
+#endif
char *output = NULL,*reason = NULL, *lengtherr = NULL;
/* build a length error message */
lengtherr = "long";
worklen = comprlen;
- cresult = Z_OK;
+ cresult = 1;
if (tpbin->compressed) {
/* uncompress whatever we read, if it fails, complain later */
- cresult = uncompress(comprbuf, &worklen, tpbin->buf, blocklen);
- output = comprbuf;
+ if (tpbin->flags == COMPRESS_ZLIB) {
+#ifndef HAVE_ZLIB
+ errx(1,"This restore version doesn't support zlib decompression");
+#else
+ cresult = uncompress(comprbuf, &worklen,
+ tpbin->buf, blocklen);
+ output = comprbuf;
+ switch (cresult) {
+ case Z_OK:
+ break;
+ case Z_MEM_ERROR:
+ reason = "not enough memory";
+ break;
+ case Z_BUF_ERROR:
+ reason = "buffer too small";
+ break;
+ case Z_DATA_ERROR:
+ reason = "data error";
+ break;
+ default:
+ reason = "unknown";
+ }
+ if (cresult == Z_OK)
+ cresult = 1;
+ else
+ cresult = 0;
+#endif /* HAVE_ZLIB */
+ }
+ if (tpbin->flags == COMPRESS_BZLIB) {
+#ifndef HAVE_BZLIB
+ errx(1,"This restore version doesn't support bzlib decompression");
+#else
+ worklen2 = worklen;
+ cresult = BZ2_bzBuffToBuffDecompress(
+ comprbuf, &worklen2,
+ tpbin->buf, blocklen, 0, 0);
+ worklen = worklen2;
+ output = comprbuf;
+ switch (cresult) {
+ case BZ_OK:
+ break;
+ case BZ_MEM_ERROR:
+ reason = "not enough memory";
+ break;
+ case BZ_OUTBUFF_FULL:
+ reason = "buffer too small";
+ break;
+ case BZ_DATA_ERROR:
+ case BZ_DATA_ERROR_MAGIC:
+ case BZ_UNEXPECTED_EOF:
+ reason = "data error";
+ break;
+ default:
+ reason = "unknown";
+ }
+ if (cresult == BZ_OK)
+ cresult = 1;
+ else
+ cresult = 0;
+#endif /* HAVE_BZLIB */
+ }
}
else {
output = tpbin->buf;
worklen = blocklen;
}
- switch (cresult) {
- case Z_OK:
- numtrec = worklen / TP_BSIZE;
- if (worklen % TP_BSIZE != 0)
- reason = "length mismatch";
- break;
- case Z_MEM_ERROR:
- reason = "not enough memory";
- break;
- case Z_BUF_ERROR:
- reason = "buffer too small";
- break;
- case Z_DATA_ERROR:
- reason = "data error";
- break;
- default:
- reason = "unknown";
- } /*switch */
+ if (cresult) {
+ numtrec = worklen / TP_BSIZE;
+ if (worklen % TP_BSIZE != 0)
+ reason = "length mismatch";
+ }
if (reason) {
if (lengtherr)
fprintf(stderr, "%s compressed block: %d expected: %d\n",
lengtherr, readsize, tpbin->length + PREFIXSIZE);
fprintf(stderr, "decompression error, block %ld: %s\n",
tpblksread+1, reason);
- if (cresult != Z_OK) output = NULL;
+ if (!cresult)
+ output = NULL;
}
return output;
}
break;
}
}
-#endif /* HAVE_ZLIB */
+#endif /* HAVE_ZLIB || HAVE_BZLIB */
/*
* Read the first block and get the blocksize from it. Test