diff -Nru myrescue-0.9.6/ChangeLog myrescue-0.9.8/ChangeLog --- myrescue-0.9.6/ChangeLog 2018-02-11 18:52:20.000000000 +0000 +++ myrescue-0.9.8/ChangeLog 2018-12-21 12:19:42.000000000 +0000 @@ -1,3 +1,10 @@ +0.9.8 + FEATURE: Option to perform a USB bus reset after every failed + read attempt. + +0.9.7 + -- ignore - had a bug --- + 0.9.6 BUGFIX: Prevent failure and possible loss of recoverable data from drives with 2^31 or more blocks. diff -Nru myrescue-0.9.6/debian/changelog myrescue-0.9.8/debian/changelog --- myrescue-0.9.6/debian/changelog 2018-06-06 02:32:42.000000000 +0000 +++ myrescue-0.9.8/debian/changelog 2019-01-04 19:07:19.000000000 +0000 @@ -1,7 +1,16 @@ +myrescue (0.9.8-1) unstable; urgency=medium + + * New upstream version 0.9.8 + * Bumped DH level to 12 + * Bumped Standards-Version to 4.3.0 + * debian/copyright: updated packaging copyright years + + -- Giovani Augusto Ferreira Fri, 04 Jan 2019 17:07:19 -0200 + myrescue (0.9.6-1) unstable; urgency=medium [ Raphaël Hertzog ] - * Update team maintainer address to Debian Security Tools + * Update team maintainer address to Debian Security Tools * Update Vcs-Git and Vcs-Browser for the move to salsa.debian.org diff -Nru myrescue-0.9.6/debian/compat myrescue-0.9.8/debian/compat --- myrescue-0.9.6/debian/compat 2018-06-06 02:32:42.000000000 +0000 +++ myrescue-0.9.8/debian/compat 2019-01-04 19:04:15.000000000 +0000 @@ -1 +1 @@ -11 +12 diff -Nru myrescue-0.9.6/debian/control myrescue-0.9.8/debian/control --- myrescue-0.9.6/debian/control 2018-06-06 02:32:42.000000000 +0000 +++ myrescue-0.9.8/debian/control 2019-01-04 19:04:51.000000000 +0000 @@ -3,8 +3,8 @@ Priority: optional Maintainer: Debian Security Tools Uploaders: Giovani Augusto Ferreira -Build-Depends: debhelper (>= 11) -Standards-Version: 4.1.4 +Build-Depends: debhelper (>= 12) +Standards-Version: 4.3.0 Homepage: http://myrescue.sf.net Vcs-Browser: https://salsa.debian.org/pkg-security-team/myrescue Vcs-Git: https://salsa.debian.org/pkg-security-team/myrescue.git diff -Nru myrescue-0.9.6/debian/copyright myrescue-0.9.8/debian/copyright --- myrescue-0.9.6/debian/copyright 2018-06-06 02:32:42.000000000 +0000 +++ myrescue-0.9.8/debian/copyright 2019-01-04 19:05:33.000000000 +0000 @@ -11,7 +11,7 @@ Copyright: 2008 Christophe Monniez 2008-2009 Daniel Baumann 2015-2016 Joao Eriberto Mota Filho - 2016-2018 Giovani Augusto Ferreira + 2016-2019 Giovani Augusto Ferreira License: GPL-2+ License: GPL-2+ diff -Nru myrescue-0.9.6/doc/myrescue.1 myrescue-0.9.8/doc/myrescue.1 --- myrescue-0.9.6/doc/myrescue.1 2018-02-11 18:52:20.000000000 +0000 +++ myrescue-0.9.8/doc/myrescue.1 2018-12-21 12:19:42.000000000 +0000 @@ -25,6 +25,8 @@ .RB [ -T ] .RB [ -J .IR jump-after-blocks ] +.RB [ -U +.IR usb-device-file ] .I input-file .I output-file .SH DESCRIPTION @@ -156,6 +158,14 @@ failed sector or upon hitting a sector to be skipped as specified by -f, -G or -F. .TP +.BI -U " usb-device-file" +(Linux-specific feature) Perform a bus reset for the specified +.I usb-device-file +after every failed read attempt. +Certain faulty SD cards will disappear completely from the bus after a read +error occurs and the USB reader has to be reset completely +in order to continue. +.TP .BR -h ", " -? Display usage information. .SH RECOMMENDED PROCEDURE diff -Nru myrescue-0.9.6/doc/myrescue.de.1 myrescue-0.9.8/doc/myrescue.de.1 --- myrescue-0.9.6/doc/myrescue.de.1 2018-02-11 18:52:20.000000000 +0000 +++ myrescue-0.9.8/doc/myrescue.de.1 2018-12-21 12:19:42.000000000 +0000 @@ -25,6 +25,8 @@ .IR failed-range ] .RB [ -J .IR jump-after-blocks ] +.RB [ -U +.IR usb-device-file ] .I input-file .I output-file .SH BESCHREIBUNG @@ -169,6 +171,16 @@ Defekt oder beim Antreffen eines Blocks, der laut -f, -G or -F zu ueberspringen ist. .TP +.BI -U " usb-device-file" +(Linux spezifisch) Nach jedem Lesefehler das per +.I usb-device-file +spezifizierte Gerät zuruecksetzen. +Manche kaputte SD-Karte verschwindet nach einem Lesefehler komplett vom Bus. +Der USB-Leser muss daher komplett zurueckgesetzt werden, um ueberhaupt +weitermachen zu koennen. +.IP +Weitere Hintergrund-Infos: https://www.idioten-notschlachten.de/blog/2011/11/13/kennen-sie-asmi/ +.TP .BR -h ", " -? Zeigt die Online-Hilfe an. .SH EMPFOHLENE VORGEHENSWEISE diff -Nru myrescue-0.9.6/src/myrescue.c myrescue-0.9.8/src/myrescue.c --- myrescue-0.9.6/src/myrescue.c 2018-02-11 18:52:20.000000000 +0000 +++ myrescue-0.9.8/src/myrescue.c 2018-12-21 12:19:42.000000000 +0000 @@ -18,9 +18,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#define __USE_LARGEFILE64 1 -#define _LARGEFILE_SOURCE 1 +#define __USE_LARGEFILE64 1 +#define _LARGEFILE_SOURCE 1 #define _LARGEFILE64_SOURCE 1 +#define HAVE_USBRESET 1 #include #include @@ -38,6 +39,41 @@ #include "permute.h" #define LONG_TIME 3 +#define SLEEP_AFTER_USBRESET 5 + +#if HAVE_USBRESET + +#include +#include + +int usbreset(const char* usb_dev_file) +{ + int fd; + int rc; + + printf("Resetting USB device %s\n", usb_dev_file); + + fd = open(usb_dev_file, O_WRONLY); + if (fd < 0) { + perror("Error opening usb device file"); + return 1; + } + + rc = ioctl(fd, USBDEVFS_RESET, 0); + if (rc < 0) { + perror("Error in usb reset ioctl"); + close(fd); + return 1; + } + close(fd); + + printf("Reset successful\n"); + + sleep(SLEEP_AFTER_USBRESET); + + return 0; +} +#endif int sig_abort = 0; @@ -131,6 +167,7 @@ int try_block ( int src_fd, int dst_fd, long block_num, int block_size, int retry_count, + char * usb_dev_file, unsigned char * buffer ) { int r ; @@ -139,7 +176,12 @@ block_num, block_size, buffer ) == 0 ) return 1 ; +#if HAVE_USBRESET + if (usb_dev_file) + usbreset(usb_dev_file); +#endif } + return 0 ; } @@ -184,6 +226,7 @@ int retry_count, int abort_error, int skip, int skip_fail, int reverse, int good_range, int failed_range, int long_as_bad, + char * usb_dev_file, unsigned char * buffer ) { long block_step = 1; @@ -211,6 +254,7 @@ time(&before); if ( try_block ( src_fd, dst_fd, block, block_size, retry_count, + usb_dev_file, buffer ) ) { time(&after); long_time = (after - before >= LONG_TIME); @@ -257,6 +301,7 @@ int retry_count, int abort_error, int skip, int skip_fail, int jump, int good_range, int failed_range, int long_as_bad, + char *usb_dev_file, long block, long orig_block, int jump_count, int jump_step, long *ok_count, long *bad_count, @@ -293,6 +338,7 @@ time(&before); if ( try_block ( src_fd, dst_fd, block, block_size, retry_count, + usb_dev_file, buffer ) ) { time(&after); long_time = (after - before >= LONG_TIME); @@ -319,6 +365,7 @@ int retry_count, int abort_error, int skip, int skip_fail, int jump, int good_range, int failed_range, int long_as_bad, + char * usb_dev_file, unsigned char * buffer ) { long orig_block, block ; @@ -346,6 +393,7 @@ retry_count, abort_error, skip, skip_fail, jump, good_range, failed_range, long_as_bad, + usb_dev_file, block, orig_block, jump, +1, &ok_count, &bad_count, @@ -358,6 +406,7 @@ retry_count, abort_error, skip, skip_fail, jump, good_range, failed_range, long_as_bad, + usb_dev_file, block-1, orig_block, jump-1, -1, &ok_count, &bad_count, @@ -391,6 +440,8 @@ "-J randomly jump after reading a few sectors\n" "-T make -A, -S and -F avoid blocks that took long to read\n" "-R reverse copy direction\n" +"-U USB device reset after read error\n" +" (something like /dev/bus/usb/XXX/XXX !)\n" "-h, -? usage information\n" ; int main(int argc, char** argv) @@ -412,6 +463,7 @@ int good_range = 0 ; int failed_range = 0 ; int long_as_bad = 0 ; + char* usb_dev_file = NULL; long long block_count ; @@ -425,7 +477,7 @@ /* options */ - while ( (optc = getopt ( argc, argv, "b:B:ASf:r:s:e:J:G:F:TRh?" ) ) != -1 ) { + while ( (optc = getopt ( argc, argv, "b:B:ASf:r:s:e:J:G:U:F:TRh?" ) ) != -1 ) { switch ( optc ) { case 'b' : block_size = atol(optarg); @@ -506,6 +558,14 @@ case 'R' : reverse = 1 ; break ; + case 'U': +#if HAVE_USBRESET + usb_dev_file = optarg; +#else + fprintf(stderr, "usb reset not compiled in\n"); + exit(-1); +#endif + break ; default : fprintf ( stderr, "%s", usage ) ; exit(-1) ; @@ -590,6 +650,7 @@ retry_count, abort_error, skip, skip_fail, reverse, good_range, failed_range, long_as_bad, + usb_dev_file, buffer ) ; else do_jump ( src_fd, dst_fd, bitmap_fd, @@ -597,6 +658,7 @@ retry_count, abort_error, skip, skip_fail, jump, good_range, failed_range, long_as_bad, + usb_dev_file, buffer ); return 0 ; }