[Forensics-changes] [SCM] recover files/disks with damaged sectors branch, upstream, updated. upstream_0.19-1-g17d753f
Daniel Baumann
daniel at debian.org
Sat Jan 10 19:49:49 UTC 2009
The following commit has been merged in the upstream branch:
commit 17d753f56bed9f30ca952816492d6dcc1bb8875c
Author: Daniel Baumann <daniel at debian.org>
Date: Sat Jan 10 20:39:32 2009 +0100
Adding upstream version 0.20.
diff --git a/Makefile b/Makefile
index b0f8cfb..b10e6dc 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-VERSION=0.19
+VERSION=0.20
CFLAGS=-Wall -Wshadow -Wconversion -Wwrite-strings -Winline -O2 -DVERSION=\"$(VERSION)\"
LDFLAGS=
@@ -10,13 +10,14 @@ all: recoverdm mergebad
recoverdm: $(OBJSr)
$(CC) -Wall -W $(OBJSr) $(LDFLAGS) -o recoverdm
- strip recoverdm
- echo
- echo Oh, blatant plug: http://keetweej.vanheusden.com/wishlist.html
mergebad: $(OBJSm)
$(CC) -Wall -W $(OBJSm) $(LDFLAGS) -o mergebad
- strip mergebad
+
+install:
+ cp recoverdm mergebad /usr/local/bin
+ echo
+ echo Oh, blatant plug: http://keetweej.vanheusden.com/wishlist.html
clean:
rm -f $(OBJSr) $(OBJSm) recoverdm mergebad core
diff --git a/recoverdm.c b/recoverdm.c
index dcb64b1..8b71ae1 100644
--- a/recoverdm.c
+++ b/recoverdm.c
@@ -26,10 +26,12 @@ void usage(void)
{
fprintf(stderr, "Usage: recoverdm -t <type> -i <file/device-in> -o <fileout> [-l <sectorsfile>] [-n # retries]\n");
fprintf(stderr, " [-s rotation speed (CD-ROM etc.)] [-r # CD/DVD RAW read retries]\n");
- fprintf(stderr, " [-b start offset]\n");
+ fprintf(stderr, " [-b start offset] [-p skip blocks count]\n");
fprintf(stderr, "Number of retries defaults to %d. For CD-ROMs it's advised to use 1.\n", N_RETRIES);
fprintf(stderr, "Number of CD/DVD RAW read retries defaults to %d. It is advised to use at least 3.\n", N_CD_RAW_RETRIES);
fprintf(stderr, "CD-ROM (and DVD) speed defaults to %d.\n", DEFAULT_CD_SPEED);
+ fprintf(stderr, "Skip blocks count is how many sectors are skipped after non-read one. Use\n");
+ fprintf(stderr, "more to speed-up the recover process. Default is 1.\n");
fprintf(stderr, "Type can be:\n");
fprintf(stderr, "\tFILE\t\t1\n");
fprintf(stderr, "\tFLOPPY\t\t10\n");
@@ -206,6 +208,7 @@ int main(int argc, char *argv[])
int fdin, fdout;
off64_t prevpos, curpos=(off64_t)-1, lastok=(off64_t)-1, the_end;
off64_t start_offset = 0;
+ int skip_value = 1; // in blocks
int n=0;
size_t block_size;
int c;
@@ -224,7 +227,7 @@ int main(int argc, char *argv[])
return -1;
}
- while((c = getopt(argc, argv, "i:o:l:t:n:s:r:b:Vh")) != -1)
+ while((c = getopt(argc, argv, "i:o:l:t:p:n:s:r:b:Vh")) != -1)
{
switch(c)
{
@@ -252,6 +255,9 @@ int main(int argc, char *argv[])
case 'n':
n_retries = atoi(optarg);
break;
+ case 'p':
+ skip_value = atoi(optarg);
+ break;
case 's':
cd_speed = atoi(optarg);
break;
@@ -284,6 +290,12 @@ int main(int argc, char *argv[])
fprintf(stderr, "Start offset must be a multiple of 512!\n");
return -1;
}
+
+ if (skip_value <= 0)
+ {
+ fprintf(stderr, "Skip value must be positive!\n");
+ return -1;
+ }
if (dev_type == DT_CDROM_IDE || dev_type == DT_CDROM_SCSI)
block_size = 2048;
@@ -430,7 +442,7 @@ int main(int argc, char *argv[])
/* always mark the sector as tricky */
if (dsecfile)
{
- fprintf(dsecfile, "%lld %ld\n", curpos, block_size);
+ fprintf(dsecfile, "%lld %ld\n", curpos, block_size*skip_value);
fflush(dsecfile);
}
@@ -462,11 +474,11 @@ int main(int argc, char *argv[])
}
}
- printf("Tried reading %d times, failed doing that. Continuing...\n", n_retries);
+ printf("Tried reading %d times, failed doing that. Skiping %d blocks...\n", n_retries, skip_value);
- if (lseek64(fdin, curpos + (off64_t)block_size, SEEK_SET) == -1)
+ if (lseek64(fdin, curpos + (off64_t)block_size*skip_value, SEEK_SET) == -1)
{
- fprintf(stderr, "Problem seeking in input-file! [%d] (next sector)\n", errno);
+ fprintf(stderr, "Problem seeking in input-file! [%d] (sector %d after current)\n", errno, skip_value);
}
}
}
--
recover files/disks with damaged sectors
More information about the forensics-changes
mailing list