xfs
[Top] [All Lists]

Re: Structure needs cleaning - Seagate Expansion External HDD 2TB USB

To: Marcel z maleho mesta <newsx@xxxxxxxxxxxxxx>
Subject: Re: Structure needs cleaning - Seagate Expansion External HDD 2TB USB
From: Emmanuel Florac <eflorac@xxxxxxxxxxxxxx>
Date: Sun, 16 May 2010 21:33:07 +0200
Cc: xfs@xxxxxxxxxxx
In-reply-to: <4BEF12A5.2030505@xxxxxxxxxxxxxx>
Organization: Intellique
References: <4BEF12A5.2030505@xxxxxxxxxxxxxx>
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@xxxxxxxxxxxxxx>
                    |   +33 1 78 94 84 02
------------------------------------------------------------------------

<Prev in Thread] Current Thread [Next in Thread>