1

raw パーティション イメージ (EXT4) の空き領域からジャンク データのみを抽出したい。そこで、空き領域をゼロにして、その結果をマスクとして使用するというアイデアを思いつきました。

データと空き領域を含む raw パーティション イメージ (14GB) と、空き領域をゼロにした同じ raw パーティション イメージがあります。

Perl でこれら 2 つのファイル間で次の操作を実行したいと考えています。処理された生のパーティション イメージを取得するために、それらの各バイトには、空き領域からのジャンク データのみが含まれます。

RPM  - raw partition image
RPMz - raw partition image with free space zeroed
RPMp - raw partition image processed, will contain only junk data from free space

各バイト:RPM & !RPMz => RPMp

誰かが Perl スクリプトまたはこれの出発点で私を助けてくれますか?

4

1 に答える 1

1

これは、!RPMz を取得するために、バイトを反転するために私が書いたものです。しかし、それは遅く、100MB のチャンクではメモリ不足です。助けが必要です。

use strict;
use warnings;
use bignum;

my $buffer = "";

my $path1="F:/data-lost-workspace/partition-for-zerofree/mmcblk0p12.raw";
my $path2="F:/data-lost-workspace/partition-for-zerofree/mmcblk0p12_invert.raw";

open(FILE_IN, "<$path1");
binmode(FILE_IN); 

my $offset=0;
my $remaining = -s $path1;
my $length=1024*1024*100;
my $index=1;

unlink $path2;

while($remaining>0)
{
my $line=read(FILE_IN, $buffer, $length);  
print $index." ".$line."\r\n";
$index++;
$remaining=$remaining-$length;

my $buffer_invert=();

my @c = split('', $buffer);

for(my $i=0;$i<$length;$i++)
{
    if(ord($c[$i])==0x0)
    {
        $c[$i]=chr(0xFF);
    }
    else
    {
        $c[$i]=chr(0x00);
    }
}

$buffer_invert=join('', @c);

open(FILE_OUT, ">>$path2");
binmode(FILE_OUT); 
print FILE_OUT $buffer_invert;
close(FILE_OUT);
}
close(FILE_IN);
于 2014-11-10T07:13:55.897 に答える