Structure needs cleaning - Seagate Expansion External HDD 2TB USB
Emmanuel Florac
eflorac at intellique.com
Sun May 16 14:33:07 CDT 2010
Le Sat, 15 May 2010 22:31:17 +0100 vous écriviez:
> but the most important one "DVBgrab" with about
> 400Gb of data :( (each file is between 1 and 2 Gb)
Don't write anything to your drive. Here is a perl script I wrote to
find back lost DV files from a huge corrupted array.
Mount some other place to save the found files to /mnt/destination,
then run the script passing the device to search as parameter.
#!/usr/bin/perl
use strict;
use warnings;
$|=1 ;
my ( $file ) = @ARGV;
my $blocksize = 4096 ;
my $lookupstring = pack "H*", "1F0700" ;
my $regexp = qr/^(.*?)($lookupstring.*)$/s ;
open ( my $raid, "< $file" ) or die "can't open $file \n" ;
{
my $block ;
my $offset = 0 ;
my $nextblock = 0;
my $testfile;
# frame size is 1440000 bytes
my $framebuffer1 = '' ;
my $outnumber = 0;
seek $raid, $offset, 0 or die ;
while ( my $readbytes = read $raid, $block, $blocksize ) {
$offset += $readbytes ;
print "* offset : $offset\n" unless ( $offset %
1073741824 ) ;
if ( length $framebuffer1 == 0 ) {
if ( $block =~ m/$regexp/ ) {
print "found, file $outnumber
offset $offset\n"; $framebuffer1 = $2 ;
}
} elsif ( length $framebuffer1 < 144000 - $blocksize ) {
$framebuffer1 .= $block ;
print "file head inside : offset $offset\n" if
( $block =~ m/$regexp/ ) ; } elsif ( length $framebuffer1 == 144000 -
$blocksize ) { $framebuffer1 .= $block ;
} else {
$framebuffer1 .= substr( $block, 0, ( 144000 -
length $framebuffer1 ) ) ;
if ( not $testfile ) {
print "OPEN\n";
open $testfile,
">/mnt/destination/out". sprintf ("%09d", $outnumber) . ".dv" or die
"can't write file $outnumber "; }
print $testfile $framebuffer1 ;
if ( $block =~ m/$regexp/ ) {
print "found, file $outnumber
offset $offset\n"; $framebuffer1 = $2 ;
} else {
print "CLOSE\n" ;
close $testfile ;
undef $testfile ;
$framebuffer1 = '' ;
$outnumber++;
}
}
}
}
--
------------------------------------------------------------------------
Emmanuel Florac | Direction technique
| Intellique
| <eflorac at intellique.com>
| +33 1 78 94 84 02
------------------------------------------------------------------------
More information about the xfs
mailing list