Hello community, here is the log from the commit of package partclone for openSUSE:Factory checked in at 2018-12-18 14:57:23 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/partclone (Old) and /work/SRC/openSUSE:Factory/.partclone.new.28833 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "partclone" Tue Dec 18 14:57:23 2018 rev:9 rq:658172 version:0.3.12 Changes: -------- --- /work/SRC/openSUSE:Factory/partclone/partclone.changes 2017-10-19 19:33:30.821011021 +0200 +++ /work/SRC/openSUSE:Factory/.partclone.new.28833/partclone.changes 2018-12-18 14:58:00.354286374 +0100 @@ -1,0 +2,7 @@ +Fri Dec 14 17:35:21 UTC 2018 - Martin Pluskal <mplus...@suse.com> + +- Update to version 0.3.12: + * Support compressed cloned images +- Enable exfat support + +------------------------------------------------------------------- Old: ---- partclone-0.3.11.tar.gz New: ---- partclone-0.3.12.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ partclone.spec ++++++ --- /var/tmp/diff_new_pack.6QmSzz/_old 2018-12-18 14:58:00.886285569 +0100 +++ /var/tmp/diff_new_pack.6QmSzz/_new 2018-12-18 14:58:00.886285569 +0100 @@ -1,7 +1,7 @@ # # spec file for package partclone # -# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. # Copyright (c) 2012 Mariusz Fik <fi...@opensuse.org> # # All modifications and additions to the file contributed by third parties @@ -13,17 +13,17 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # Name: partclone -Version: 0.3.11 +Version: 0.3.12 Release: 0 Summary: File System Clone Utilities -License: GPL-2.0+ +License: GPL-2.0-or-later Group: System/Filesystems -Url: http://partclone.org/ +URL: http://partclone.org/ Source: https://github.com/Thomas-Tsai/partclone/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz BuildRequires: autoconf BuildRequires: automake @@ -36,6 +36,7 @@ BuildRequires: pkgconfig BuildRequires: pkgconfig(fuse) BuildRequires: pkgconfig(libntfs-3g) +BuildRequires: pkgconfig(openssl) BuildRequires: pkgconfig(uuid) %description @@ -62,7 +63,8 @@ --enable-f2fs \ --enable-nilfs2 \ --enable-minix \ - --enable-reiserfs + --enable-reiserfs \ + --enable-exfat make %{?_smp_mflags} LIBS="-lncursesw -lpthread -lfuse" %install @@ -71,7 +73,8 @@ %find_lang %{name} %files -%doc ChangeLog README.md COPYING +%license COPYING +%doc ChangeLog README.md %{_sbindir}/partclone.btrfs %{_sbindir}/partclone.chkimg %{_sbindir}/partclone.dd @@ -80,6 +83,7 @@ %{_sbindir}/partclone.ext4 %{_sbindir}/partclone.ext4dev %{_sbindir}/partclone.extfs +%{_sbindir}/partclone.exfat %{_sbindir}/partclone.f2fs %{_sbindir}/partclone.fat %{_sbindir}/partclone.fat12 @@ -100,34 +104,35 @@ %{_sbindir}/partclone.restore %{_sbindir}/partclone.vfat %{_sbindir}/partclone.xfs -%{_mandir}/man8/partclone.8%{ext_man} -%{_mandir}/man8/partclone.btrfs.8%{ext_man} -%{_mandir}/man8/partclone.chkimg.8%{ext_man} -%{_mandir}/man8/partclone.dd.8%{ext_man} -%{_mandir}/man8/partclone.ext2.8%{ext_man} -%{_mandir}/man8/partclone.ext3.8%{ext_man} -%{_mandir}/man8/partclone.ext4.8%{ext_man} -%{_mandir}/man8/partclone.ext4dev.8%{ext_man} -%{_mandir}/man8/partclone.extfs.8%{ext_man} -%{_mandir}/man8/partclone.f2fs.8%{ext_man} -%{_mandir}/man8/partclone.fat.8%{ext_man} -%{_mandir}/man8/partclone.fat12.8%{ext_man} -%{_mandir}/man8/partclone.fat16.8%{ext_man} -%{_mandir}/man8/partclone.fat32.8%{ext_man} -%{_mandir}/man8/partclone.hfs+.8%{ext_man} -%{_mandir}/man8/partclone.hfsp.8%{ext_man} -%{_mandir}/man8/partclone.hfsplus.8%{ext_man} -%{_mandir}/man8/partclone.imager.8%{ext_man} -%{_mandir}/man8/partclone.info.8%{ext_man} -%{_mandir}/man8/partclone.minix.8%{ext_man} -%{_mandir}/man8/partclone.nilfs2.8%{ext_man} -%{_mandir}/man8/partclone.ntfs.8%{ext_man} -%{_mandir}/man8/partclone.ntfsfixboot.8%{ext_man} -%{_mandir}/man8/partclone.ntfsreloc.8%{ext_man} -%{_mandir}/man8/partclone.reiserfs.8%{ext_man} -%{_mandir}/man8/partclone.restore.8%{ext_man} -%{_mandir}/man8/partclone.vfat.8%{ext_man} -%{_mandir}/man8/partclone.xfs.8%{ext_man} +%{_mandir}/man8/partclone.8%{?ext_man} +%{_mandir}/man8/partclone.btrfs.8%{?ext_man} +%{_mandir}/man8/partclone.chkimg.8%{?ext_man} +%{_mandir}/man8/partclone.dd.8%{?ext_man} +%{_mandir}/man8/partclone.ext2.8%{?ext_man} +%{_mandir}/man8/partclone.ext3.8%{?ext_man} +%{_mandir}/man8/partclone.ext4.8%{?ext_man} +%{_mandir}/man8/partclone.ext4dev.8%{?ext_man} +%{_mandir}/man8/partclone.extfs.8%{?ext_man} +%{_mandir}/man8/partclone.exfat.8%{?ext_man} +%{_mandir}/man8/partclone.f2fs.8%{?ext_man} +%{_mandir}/man8/partclone.fat.8%{?ext_man} +%{_mandir}/man8/partclone.fat12.8%{?ext_man} +%{_mandir}/man8/partclone.fat16.8%{?ext_man} +%{_mandir}/man8/partclone.fat32.8%{?ext_man} +%{_mandir}/man8/partclone.hfs+.8%{?ext_man} +%{_mandir}/man8/partclone.hfsp.8%{?ext_man} +%{_mandir}/man8/partclone.hfsplus.8%{?ext_man} +%{_mandir}/man8/partclone.imager.8%{?ext_man} +%{_mandir}/man8/partclone.info.8%{?ext_man} +%{_mandir}/man8/partclone.minix.8%{?ext_man} +%{_mandir}/man8/partclone.nilfs2.8%{?ext_man} +%{_mandir}/man8/partclone.ntfs.8%{?ext_man} +%{_mandir}/man8/partclone.ntfsfixboot.8%{?ext_man} +%{_mandir}/man8/partclone.ntfsreloc.8%{?ext_man} +%{_mandir}/man8/partclone.reiserfs.8%{?ext_man} +%{_mandir}/man8/partclone.restore.8%{?ext_man} +%{_mandir}/man8/partclone.vfat.8%{?ext_man} +%{_mandir}/man8/partclone.xfs.8%{?ext_man} %{_datadir}/partclone %files lang -f %{name}.lang ++++++ partclone-0.3.11.tar.gz -> partclone-0.3.12.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/partclone-0.3.11/ChangeLog new/partclone-0.3.12/ChangeLog --- old/partclone-0.3.11/ChangeLog 2017-10-18 08:39:18.000000000 +0200 +++ new/partclone-0.3.12/ChangeLog 2018-10-28 14:46:38.000000000 +0100 @@ -1,5 +1,36 @@ +2018-06-25 Thomas Tsai <tlinux.t...@gmail.com> + + Merge pull request #111 from zboszor/pipe-compressor + Support compressed cloned images + +2018-06-07 Böszörményi Zoltán <zbos...@pr.hu> + + Fix close_target() + close(target_fd) must be done when not in compressing mode. + + Support compressed cloned images + The ncurses mode obviously conflicts with writing the cloned image + to stdout. Piping the image to a command to compress it while in + ncurses mode is unusable because of this. + + Fix it by adding a new option -x / --compresscmd CMD that is + executed in a write-only pipe internally by partclone. + +2018-05-05 Thomas Tsai <tlinux.t...@gmail.com> + + Merge pull request #88 from robert-scheck/non-interactive + Distinguish between (non-)interactive shell (courtesy of "UNIX F.A.Q.", 1993) + 2017-10-18 Thomas Tsai <tho...@nchc.org.tw> + set version 0.3.11 + + Merge branch 'master' of github.com:Thomas-Tsai/partclone + + make xfs clean and compile work + + release 0.3.10 + update merge remove trash @@ -161,6 +192,8 @@ 2017-01-28 Robert Scheck <rob...@fedoraproject.org> + Distinguish between (non-)interactive shell (courtesy of "UNIX F.A.Q.", 1993) + Use "which" if "locate" doesn't exist (e.g. in build environments) 2017-01-13 Thomas Tsai <tlinux.t...@gmail.com> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/partclone-0.3.11/NEWS new/partclone-0.3.12/NEWS --- old/partclone-0.3.11/NEWS 2017-10-18 08:39:18.000000000 +0200 +++ new/partclone-0.3.12/NEWS 2018-10-28 14:46:38.000000000 +0100 @@ -1 +1 @@ -pleace access http://partclone.org +please access http://partclone.org diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/partclone-0.3.11/README.md new/partclone-0.3.12/README.md --- old/partclone-0.3.11/README.md 2017-10-18 08:39:18.000000000 +0200 +++ new/partclone-0.3.12/README.md 2018-10-28 14:46:38.000000000 +0100 @@ -2,10 +2,10 @@ Partclone now supports ext2, ext3, ext4, hfs+, reiserfs, reiser4, btrfs, vmfs3, vmfs5, xfs, jfs, ufs, ntfs, fat(12/16/32), exfat... -We made some utilies: +We made some utilities: -* partclone.ext2, partclone.ext3, partclone.extfs -* partclone.ext4 +* partclone.ext2, partclone.ext3, partclone.ext4 +* partclone.extfs * partclone.reiserfs * partclone.reiser4 * partclone.xfs @@ -26,8 +26,6 @@ * partclone.dd ... -For more info about partclone, check our website http://partclone.org. - master branch is NOT STABLE, Please check 'release' branch Basic Usage: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/partclone-0.3.11/configure.ac new/partclone-0.3.12/configure.ac --- old/partclone-0.3.11/configure.ac 2017-10-18 08:39:18.000000000 +0200 +++ new/partclone-0.3.12/configure.ac 2018-10-28 14:46:38.000000000 +0100 @@ -1,4 +1,4 @@ -AC_INIT([Partclone], [0.3.11], [tho...@nchc.org.tw]) +AC_INIT([Partclone], [0.3.12], [tho...@nchc.org.tw]) AM_INIT_AUTOMAKE([-Wall foreign]) AM_GNU_GETTEXT_VERSION([0.16.1]) AM_GNU_GETTEXT([external]) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/partclone-0.3.11/docs/partclone.8 new/partclone-0.3.12/docs/partclone.8 --- old/partclone-0.3.11/docs/partclone.8 2017-10-18 08:39:18.000000000 +0200 +++ new/partclone-0.3.12/docs/partclone.8 2018-10-28 14:46:38.000000000 +0100 @@ -97,6 +97,11 @@ Save partition to the special image format\&. .RE .PP +\fB\-x\fR, \fB\-\-compresscmd \fR\fB\fICMD\fR\fR +.RS 4 +Execute CMD in a write-only pipe to compress the output image\&. Applicable to cloning\&. The output file is always overwritten\&. +.RE +.PP \fB\-r\fR, \fB\-\-restore\fR .RS 4 Restore partition from the special image format\&. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/partclone-0.3.11/release.sh new/partclone-0.3.12/release.sh --- old/partclone-0.3.11/release.sh 2017-10-18 08:39:18.000000000 +0200 +++ new/partclone-0.3.12/release.sh 2018-10-28 14:46:38.000000000 +0100 @@ -22,11 +22,11 @@ _dch_options="-b" is_release=1 USAGE(){ - + cat << EOF - $0 is script to auto release partclone. This cript will create partclone - tar ball file and auto build debian package with my key. - It's only for developer used. + $0 is script to auto release partclone. This script will create partclone + tar ball file and auto build debian package with my key. + It's only for developer usage. recognized flags are: -s, --src build tar ball diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/partclone-0.3.11/src/Makefile.am new/partclone-0.3.12/src/Makefile.am --- old/partclone-0.3.11/src/Makefile.am 2017-10-18 08:39:18.000000000 +0200 +++ new/partclone-0.3.12/src/Makefile.am 2018-10-28 14:46:38.000000000 +0100 @@ -1,6 +1,6 @@ AUTOMAKE_OPTIONS = subdir-objects AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" -D_FILE_OFFSET_BITS=64 -LDADD = $(LIBINTL) +LDADD = $(LIBINTL) -lcrypto sbin_PROGRAMS=partclone.info partclone.dd partclone.restore partclone.chkimg partclone.imager #partclone.imgfuse #partclone.block TOOLBOX = srcdir=$(top_srcdir) builddir=$(top_builddir) $(top_srcdir)/toolbox @@ -60,21 +60,21 @@ sbin_PROGRAMS += partclone.extfs partclone_extfs_SOURCES=$(main_files) extfsclone.c extfsclone.h partclone_extfs_CFLAGS=-DEXTFS -partclone_extfs_LDADD=-lext2fs -lcom_err -lpthread +partclone_extfs_LDADD=-lext2fs -lcom_err -lpthread -lcrypto endif if ENABLE_REISERFS sbin_PROGRAMS += partclone.reiserfs partclone_reiserfs_SOURCES=$(main_files) reiserfsclone.c reiserfsclone.h partclone_reiserfs_CFLAGS=-DREISERFS -partclone_reiserfs_LDADD=-lreiserfs -ldal +partclone_reiserfs_LDADD=-lreiserfs -ldal -lcrypto endif if ENABLE_REISER4 sbin_PROGRAMS += partclone.reiser4 partclone_reiser4_SOURCES=$(main_files) reiser4clone.c reiser4clone.h partclone_reiser4_CFLAGS=-DREISER4 -partclone_reiser4_LDADD=-lreiser4 -laal +partclone_reiser4_LDADD=-lreiser4 -laal -lcrypto endif if ENABLE_HFSP @@ -87,7 +87,7 @@ sbin_PROGRAMS += partclone.xfs partclone_xfs_SOURCES=$(main_files) xfsclone.c xfsclone.h $(XFS_SOURCE) partclone_xfs_CFLAGS=-Ixfs/include -Ixfs/libxfs/ -Ixfs/include/xfs/ -DXFS -D_GNU_SOURCE -DNDEBUG $(UUID_CFLAGS) -partclone_xfs_LDADD=-lrt -lpthread -luuid +partclone_xfs_LDADD=-lrt -lpthread -luuid -lcrypto endif if ENABLE_EXFAT @@ -100,14 +100,14 @@ sbin_PROGRAMS += partclone.f2fs partclone_f2fs_SOURCES=$(main_files) f2fsclone.c f2fsclone.h $(F2FS_SOURCE) partclone_f2fs_CFLAGS=-DF2FS -partclone_f2fs_LDADD=-luuid +partclone_f2fs_LDADD=-luuid -lcrypto endif if ENABLE_NILFS2 sbin_PROGRAMS += partclone.nilfs2 partclone_nilfs2_SOURCES=$(main_files) nilfsclone.c nilfsclone.h partclone_nilfs2_CFLAGS=-DNILFS -partclone_nilfs2_LDADD=-lnilfs +partclone_nilfs2_LDADD=-lnilfs -lcrypto endif if ENABLE_FAT @@ -123,10 +123,10 @@ partclone_ntfs_SOURCES=$(main_files) ntfsclone-ng.c ntfsclone-ng.h if ENABLE_NTFS_3G partclone_ntfs_CFLAGS=-DNTFS3G -partclone_ntfs_LDADD=-lntfs-3g +partclone_ntfs_LDADD=-lntfs-3g -lcrypto else partclone_ntfs_CFLAGS=-DNTFS -partclone_ntfs_LDADD=-lntfs +partclone_ntfs_LDADD=-lntfs -lcrypto endif endif @@ -134,24 +134,24 @@ sbin_PROGRAMS += partclone.ufs partclone_ufs_SOURCES=$(main_files) ufsclone.c ufsclone.h partclone_ufs_CFLAGS=-DUFS -D_GNU_SOURCE -partclone_ufs_LDADD=-lufs -lbsd +partclone_ufs_LDADD=-lufs -lbsd -lcrypto endif if ENABLE_VMFS sbin_PROGRAMS += partclone.vmfs partclone_vmfs_SOURCES=$(main_files) vmfsclone.c vmfsclone.h partclone_vmfs_CFLAGS=-DVMFS -D_GNU_SOURCE $(UUID_CFLAGS) -partclone_vmfs_LDADD=-lvmfs -luuid +partclone_vmfs_LDADD=-lvmfs -luuid -lcrypto sbin_PROGRAMS += partclone.vmfs5 partclone_vmfs5_SOURCES=$(main_files) vmfs5clone.c vmfsclone.h partclone_vmfs5_CFLAGS=-DVMFS -D_GNU_SOURCE $(UUID_CFLAGS) -partclone_vmfs5_LDADD=-lvmfs -luuid +partclone_vmfs5_LDADD=-lvmfs -luuid -lcrypto sbin_PROGRAMS += partclone.fstype partclone_fstype_SOURCES=fstype.c partclone_fstype_CFLAGS=-DVMFS -D_GNU_SOURCE $(UUID_CFLAGS) -partclone_fstype_LDADD=-lvmfs -luuid +partclone_fstype_LDADD=-lvmfs -luuid -lcrypto endif @@ -160,14 +160,14 @@ #partclone_jfs_SOURCES=$(main_files) jfs_devices.c jfs_devices.h jfsclone.c jfsclone.h partclone_jfs_SOURCES=$(main_files) jfsclone.c jfsclone.h partclone_jfs_CFLAGS=-DJFS -partclone_jfs_LDADD=-luuid -ljfs +partclone_jfs_LDADD=-luuid -ljfs -lcrypto endif if ENABLE_BTRFS sbin_PROGRAMS += partclone.btrfs partclone_btrfs_SOURCES=$(main_files) btrfsclone.c btrfsclone.h $(BTRFS_SOURCE) partclone_btrfs_CFLAGS=-DBTRFS -DBTRFS_FLAT_INCLUDES -D_XOPEN_SOURCE=700 -D_GNU_SOURCE -partclone_btrfs_LDADD=-luuid -lblkid +partclone_btrfs_LDADD=-luuid -lblkid -lcrypto endif if ENABLE_MINIX @@ -179,9 +179,9 @@ if ENABLE_FUSE sbin_PROGRAMS+=partclone.imgfuse partclone_imgfuse_SOURCES=fuseimg.c partclone.c checksum.c partclone.h fs_common.h checksum.h -partclone_imgfuse_LDADD=-lfuse +partclone_imgfuse_LDADD=-lfuse -lcrypto if ENABLE_STATIC -partclone_imgfuse_LDADD+=-ldl +partclone_imgfuse_LDADD+=-ldl -lcrypto endif endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/partclone-0.3.11/src/main.c new/partclone-0.3.12/src/main.c --- old/partclone-0.3.11/src/main.c 2017-10-18 08:39:18.000000000 +0200 +++ new/partclone-0.3.12/src/main.c 2018-10-28 14:46:38.000000000 +0100 @@ -27,7 +27,10 @@ #include <unistd.h> #include <pthread.h> #include <assert.h> -#include<dirent.h> +#include <dirent.h> + +// SHA1 for torrent info +#include <openssl/sha.h> /** * progress.h - only for progress bar @@ -571,6 +574,13 @@ char *read_buffer, *write_buffer; unsigned long long blocks_used_fix = 0, test_block = 0; + // SHA1 for torrent info + SHA_CTX ctx; + unsigned char hash[SHA_DIGEST_LENGTH + 1] = {'\0'}; + unsigned long long sha_length = 0; + const unsigned long long BT_PIECE_SIZE = 16ULL * 1024 * 1024; + int tinfo = -1; + log_mesg(1, 0, 0, debug, "#\nBuffer capacity = %u, Blocks per cs = %u\n#\n", buffer_capacity, blocks_per_cs); // fix some super block record incorrect @@ -611,6 +621,15 @@ if (!opt.ignore_crc) init_checksum(img_opt.checksum_mode, checksum, debug); + // init SHA1 for torrent info + if (opt.blockfile == 1) { + char torrent_name[PATH_MAX + 1] = {'\0'}; + sprintf(torrent_name,"%s/torrent.info", target); + tinfo = open(torrent_name, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); + + SHA1_Init(&ctx); + } + block_id = 0; do { unsigned int i; @@ -727,6 +746,51 @@ // write blocks if (blocks_write > 0) { if (opt.blockfile == 1){ + // SHA1 for torrent info + // Not always bigger or smaller than 16MB + + // first we write out block_id * block_size for filename + // because when calling write_block_file + // we will create a new file to describe a continuous block (or buffer is full) + // and never write to same file again + dprintf(tinfo, "offset: %032llx\n", block_id * block_size); + dprintf(tinfo, "length: %032llx\n", blocks_write * block_size); + + // every BT piece is 16MiB + unsigned long long sha_remain_length = BT_PIECE_SIZE - sha_length; + unsigned long long buffer_remain_length = blocks_write * block_size; + unsigned long long buffer_offset = 0; + while (buffer_remain_length > 0) { + sha_remain_length = BT_PIECE_SIZE - sha_length; + if (sha_remain_length <= 0) { + // finish a piece + SHA1_Final(hash, &ctx); + dprintf(tinfo, "sha1: "); + for (int x = 0; x < SHA_DIGEST_LENGTH; x++) { + dprintf(tinfo, "%02x", hash[x]); + } + dprintf(tinfo, "\n"); + // start for next piece; + SHA1_Init(&ctx); + sha_length = 0; + sha_remain_length = BT_PIECE_SIZE; + } + if (buffer_remain_length <= 0) { + break; + } + else if (sha_remain_length > buffer_remain_length) { + SHA1_Update(&ctx, write_buffer + blocks_written * block_size + buffer_offset, buffer_remain_length); + sha_length += buffer_remain_length; + break; + } + else { + SHA1_Update(&ctx, write_buffer + blocks_written * block_size + buffer_offset, sha_remain_length); + buffer_offset += sha_remain_length; + buffer_remain_length -= sha_remain_length; + sha_length += sha_remain_length; + } + } + w_size = write_block_file(target, write_buffer + blocks_written * block_size, blocks_write * block_size, (block_id*block_size), &opt); }else{ @@ -748,6 +812,19 @@ } while (blocks_written < blocks_read); } while(1); + + // finish SHA1 for torrent info + if (opt.blockfile == 1) { + if (sha_length) { + SHA1_Final(hash, &ctx); + dprintf(tinfo, "sha1: "); + for (int x = 0; x < SHA_DIGEST_LENGTH; x++) { + dprintf(tinfo, "%02x", hash[x]); + } + dprintf(tinfo, "\n"); + } + } + free(write_buffer); free(read_buffer); @@ -937,7 +1014,11 @@ log_mesg(0, 1, 1, debug, "%s", bad_sectors_warning_msg); } else if (r_size == 0){ // done for ddd /// write buffer to target - w_size = write_all(&dfw, buffer, rescue_write_size, &opt); + if (opt.blockfile == 1){ + w_size = write_block_file(target, buffer, rescue_write_size, copied*block_size, &opt); + } else { + w_size = write_all(&dfw, buffer, rescue_write_size, &opt); + } break; } else log_mesg(0, 1, 1, debug, "source read ERROR %s\n", strerror(errno)); @@ -999,7 +1080,7 @@ close(dfr); /// close target if (dfw != -1) - close(dfw); + close_target(dfw); /// free bitmp free(bitmap); close_pui(pui); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/partclone-0.3.11/src/partclone.c new/partclone-0.3.12/src/partclone.c --- old/partclone-0.3.11/src/partclone.c 2017-10-18 08:39:18.000000000 +0200 +++ new/partclone-0.3.12/src/partclone.c 2018-10-28 14:46:38.000000000 +0100 @@ -11,7 +11,9 @@ * (at your option) any later version. */ + #include <config.h> +#define _GNU_SOURCE #define _LARGEFILE64_SOURCE #include <features.h> #include <fcntl.h> @@ -217,6 +219,7 @@ #ifndef RESTORE #ifndef DD " -c, --clone Save to the special image format\n" + " -x, --compresscmd CMD Start CMD as an output pipe to compress the cloned image\n" " -r, --restore Restore from the special image format\n" " -b, --dev-to-dev Local device to device copy mode\n" #endif @@ -314,9 +317,9 @@ #elif RESTORE static const char *sopt = "-hvd::L:o:O:s:f:CFINiqWBz:E:n:T"; #elif DD - static const char *sopt = "-hvd::L:o:O:s:f:CFINiqWBz:E:n:"; + static const char *sopt = "-hvd::L:o:O:s:f:CFINiqWBz:E:n:T"; #else - static const char *sopt = "-hvd::L:cbrDo:O:s:f:RCFINiqWBz:E:a:k:Kn:T"; + static const char *sopt = "-hvd::L:cx:brDo:O:s:f:RCFINiqWBz:E:a:k:Kn:T"; #endif static const struct option lopt[] = { @@ -338,6 +341,7 @@ #ifndef RESTORE #ifndef DD { "clone", no_argument, NULL, 'c' }, + { "compresscmd", required_argument, NULL, 'x' }, { "restore", no_argument, NULL, 'r' }, { "dev-to-dev", no_argument, NULL, 'b' }, #endif @@ -456,6 +460,9 @@ opt->clone++; mode=1; break; + case 'x': + opt->compresscmd = optarg; + break; case 'r': opt->restore++; mode=1; @@ -1536,6 +1543,8 @@ return ret; } +static FILE *compress_pipe = NULL; + int open_target(char* target, cmd_opt* opt) { int ret = 0; int debug = opt->debug; @@ -1563,7 +1572,16 @@ } if ((opt->clone || opt->domain || (ddd_block_device == 0)) && (opt->blockfile == 0)) { - if (strcmp(target, "-") == 0) { + if (opt->compresscmd) { + int strsz = strlen(opt->compresscmd) + strlen(target) + 4; + char *compresscmd = malloc(strsz); + + sprintf(compresscmd, "%s >%s", opt->compresscmd, target); + compress_pipe = popen(compresscmd, "w"); + free(compresscmd); + if ((ret = (compress_pipe ? fileno(compress_pipe) : -1)) == -1) + log_mesg(0, 1, 1, debug, "clone: popen (%s >%s) error\n", opt->compresscmd, target); + } else if (strcmp(target, "-") == 0) { if ((ret = fileno(stdout)) == -1) log_mesg(0, 1, 1, debug, "clone: open %s(stdout) error\n", target); } else { @@ -1626,6 +1644,18 @@ return ret; } + +int close_target(int dfw) { + int ret = 0; + + if (compress_pipe) + ret = pclose(compress_pipe); + else + ret = close(dfw); + compress_pipe = NULL; + return ret; +} + int write_block_file(char* target, char *buf, unsigned long long count, unsigned long long offset, cmd_opt* opt){ long long int i; int debug = opt->debug; @@ -1671,14 +1701,24 @@ int debug = opt->debug; unsigned long long size = count; extern unsigned long long rescue_write_size; + #define BSIZE 512 + void *Bbuffer; // for sync I/O buffer, when use stdin or pipe. while (count > 0) { - if (do_write) - i = write(*fd, buf, count); - else - i = read(*fd, buf, count); + if (do_write) { + if (opt->restore){ + posix_memalign(&Bbuffer, BSIZE, BSIZE); + memcpy(Bbuffer, buf, BSIZE); + i = write(*fd, buf, BSIZE); + free(Bbuffer); + } else { + i = write(*fd, buf, count); + } + } else { + i = read(*fd, buf, count); + } if (i < 0) { log_mesg(1, 0, 1, debug, "%s: errno = %i(%s)\n",__func__, errno, strerror(errno)); if (errno != EAGAIN && errno != EINTR) { @@ -1770,9 +1810,12 @@ log_mesg(0, 0, 1, debug, _("Partclone v%s http://partclone.org\n"), VERSION); if (opt.chkimg) log_mesg(0, 0, 1, debug, _("Starting to check image (%s)\n"), opt.source); - else if (opt.clone) - log_mesg(0, 0, 1, debug, _("Starting to clone device (%s) to image (%s)\n"), opt.source, opt.target); - else if(opt.restore){ + else if (opt.clone) { + if (opt.compresscmd) + log_mesg(0, 0, 1, debug, _("Starting to clone device (%s) to compressed image (%s)\n"), opt.source, opt.target); + else + log_mesg(0, 0, 1, debug, _("Starting to clone device (%s) to image (%s)\n"), opt.source, opt.target); + } else if(opt.restore){ if (opt.blockfile) log_mesg(0, 0, 1, debug, _("Starting to restore image (%s) to block files (%s)\n"), opt.source, opt.target); else diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/partclone-0.3.11/src/partclone.h new/partclone-0.3.12/src/partclone.h --- old/partclone-0.3.11/src/partclone.h 2017-10-18 08:39:18.000000000 +0200 +++ new/partclone-0.3.12/src/partclone.h 2018-10-28 14:46:38.000000000 +0100 @@ -100,6 +100,7 @@ int debug; char* source; char* target; + char* compresscmd; char* logfile; char note[NOTE_SIZE]; int overwrite; @@ -314,6 +315,7 @@ */ extern int open_source(char* source, cmd_opt* opt); extern int open_target(char* target, cmd_opt* opt); +extern int close_target(int dfw); /// check partition size extern int check_size(int* ret, unsigned long long size); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/partclone-0.3.11/src/readblock.c new/partclone-0.3.12/src/readblock.c --- old/partclone-0.3.11/src/readblock.c 2017-10-18 08:39:18.000000000 +0200 +++ new/partclone-0.3.12/src/readblock.c 2018-10-28 14:46:38.000000000 +0100 @@ -198,7 +198,7 @@ log_mesg(0, 1, 1, opt.debug, "source seek ERROR:%s\n", strerror(errno)); r_size = read_all(&dfr, read_buffer, fs_info.block_size, &opt); w_size = write_all(&dfw, read_buffer, fs_info.block_size, &opt); - close(dfw); + close_target(dfw); close(dfr); /// close source free(bitmap); /// free bitmap diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/partclone-0.3.11/src/version.h new/partclone-0.3.12/src/version.h --- old/partclone-0.3.11/src/version.h 2017-10-18 08:39:18.000000000 +0200 +++ new/partclone-0.3.12/src/version.h 2018-10-28 14:46:38.000000000 +0100 @@ -3,5 +3,5 @@ * WHETHER THEY ARE BUILT BY OTHERS OR DURING DEVELOPMENT OR FOR THE * OFFICIAL PARTCLONE RELEASES. */ -#define git_version "931b4a45da7f84917a64817019943bd61c9d9229" +#define git_version "65923e7426ee8926f36cb0c9963febc55af85de2" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/partclone-0.3.11/tests/_common new/partclone-0.3.12/tests/_common --- old/partclone-0.3.11/tests/_common 2017-10-18 08:39:18.000000000 +0200 +++ new/partclone-0.3.12/tests/_common 2018-10-28 14:46:38.000000000 +0100 @@ -55,7 +55,7 @@ } _ptlbreak(){ - if [ $break_debug -ne 0 ];then + if [[ $break_debug -ne 0 && $- = *"i"* ]];then echo "continue test process(Y/n)? default yes" read con