[Debburn-changes] r320 - nonameyet/trunk/3rd-party/dirsplit
Eduard Bloch
blade at costa.debian.org
Sun Sep 17 21:19:59 UTC 2006
Author: blade
Date: 2006-09-17 21:19:58 +0000 (Sun, 17 Sep 2006)
New Revision: 320
Modified:
nonameyet/trunk/3rd-party/dirsplit/dirsplit
Log:
Corrected dirsplit, splitting into multiple coalesced volumes in e4 mode
Modified: nonameyet/trunk/3rd-party/dirsplit/dirsplit
===================================================================
--- nonameyet/trunk/3rd-party/dirsplit/dirsplit 2006-09-17 19:17:09 UTC (rev 319)
+++ nonameyet/trunk/3rd-party/dirsplit/dirsplit 2006-09-17 21:19:58 UTC (rev 320)
@@ -75,6 +75,7 @@
$opt_ver = 1 if $opt_sim;
$opt_move=1 if ($opt_sln || $opt_ln);
+die "Invalid filesystem exploration mode!\n" if ($emode<1 || $emode>4);
# big list @sizes containing the "items" (object sizes)
# %names hash mapping "items" (size as key) to arrays with filenames/subarrays for coalesced files
@@ -238,7 +239,7 @@
# parameter: directory
# mode 1: descend as far as possible and index all non-directories
# mode 2++:
-# put all files of a dir into coaleseced-object, then descend into each dir
+# put all files of a dir into coalesced-object, then descend into each dir
sub explore {
(my $dir) = @_;
my @stuff;
@@ -248,9 +249,7 @@
opendir(DIR, $dir) || die "Could not open $dir\n";
@stuff=readdir(DIR);
- if($opt_simple) {
- @stuff=sort { lc($a) cmp lc($b) } @stuff;
- }
+ @stuff=sort { lc($a) cmp lc($b) } @stuff;
foreach my $f (@stuff) {
next if ($f eq "." || $f eq "..");
@@ -299,46 +298,40 @@
}
$filesum += $tmp;
};
+ #print "D: filesum: $filesum\n";
+ if($filesum<=$max) {
+ # ok, building a coalesced object, the simplest case
+ &insitem($filesum, \@files);
+ }
+ elsif($emode==2) {
+ die "Coalesced data object became too large for one medium, expriment with -e option.\n";
+ }
+ # oversized, deal with oversized coal. objects
+ elsif($emode==3) {
+ # don't coalesc in this mode, do like mode 1 above, leave them alone
+ &insitem(getsize($_), $_) for(@files);
+ return;
+ }
+ # a bit more complicated, split file set
+ elsif($emode==4) {
- # handle coal. objects becoming too large
- if($filesum>$max) {
- # too large coal. object...
- if($emode==3) {
- # don't coalesc in this mode, do like mode 1 above, leave them alone
- &insitem(getsize($_), $_) for(@files);
- return;
- }
- # a bit complicated, split file set while creating coal.objects
- if($emode==4) {
- my $partsum=0;
- my @sorted=sort(@files);
- my @tmpvol;
- for(my $i=0;$i<=$#sorted;$i++) {
-# print "D: i: $i, partsum: $partsum, file: $sorted[$i]\n";
- my $tmp=getsize($sorted[$i]);
- $partsum+=$tmp;
- if($partsum>$max) {
- # undo the last step then build the coal.object
- $partsum-=$tmp;
- $i--;
-
- &insitem($partsum, \@tmpvol);
- # reset temporaries
- undef @tmpvol;
- undef $partsum;
- }
- else {
- push(@tmpvol, $sorted[$i]);
- }
+ my @tmpvol;
+ my $tmpsize=0;
+ for my $f (@files) {
+ my $newsize=getsize($f);
+ if($tmpsize+$newsize > $max) { # wouldn't fit
+ &insitem($tmpsize, [@tmpvol]);
+ $tmpsize=$newsize;
+ @tmpvol=($f);
}
- return;
+ else {
+ push(@tmpvol, $f);
+ $tmpsize+=$newsize;
+ }
}
+ # the last incomplete volume, not copying the [array], it's local here already
+ &insitem($tmpsize, \@tmpvol)
}
-
- # ok, building a coalesced object for simple cases
- if($filesum) {
- &insitem($filesum, \@files);
- }
}
}
@@ -348,6 +341,7 @@
# args: size, object (filename or list reference)
sub insitem {
my ($size, $object) = @_;
+ #print "D: $size, $object\n";
# normaly, put the items into the pool for calculation. In simple mode, calculate here
push(@sizes, $size);
More information about the Debburn-changes
mailing list