diff -rupN partimage-0.6.7/README.lzo partimage-0.6.7-lzo/README.lzo --- partimage-0.6.7/README.lzo 1970-01-01 01:00:00.000000000 +0100 +++ partimage-0.6.7-lzo/README.lzo 2008-10-27 11:09:55.309870249 +0100 @@ -0,0 +1,20 @@ + + Partition Image LZO-PATCH + ------------------- + copyright : (C) 2008 by Max Bidlingmaier + +AUTHOR: Max Bidlingmaier +Contact: mbidlingmaier at esigma dash technology dot com + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +at your option) any later version. + +This Patch enables LZO-compression for Partition Image. LZO is about 3-4 times faster +than gzip at the cost of some compression ration (http://www.oberhumer.com/opensource/lzo/) + +To use LZO-compression apply the patch and use configure with --enable-lzo, additional tags are +--with-lzo-headers and --with-lzo-lib if configure is unable to find headers and libs + +This Patch is against Partimage 0.6.7 diff -rupN partimage-0.6.7/config.h.in partimage-0.6.7-lzo/config.h.in --- partimage-0.6.7/config.h.in 2008-02-03 23:00:35.000000000 +0100 +++ partimage-0.6.7-lzo/config.h.in 2008-10-27 11:04:05.337880024 +0100 @@ -148,6 +148,11 @@ /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H +/* { { echo "$as_me:$LINENO: error: Define to 1 if LZO is enabled" >&5 echo + "$as_me: error: Define to 1 if LZO is enabled" >&2;} { (exit 1); exit 1; }; + } */ +#undef LZO_ENABLED + /* Define to 1 if you want partimaged to drop privilieges on start */ #undef MUST_CHEUID diff -rupN partimage-0.6.7/configure partimage-0.6.7-lzo/configure --- partimage-0.6.7/configure 2008-02-03 23:00:33.000000000 +0100 +++ partimage-0.6.7-lzo/configure 2008-10-27 11:31:06.761652529 +0100 @@ -1,7 +1,7 @@ #! /bin/sh # From configure.ac Revision: 1.4 . # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.61 for partimage 0.6.7. +# Generated by GNU Autoconf 2.61 for partimage 0.6.7-lzo. # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. @@ -727,8 +727,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='partimage' PACKAGE_TARNAME='partimage' -PACKAGE_VERSION='0.6.7' -PACKAGE_STRING='partimage 0.6.7' +PACKAGE_VERSION='0.6.7-lzo' +PACKAGE_STRING='partimage 0.6.7-lzo' PACKAGE_BUGREPORT='' # Factoring default headers for most tests. @@ -1412,7 +1412,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures partimage 0.6.7 to adapt to many kinds of systems. +\`configure' configures partimage 0.6.7-lzo to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1483,7 +1483,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of partimage 0.6.7:";; + short | recursive ) echo "Configuration of partimage 0.6.7-lzo:";; esac cat <<\_ACEOF @@ -1502,6 +1502,7 @@ Optional Features: --disable-largefile omit support for large files --enable-efence Enable linking with libefence Memory Debugger --disable-ssl Don't compile ssl mode +--enable-lzo Enable LZO-Compression --enable-devel Enable developpers options (debug, ...) --enable-pam Enable PAM to authenticate users --enable-all-static build static binaries @@ -1522,6 +1523,8 @@ Optional Packages: --with-tags[=TAGS] include additional configurations [automatic] --with-ssl-headers=DIR SSL Include files location --with-ssl-lib=DIR SSL Library location +--with-lzo-headers=DIR LZO Include files location +--with-lzo-lib=DIR LZO Library location --with-slang-headers=DIR SLang Include files location --with-log-dir=PATH logfiles /var/log --with-debug-level=X default debut level used to write the debug logfile 1 @@ -1604,7 +1607,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -partimage configure 0.6.7 +partimage configure 0.6.7-lzo generated by GNU Autoconf 2.61 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1618,7 +1621,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by partimage $as_me 0.6.7, which was +It was created by partimage $as_me 0.6.7-lzo, which was generated by GNU Autoconf 2.61. Invocation command line was $ $0 $@ @@ -2436,7 +2439,7 @@ fi # Define the identity of the package. PACKAGE='partimage' - VERSION='0.6.7' + VERSION='0.6.7-lzo' cat >>confdefs.h <<_ACEOF @@ -6272,7 +6275,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 6275 "configure"' > conftest.$ac_ext + echo '#line 6278 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -9070,11 +9073,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:9073: $lt_compile\"" >&5) + (eval echo "\"\$as_me:9076: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:9077: \$? = $ac_status" >&5 + echo "$as_me:9080: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -9360,11 +9363,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:9363: $lt_compile\"" >&5) + (eval echo "\"\$as_me:9366: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:9367: \$? = $ac_status" >&5 + echo "$as_me:9370: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -9464,11 +9467,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:9467: $lt_compile\"" >&5) + (eval echo "\"\$as_me:9470: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:9471: \$? = $ac_status" >&5 + echo "$as_me:9474: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -11826,7 +11829,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:14352: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:14353: \$? = $ac_status" >&5 + echo "$as_me:14356: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -14450,11 +14453,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14453: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14456: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:14457: \$? = $ac_status" >&5 + echo "$as_me:14460: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -16025,11 +16028,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16028: $lt_compile\"" >&5) + (eval echo "\"\$as_me:16031: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:16032: \$? = $ac_status" >&5 + echo "$as_me:16035: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -16129,11 +16132,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16132: $lt_compile\"" >&5) + (eval echo "\"\$as_me:16135: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:16136: \$? = $ac_status" >&5 + echo "$as_me:16139: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -18329,11 +18332,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:18332: $lt_compile\"" >&5) + (eval echo "\"\$as_me:18335: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:18336: \$? = $ac_status" >&5 + echo "$as_me:18339: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -18619,11 +18622,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:18622: $lt_compile\"" >&5) + (eval echo "\"\$as_me:18625: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:18626: \$? = $ac_status" >&5 + echo "$as_me:18629: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -18723,11 +18726,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:18726: $lt_compile\"" >&5) + (eval echo "\"\$as_me:18729: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:18730: \$? = $ac_status" >&5 + echo "$as_me:18733: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -24841,6 +24844,33 @@ if test "${with_ssl_lib+set}" = set; the fi +#lzo enabled +# Check whether --enable-lzo was given. +if test "${enable_lzo+set}" = set; then + enableval=$enable_lzo; LZO=$enableval +else + LZO=no + +fi + + + +# Check whether --with-lzo-headers was given. +if test "${with_lzo_headers+set}" = set; then + withval=$with_lzo_headers; LZO_HDR_DIR="$withval" + CPPFLAGS="$CPPFLAGS -I$withval" + +fi + + + +# Check whether --with-lzo-lib was given. +if test "${with_lzo_lib+set}" = set; then + withval=$with_lzo_lib; LIBS="$LIBS -L$withval" + +fi + + # Check whether --with-slang-headers was given. if test "${with_slang_headers+set}" = set; then @@ -28793,6 +28823,128 @@ echo "$as_me: error: SSL Headers not fo fi +if test "$LZO" = "yes"; then + + { echo "$as_me:$LINENO: result: " >&5 +echo "${ECHO_T}" >&6; } + { echo "$as_me:$LINENO: checking for LZO Library Header files ... ..." >&5 +echo "$as_me: checking for LZO Library Header files ... ..." >&6;} + + { echo "$as_me:$LINENO: checking \"for lzo1x.h lzoconf.h\"" >&5 +echo $ECHO_N "checking \"for lzo1x.h lzoconf.h\"... $ECHO_C" >&6; } + ac_hdr_found=no + for p in $LZO_HDR_DIR /usr/include /usr/include/lzo; do + + ac_file_found=yes + for f in lzo1x.h lzoconf.h; do + if test ! -f $p/$f; then + ac_file_found=no + break; + fi + done + + if test "$ac_file_found" = "yes" ; then + + ac_hdr_found=yes + break + + + else + : + fi + + done + if test "$ac_hdr_found" = "yes" ; then + CPPFLAGS="$CPPFLAGS -I$p" + { echo "$as_me:$LINENO: result: ($p) yes " >&5 +echo "${ECHO_T}($p) yes " >&6; } + { echo "$as_me:$LINENO: checking for lzo1x_1_compress in -llzo" >&5 +echo $ECHO_N "checking for lzo1x_1_compress in -llzo... $ECHO_C" >&6; } +if test "${ac_cv_lib_lzo_lzo1x_1_compress+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-llzo $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char lzo1x_1_compress (); +int +main () +{ +return lzo1x_1_compress (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_lib_lzo_lzo1x_1_compress=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_lzo_lzo1x_1_compress=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_lzo_lzo1x_1_compress" >&5 +echo "${ECHO_T}$ac_cv_lib_lzo_lzo1x_1_compress" >&6; } +if test $ac_cv_lib_lzo_lzo1x_1_compress = yes; then + LIBS="$LIBS -llzo" +else + { { echo "$as_me:$LINENO: error: Required for LZO Compression Library not found. " >&5 +echo "$as_me: error: Required for LZO Compression Library not found. " >&2;} + { (exit 1); exit 1; }; } + +fi + + + else + { echo "$as_me:$LINENO: result: \"no\"" >&5 +echo "${ECHO_T}\"no\"" >&6; } + { { echo "$as_me:$LINENO: error: LZO Headers not found. " >&5 +echo "$as_me: error: LZO Headers not found. " >&2;} + { (exit 1); exit 1; }; } + + fi + + +cat >>confdefs.h <<\_ACEOF +#define LZO_ENABLED 1 +_ACEOF + +fi + # Check whether --enable-login was given. if test "${enable_login+set}" = set; then enableval=$enable_login; @@ -29358,7 +29510,7 @@ exec 6>&1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by partimage $as_me 0.6.7, which was +This file was extended by partimage $as_me 0.6.7-lzo, which was generated by GNU Autoconf 2.61. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -29411,7 +29563,7 @@ Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -partimage config.status 0.6.7 +partimage config.status 0.6.7-lzo configured by $0, generated by GNU Autoconf 2.61, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" diff -rupN partimage-0.6.7/configure.ac partimage-0.6.7-lzo/configure.ac --- partimage-0.6.7/configure.ac 2008-02-03 22:58:11.000000000 +0100 +++ partimage-0.6.7-lzo/configure.ac 2008-10-27 11:02:59.400621168 +0100 @@ -8,7 +8,7 @@ AC_REVISION([[$Revision: 1.4 $]]) AC_PREREQ(2.59c) -AC_INIT([partimage], [0.6.7]) +AC_INIT([partimage], [0.6.7-lzo]) AC_CANONICAL_SYSTEM AC_CONFIG_MACRO_DIR([m4]) @@ -136,6 +136,24 @@ AC_ARG_WITH(ssl-lib, LIBS="$LIBS -L$withval" ) +#lzo enabled +AC_ARG_ENABLE(lzo, + [--enable-lzo Enable LZO-Compression], + LZO=$enableval, + LZO=no +) + +AC_ARG_WITH(lzo-headers, + [--with-lzo-headers=DIR LZO Include files location], + LZO_HDR_DIR="$withval" + CPPFLAGS="$CPPFLAGS -I$withval" +) + +AC_ARG_WITH(lzo-lib, + [--with-lzo-lib=DIR LZO Library location], + LIBS="$LIBS -L$withval" +) + dnl SLang location AC_ARG_WITH(slang-headers, [--with-slang-headers=DIR SLang Include files location], @@ -253,6 +271,21 @@ if test "$SSL" = "yes"; then ) fi +if test "$LZO" = "yes"; then + + AC_MSG_RESULT() + AC_CHECKING([ for LZO Library Header files ... ]) + AC_SEARCH_HEADERS(lzo1x.h lzoconf.h, $LZO_HDR_DIR /usr/include /usr/include/lzo, + [ AC_CHECK_LIB(lzo, lzo1x_1_compress, [LIBS="$LIBS -llzo"], + AC_MSG_ERROR([ Required for LZO Compression Library not found. ]) + ) + ], + AC_MSG_ERROR([ LZO Headers not found. ]) + ) + AC_DEFINE([LZO_ENABLED], 1, + AC_MSG_ERROR([Define to 1 if LZO is enabled])) +fi + dnl Client must login. dnl Don't remove the comma, it's required. AC_ARG_ENABLE(login, diff -rupN partimage-0.6.7/src/client/gui_text.cpp partimage-0.6.7-lzo/src/client/gui_text.cpp --- partimage-0.6.7/src/client/gui_text.cpp 2008-02-03 22:58:00.000000000 +0100 +++ partimage-0.6.7-lzo/src/client/gui_text.cpp 2008-10-27 10:46:55.553620502 +0100 @@ -332,6 +332,9 @@ int CSaveOptWindow::create(char *szImage m_radioCompNone = newtRadiobutton(1, 2, i18n("None (very fast + very big file)"), options.dwCompression == COMPRESS_NONE, NULL); m_radioCompGzip = newtRadiobutton(1, 3, "Gzip (.gz: medium speed + small image file)", options.dwCompression == COMPRESS_GZIP, m_radioCompNone); m_radioCompBzip2 = newtRadiobutton(1, 4, "Bzip2 (.bz2: very slow + very small image file)", options.dwCompression == COMPRESS_BZIP2, m_radioCompGzip); +#ifdef LZO_ENABLED + m_radioCompLzo = newtRadiobutton(1, 5, "LZO (.lzo: fast + not to small)", options.dwCompression == COMPRESS_LZO, m_radioCompBzip2); +#endif m_labelOptions = newtLabel(1, 7, i18n("Options")); m_checkCheckBeforeSaving = newtCheckbox(1, 8, i18n("Check partition before saving"), (!!options.bCheckBeforeSaving ? 'X' : ' '), " X", NULL); @@ -357,7 +360,7 @@ int CSaveOptWindow::create(char *szImage m_formMain = newtForm(NULL, NULL, 0); newtFormAddComponents(m_formMain, m_labelCompression, m_labelOptions, m_labelSplit, NULL); - newtFormAddComponents(m_formMain, m_radioCompNone, m_radioCompGzip, m_radioCompBzip2, m_checkCheckBeforeSaving, m_checkAskDesc, m_checkOverwrite, NULL); + newtFormAddComponents(m_formMain, m_radioCompNone, m_radioCompGzip, m_radioCompBzip2, m_radioCompLzo, m_checkCheckBeforeSaving, m_checkAskDesc, m_checkOverwrite, NULL); newtFormAddComponents(m_formMain, m_labelFinish, m_radioFinishWait, m_radioFinishHalt, m_radioFinishReboot, m_radioFinishQuit, m_radioFinishLast, NULL); newtFormAddComponents(m_formMain, m_radioSplitAuto, m_radioSplitSize, m_labelSplitSizeKB, m_editSplitSize, m_checkSplitWait, NULL); addHotKeys(); @@ -384,6 +387,10 @@ int CSaveOptWindow::getValues(COptions * options->dwCompression = COMPRESS_GZIP; else if (newtRadioGetCurrent(m_radioCompNone) == m_radioCompBzip2) options->dwCompression = COMPRESS_BZIP2; +#ifdef LZO_ENABLED + else if (newtRadioGetCurrent(m_radioCompNone) == m_radioCompLzo) + options->dwCompression = COMPRESS_LZO; +#endif // get finish level if (newtRadioGetCurrent(m_radioFinishWait) == m_radioFinishWait) @@ -485,9 +492,11 @@ int CSavingWindow::create(const char *sz case COMPRESS_BZIP2: SNPRINTF(szTemp, i18n("Compression level:...........bzip2")); break; +#ifdef LZO_ENABLED case COMPRESS_LZO: SNPRINTF(szTemp, i18n("Compression level:...........lzo")); break; +#endif } m_labelCompression = newtLabel(1, 6, szTemp); @@ -898,10 +907,12 @@ void CRestoringWindow::showImageFileInfo SNPRINTF(szTemp, i18n("Compression level:................bzip2")); SNPRINTF(szTemp2, i18n("bzip2")); break; +#ifdef LZO_ENABLED case COMPRESS_LZO: SNPRINTF(szTemp, i18n("Compression level:................lzo")); SNPRINTF(szTemp2, i18n("lzo")); break; +#endif default: memset(szTemp2, 0, sizeof(szTemp2)); SNPRINTF(szTemp3, i18n("Compression level:................%s"),szTemp2); diff -rupN partimage-0.6.7/src/client/gui_text.h partimage-0.6.7-lzo/src/client/gui_text.h --- partimage-0.6.7/src/client/gui_text.h 2008-02-03 22:58:00.000000000 +0100 +++ partimage-0.6.7-lzo/src/client/gui_text.h 2008-10-23 16:41:15.648872412 +0200 @@ -77,7 +77,7 @@ class CSaveOptWindow: public COptionsWin private: //newtComponent m_formMain; newtComponent m_labelCompression, m_labelOptions, m_labelSplit; - newtComponent m_radioCompNone, m_radioCompLzop, m_radioCompGzip, m_radioCompBzip2; + newtComponent m_radioCompNone, m_radioCompLzop, m_radioCompGzip, m_radioCompBzip2, m_radioCompLzo; newtComponent m_radioSplitSize, m_labelSplitSizeKB, m_radioSplitAuto; newtComponent m_checkCheckBeforeSaving, m_checkAskDesc, m_checkOverwrite; newtComponent m_editSplitSize, m_checkSplitWait; diff -rupN partimage-0.6.7/src/client/imagefile.cpp partimage-0.6.7-lzo/src/client/imagefile.cpp --- partimage-0.6.7/src/client/imagefile.cpp 2008-02-03 22:58:00.000000000 +0100 +++ partimage-0.6.7-lzo/src/client/imagefile.cpp 2008-10-27 10:50:34.646661936 +0100 @@ -43,6 +43,10 @@ #include // gzip compression #include // bzip2 compression +#ifdef LZO_ENABLED + #include // lzo compression + #include +#endif CParam g_param; @@ -129,6 +133,7 @@ CImage::CImage(COptions * options) m_fImageFile = NULL; m_gzImageFile = NULL; m_bzImageFile = NULL; + m_lzoImageFile = NULL; RETURN; } @@ -274,6 +279,75 @@ void CImage::writeSplit() RETURN; } +#ifdef LZO_ENABLED +lzo_uint CImage::xread(FILE *f, lzo_voidp buf, lzo_uint len, lzo_bool allow_eof) +{ + lzo_uint l; + + l = lzo_fread(f,buf,len); + if (l > len) + { + fprintf(stderr,"\nsomething's wrong with your C library !!!\n"); + exit(1); + } + if (l != len && !allow_eof) + { + fprintf(stderr,"\nread error - premature end of file\n"); + exit(1); + } + return l; +} + +lzo_uint CImage::xwrite(FILE *f, const lzo_voidp buf, lzo_uint len) +{ + if (f != NULL && lzo_fwrite(f,buf,len) != len) + { + fprintf(stderr,"\nwrite error (disk full ?)\n"); + exit(1); + } + return len; +} + + +int CImage::xgetc(FILE *f) +{ + unsigned char c; + xread(f,(lzo_bytep) &c,1,0); + return c; +} + +void CImage::xputc(FILE *f, int c) +{ + unsigned char cc = (unsigned char) c; + xwrite(f,(lzo_bytep) &cc,1); +} + +/* read and write portable 32-bit integers */ + +lzo_uint32 CImage::xread32(FILE *f) +{ + unsigned char b[4]; + lzo_uint32 v; + + xread(f,b,4,0); + v = (lzo_uint32) b[3] << 0; + v |= (lzo_uint32) b[2] << 8; + v |= (lzo_uint32) b[1] << 16; + v |= (lzo_uint32) b[0] << 24; + return v; +} + +void CImage::xwrite32(FILE *f, lzo_uint32 v) +{ + unsigned char b[4]; + + b[3] = (unsigned char) (v >> 0); + b[2] = (unsigned char) (v >> 8); + b[1] = (unsigned char) (v >> 16); + b[0] = (unsigned char) (v >> 24); + xwrite(f,b,4); +} +#endif // ======================================================= void CImage::write(void *vBuf, DWORD dwLength, bool bUpdateCRC) @@ -283,6 +357,12 @@ void CImage::write(void *vBuf, DWORD dwL QWORD qwFreeSpace; //, qwCurrentSize; char *cBuf; DWORD dwRes; + DWORD outLen; +#ifdef LZO_ENABLED + lzo_byte *outBuf; + lzo_byte *cLzoBuffer; +#endif + int nRes; BEGIN; @@ -341,6 +421,36 @@ void CImage::write(void *vBuf, DWORD dwL dwRes = (DWORD) gzwrite(m_gzImageFile, cBuf, dwLength); else if (m_options.dwCompression == COMPRESS_BZIP2) dwRes = (DWORD) BZ2_bzwrite(m_bzImageFile, cBuf, dwLength); +#ifdef LZO_ENABLED + else if (m_options.dwCompression == COMPRESS_LZO) + { + outBuf = (lzo_bytep) lzo_malloc(dwLength + dwLength / 64 + 16 + 3); + cLzoBuffer = (lzo_bytep) lzo_malloc(LZO1X_1_MEM_COMPRESS); + checksum = lzo_adler32(checksum, (BYTE*)cBuf, dwLength); + + nRes = lzo1x_1_compress((BYTE*)cBuf, dwLength, outBuf, &outLen, cLzoBuffer); + if (nRes != LZO_E_OK) + showDebug(1, "ERROR: Compress LZO failed"); + else + dwRes = dwLength; + //write uncompressed blocksize + xwrite32(m_lzoImageFile, dwLength); + if (outLen < dwLength) + { + //write compressed block + xwrite32(m_lzoImageFile, outLen); //blocklength + xwrite(m_lzoImageFile, outBuf, outLen); //write block + } + else + { + //uncompressible, write original block + xwrite32(m_lzoImageFile, dwLength); //blocklength + xwrite(m_lzoImageFile, (BYTE*)cBuf, dwLength); //write block + } + lzo_free(outBuf); + lzo_free(cLzoBuffer); + } +#endif else THROW(ERR_COMP); @@ -381,6 +491,13 @@ void CImage::read(char *cBuf, DWORD dwLe static QWORD qwCount = 0LL; DWORD dwRes; int nRes; +#ifdef LZO_ENABLED + int lzoErr; + DWORD unClen; + lzo_byte *outBuf; +#endif + + DWORD outLen; if (dwLength != 1) // avoid having BUFFER_BLOCK_SIZE messages with imginfo and restmbr showDebug(4, "begin of ci::read: size=%lu, pos=%lld\n", dwLength, qwTotalBytes); @@ -391,6 +508,42 @@ void CImage::read(char *cBuf, DWORD dwLe nRes = gzread(m_gzImageFile, cBuf, dwLength); else if (m_options.dwCompression == COMPRESS_BZIP2) nRes = BZ2_bzread(m_bzImageFile, cBuf, dwLength); +#ifdef LZO_ENABLED + else if (m_options.dwCompression == COMPRESS_LZO) + { + lzo_uint unCSize; + lzo_uint coCSize; + unCSize = xread32(m_lzoImageFile); // read uncompressed size + if (unCSize == 0){ + showDebug(3, "GOT LZO END OF FILE MARK"); + nRes = 0; + g_nThreadState = THREAD_EOF; + } + else + { + coCSize = xread32(m_lzoImageFile); //read compressed size + outBuf = (lzo_bytep) lzo_malloc(coCSize + 16); + xread(m_lzoImageFile, outBuf, coCSize, 0); // read block + if (coCSize < unCSize) //block has been compressed + { + lzo_uint new_len = unCSize; + lzoErr = lzo1x_decompress(outBuf, nRes, (BYTE*)cBuf, &unClen, NULL); + if (lzoErr != LZO_E_OK) + showDebug(3, "ERROR with demcompression %d", lzoErr); + checksum = lzo_adler32(checksum,(BYTE*)cBuf,unClen); + } + else + { //block has been incompressible + memcpy((BYTE*)cBuf, outBuf, unCSize); + unClen = unCSize; + checksum = lzo_adler32(checksum,(BYTE*)cBuf,unClen); + } + + nRes = unClen; + lzo_free(outBuf); + } + } +#endif else THROW(ERR_COMP); @@ -423,7 +576,7 @@ void CImage::read(char *cBuf, DWORD dwLe read(cBuf+dwFirstRead, dwLength-dwFirstRead, bUpdateCRC); m_guiRestore -> showImageFileInfo(get_szImageFilename(), m_options.dwCompression, m_options.szFullyBatchMode); } - else if ((g_nThreadState == THREAD_ASKEXIT) || (g_nThreadState == THREAD_FINISHED) ) + else if ((g_nThreadState == THREAD_ASKEXIT) || (g_nThreadState == THREAD_FINISHED)) { showDebug(1, "READ ERROR 2: dwLength=%lu and dwRes=%lu and g_nThreadState=%d\n", dwLength, dwRes, g_nThreadState); } @@ -573,6 +726,20 @@ void CImage::closeReading(bool bForceExi } else if (m_options.dwCompression == COMPRESS_BZIP2) // Bzip2 compression BZ2_bzclose(m_bzImageFile); +#ifdef LZO_ENABLED + else if (m_options.dwCompression == COMPRESS_LZO) // LZO compression + { + lzo_uint32 cSumInFile; + cSumInFile = xread32(m_lzoImageFile); //read EOF-Mark or checksum + if (cSumInFile == 0) //if eof mark has been read, read checksum + cSumInFile = xread32(m_lzoImageFile); //read checksum + if (checksum == cSumInFile) + showDebug(1, "Checksum verified OK"); + else + showDebug(1, "Checksum verified NOT OK"); + nRes = fclose(m_lzoImageFile); + } +#endif if (nRes) THROW(ERR_ERRNO, errno); @@ -604,6 +771,15 @@ void CImage::closeWriting() nRes = gzclose(m_gzImageFile); else if (m_options.dwCompression == COMPRESS_BZIP2) // Bzip2 compression BZ2_bzclose(m_bzImageFile); +#ifdef LZO_ENABLED + else if (m_options.dwCompression == COMPRESS_LZO) // LZO Compression + { + xwrite32(m_lzoImageFile, 0); //write eof marker + xwrite32(m_lzoImageFile, checksum); // write checksum + nRes = fclose(m_lzoImageFile); + } +#endif + if (nRes) THROW(ERR_ERRNO, errno); @@ -793,6 +969,27 @@ void CImage::openWriting() THROW(ERR_ERRNO, errno); } } +#ifdef LZO_ENABLED + else if (m_options.dwCompression == COMPRESS_LZO) // LZO compression + { + showDebug(1, "open lzo\n"); + m_lzoImageFile = fdopen(m_nFdImage, "wb"); + if (m_lzoImageFile == NULL) + { + showDebug(1, "error:%d %s\n", errno, strerror(errno)); + THROW(ERR_ERRNO, errno); + } + //write magic + static const unsigned char magic[7] = + { 0x00, 0xe9, 0x4c, 0x5a, 0x4f, 0xff, 0x1a }; + xwrite(m_lzoImageFile, magic, sizeof(magic)); + xwrite32(m_lzoImageFile, 1); //flags + xputc(m_lzoImageFile, 0x1); //method + xputc(m_lzoImageFile, 1); //comp level + xwrite32(m_lzoImageFile, (256*1024L)); //blocksize + checksum = lzo_adler32(0,NULL,0); + } +#endif else THROW(ERR_COMP); @@ -976,6 +1173,45 @@ void CImage::readAndCheckMagic(char *szM showDebug(2, "end of ci::readAndCheckMagic: ok\n"); } +#ifdef LZO_ENABLED +//try to read LZO header, retrun true if it ist LZO +bool CImage::readLZOHead() +{ + static const unsigned char magic[7] = + { 0x00, 0xe9, 0x4c, 0x5a, 0x4f, 0xff, 0x1a }; + unsigned char m [ sizeof(magic) ]; + if (xread(m_lzoImageFile, m, sizeof(magic), 1) != sizeof(magic) || + memcmp(m, magic, sizeof(magic)) != 0) + { + showDebug(3, "No LZO magic found"); + return false; + } + + lzo_uint32 tmp; + //read rest of header, information not needed now + tmp = xread32(m_lzoImageFile); //flags always 1 + tmp = xgetc(m_lzoImageFile); //method always 1 + tmp = xgetc(m_lzoImageFile); // level always 1, if not something is wrong + if (tmp != 1) + { + showDebug(4, "Unknown LZO-Level: %d", tmp); + return false; + } + + tmp = xread32(m_lzoImageFile); //blocksize + if (tmp < 1024 || tmp > 1024*1024L) + { + showDebug(3,"Unknown Blocksize: %d", tmp); + return false; + } + + //init checksum + checksum = lzo_adler32(0,NULL,0); + + return true; +}//readLZOHead +#endif + // ======================================================= // may throw canceled // may throw opened, errno, comp (from cid) @@ -1105,6 +1341,25 @@ void CImage::openReading(CVolumeHeader * else showDebug(1, "bzip2 open\n"); } + else if (m_options.dwCompression == COMPRESS_LZO) // lzo compression + { +#ifdef LZO_ENABLED + m_lzoImageFile = fdopen(m_nFdImage, "rb"); + if (m_lzoImageFile == NULL) + THROW(ERR_ERRNO, errno); + else + showDebug(1, "lzo open\n"); + readLZOHead(); + if (lzo_init() != LZO_E_OK) + { + showDebug(1, "LZO init failed"); + THROW (errno); + } +#else + showDebug(1, "NO LZO support, but this is an LZO compressed image"); + THROW (1); +#endif + } else THROW(ERR_COMP); diff -rupN partimage-0.6.7/src/client/imagefile.h partimage-0.6.7-lzo/src/client/imagefile.h --- partimage-0.6.7/src/client/imagefile.h 2008-02-03 22:58:00.000000000 +0100 +++ partimage-0.6.7-lzo/src/client/imagefile.h 2008-10-27 10:38:56.832796068 +0100 @@ -43,6 +43,7 @@ class CImage FILE *m_fImageFile; gzFile *m_gzImageFile; BZFILE *m_bzImageFile; + FILE *m_lzoImageFile; int m_nFdImage; @@ -51,6 +52,10 @@ class CImage char m_szMountDevice[MAXPATHLEN]; char m_szMountPoint[MAXPATHLEN]; char m_szMountFS[MAXPATHLEN]; +#ifdef LZO_ENABLED + lzo_uint32 checksum; + bool readLZOHead(); +#endif public: CImage(COptions * options); @@ -93,6 +98,15 @@ class CImage void closeReading(bool bForceExit = false); void closeWriting(); +#ifdef LZO_ENABLED + lzo_uint xread(FILE *f, lzo_voidp buf, lzo_uint len, lzo_bool allow_eof); + lzo_uint xwrite(FILE *f, const lzo_voidp buf, lzo_uint len); + void xputc(FILE *f, int c); + int xgetc(FILE *f); + lzo_uint32 xread32(FILE *f); + void xwrite32(FILE *f, lzo_uint32 v); +#endif + // magic strings void readAndCheckMagic(char *szMagicString); void writeMagic(char *szMagicString); diff -rupN partimage-0.6.7/src/client/main.cpp partimage-0.6.7-lzo/src/client/main.cpp --- partimage-0.6.7/src/client/main.cpp 2008-02-03 22:58:00.000000000 +0100 +++ partimage-0.6.7-lzo/src/client/main.cpp 2008-10-27 11:00:48.065652758 +0100 @@ -257,12 +257,21 @@ int main(int argc, char *argv[]) break; case 'z': // compression level options.dwCompression = atol(optarg); +#ifdef LZO_ENABLED + if ((options.dwCompression < 0) || (options.dwCompression > 3)) + { + fprintf(stderr, i18n("Compression mode must be 0 (none), " + "1(gzip), 2(bzip2), 3(lzo)\n")); + return EXIT_FAILURE; + } +#else if ((options.dwCompression < 0) || (options.dwCompression > 2)) { fprintf(stderr, i18n("Compression mode must be 0 (none), " "1(gzip), 2(bzip2)\n")); return EXIT_FAILURE; } +#endif break; case 'f': // what to do when finished successfully ? @@ -949,6 +958,9 @@ void usage() " -z0, --compress=0 don't compress: very fast but very big image file\n" " -z1, --compress=1 compress using gzip: fast and small image file (default)\n" " -z2, --compress=2 (compress using bzip2: very slow and very small image file):\n" +#ifdef LZO_ENABLED + " -z3, --compress=3 LZO compression\n" +#endif "* -c, --nocheck don't check the partition before saving\n" "* -o, --overwrite overwrite the existing image file without confirmation\n" "* -d, --nodesc don't ask any description for the image file\n" diff -rupN partimage-0.6.7/src/client/misc.cpp partimage-0.6.7-lzo/src/client/misc.cpp --- partimage-0.6.7/src/client/misc.cpp 2008-02-03 22:58:00.000000000 +0100 +++ partimage-0.6.7-lzo/src/client/misc.cpp 2008-10-27 10:48:14.721652752 +0100 @@ -550,8 +550,10 @@ void savePartition(char *szDevice, char else if (options->dwCompression == 1) + fprintf(stderr,"partimage: status: Image type: GZIP\n"); else if (options->dwCompression == 2) fprintf(stderr,"partimage: status: Image type: BZIP2\n"); +#ifdef LZO_ENABLED else if (options->dwCompression == 3) fprintf(stderr,"partimage: status: Image type: LZO\n"); +#endif } try { image.write(&headMain, sizeof(CMainHeader), true); } catch ( CExceptions * excep ) @@ -947,6 +949,7 @@ void restorePartition(char *szDevice, ch { showDebug(3,"szFullyBatchMode=%s\n, len=%d",options->szFullyBatchMode,strlen(options->szFullyBatchMode)); options->dwCompression = (DWORD) image.getCompressionLevelForImage(szImageName); + fprintf(stderr,"Komression: %d", options->dwCompression); fprintf(stderr,"partimage: status: Partimage: %s\n", headMain.szVersion); if (options->dwCompression == 0) fprintf(stderr,"partimage: status: Image type: NONE\n"); @@ -954,8 +957,10 @@ void restorePartition(char *szDevice, ch fprintf(stderr,"partimage: status: Image type: GZIP\n"); else if (options->dwCompression == 2) fprintf(stderr,"partimage: status: Image type: BZIP2\n"); +#ifdef LZO_ENABLED else if (options->dwCompression == 3) fprintf(stderr,"partimage: status: Image type: LZO\n"); +#endif } g_interface -> StatusLine(i18n("Restoring partition from the image file...")); diff -rupN partimage-0.6.7/src/shared/common.cpp partimage-0.6.7-lzo/src/shared/common.cpp --- partimage-0.6.7/src/shared/common.cpp 2008-02-03 22:57:55.000000000 +0100 +++ partimage-0.6.7-lzo/src/shared/common.cpp 2008-10-27 11:24:30.339658393 +0100 @@ -45,6 +45,9 @@ #include // gzip compression #include // bzip2 compression +#ifdef LZO_ENABLED + #include //lzo compression +#endif #include #include "common.h" diff -rupN partimage-0.6.7/src/shared/image_disk.cpp partimage-0.6.7-lzo/src/shared/image_disk.cpp --- partimage-0.6.7/src/shared/image_disk.cpp 2008-02-03 22:57:55.000000000 +0100 +++ partimage-0.6.7-lzo/src/shared/image_disk.cpp 2008-10-24 16:34:00.007637424 +0200 @@ -319,7 +319,7 @@ int CImageDisk::getCompressionLevelForIm fclose(fImageFile); if (dwRes != 16) goto checkBzip2; - if (strncmp(cBuf+1, "LZO", 3) == 0) + if (strncmp(cBuf+2, "LZO", 3) == 0) RETURN_int(COMPRESS_LZO); showDebug(3, "TRACE_002\n"); diff -rupN partimage-0.6.7/src/shared/image_disk.h partimage-0.6.7-lzo/src/shared/image_disk.h --- partimage-0.6.7/src/shared/image_disk.h 2008-02-03 22:57:55.000000000 +0100 +++ partimage-0.6.7-lzo/src/shared/image_disk.h 2008-10-23 16:35:17.527620760 +0200 @@ -25,6 +25,7 @@ #include // gzip compression #include // bzip2 compression +#include // lzo compression #include // ================================================