summaryrefslogtreecommitdiff
path: root/src/recover.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/recover.c')
-rwxr-xr-xsrc/recover.c19
1 files changed, 10 insertions, 9 deletions
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;
}