From 6c701b58a24d96e37c323412f3d2aa334cd2ded1 Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Sun, 6 Mar 2011 20:46:29 +0000 Subject: La gestion minimaliste des évènements de modification des slices est faite. Un dump à chaque event a été codé dans le main pour tester cet aspect. C'est ok. Go go go ncurses :D MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///var/svn/2011-ddhardrescue/trunk@11 d3078510-dda0-49f1-841c-895ef4b7ec81 --- src/recover.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/recover.c') diff --git a/src/recover.c b/src/recover.c index 309ebfb..b4f0da7 100755 --- a/src/recover.c +++ b/src/recover.c @@ -5,12 +5,12 @@ extern unsigned long c; -void recover(slices_t *slices, char *src, char *dst, char *ddOpts) { +void recover(slices_evt_t *slicesEvt, char *src, char *dst, char *ddOpts) { slice_t *sliceToRead; address_t firstError=0, median, foundMax=0; int res; - sliceToRead=slices->first; + sliceToRead=slicesEvt->data->first; while (!end) { // try to recover sliceToRead and split it if read error switch ( tryRecoverUntilError(sliceToRead, &firstError, src, dst, ddOpts) ) { @@ -20,7 +20,7 @@ void recover(slices_t *slices, char *src, char *dst, char *ddOpts) { break; case EIO: // slice recovery has encountered a readerror - res=sliceSplit(slices, sliceToRead, firstError, S_RECOVERED, S_UNREADABLE, S_UNKNOWN); + res=sliceSplitEvt(slicesEvt, sliceToRead, firstError, S_RECOVERED, S_UNREADABLE, S_UNKNOWN); if (res<1) { //TODO printf("sliceSplit return %d\n", res); @@ -34,7 +34,7 @@ void recover(slices_t *slices, char *src, char *dst, char *ddOpts) { /* Now, search the largest S_UNKNOWN zone split it in two parts */ //sliceToRead=slicesFindLargest(slices, S_UNKNOWN); - sliceToRead=slicesFindLargestFast(slices, &foundMax, S_UNKNOWN, foundMax, sliceToRead->next); + sliceToRead=slicesFindLargestFast(slicesEvt->data, &foundMax, S_UNKNOWN, foundMax, sliceToRead->next); if ( sliceToRead == NULL ) { // There is nothing more to recover, bailout end=1; @@ -43,7 +43,7 @@ void recover(slices_t *slices, char *src, char *dst, char *ddOpts) { median=(sliceToRead->begin+sliceToRead->end)/2; - res=sliceSplit(slices, sliceToRead, median, S_UNKNOWN, S_UNKNOWN, S_UNKNOWN); + res=sliceSplitEvt(slicesEvt, sliceToRead, median, S_UNKNOWN, S_UNKNOWN, S_UNKNOWN); switch (res) { case 1: // No split, try analyse this zone @@ -92,10 +92,11 @@ int tryRecoverUntilError(slice_t *sliceToRead, address_t *firstError, char *src, *firstError=sliceToRead->begin; res=EIO; */ +/* // Simulate that we have systematically a read error at last sector *firstError=sliceToRead->end; res=EIO; - +*/ /* // Simulate that we have systematically a read error at first sector // Simulate for each read, tha we have an error just in the middle if read for mor than one sector @@ -106,16 +107,16 @@ int tryRecoverUntilError(slice_t *sliceToRead, address_t *firstError, char *src, res=EIO; } */ -/* + // Simulate for each read a pseudo random error position and generate some cases of full read without error - int error=sliceToRead->begin + rand()%count; + address_t error=sliceToRead->begin + rand()%count; if ( error % 42 == 0 ) { res=0; } else { res=EIO; *firstError=error; } -*/ + return res; } -- cgit v1.2.3