summaryrefslogtreecommitdiffstats
path: root/perl-install/fsedit.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>1999-12-09 00:52:32 +0000
committerPascal Rigaux <pixel@mandriva.com>1999-12-09 00:52:32 +0000
commitd59b27d5fcc346d96072ed0edb88cda0223be084 (patch)
treef605bc19591d3cf23d372a5ace6c70fbe367a620 /perl-install/fsedit.pm
parent1934b3123c81c2ccb425626aa61ed29e38780ddf (diff)
downloaddrakx-d59b27d5fcc346d96072ed0edb88cda0223be084.tar
drakx-d59b27d5fcc346d96072ed0edb88cda0223be084.tar.gz
drakx-d59b27d5fcc346d96072ed0edb88cda0223be084.tar.bz2
drakx-d59b27d5fcc346d96072ed0edb88cda0223be084.tar.xz
drakx-d59b27d5fcc346d96072ed0edb88cda0223be084.zip
no_comment
Diffstat (limited to 'perl-install/fsedit.pm')
-rw-r--r--perl-install/fsedit.pm45
1 files changed, 39 insertions, 6 deletions
diff --git a/perl-install/fsedit.pm b/perl-install/fsedit.pm
index 1bca50f5c..4e31ae49a 100644
--- a/perl-install/fsedit.pm
+++ b/perl-install/fsedit.pm
@@ -105,17 +105,50 @@ sub get_root($) {
}
sub get_root_ { get_root([ get_fstab(@{$_[0]}) ]) }
+sub is_one_big_fat {
+ my ($hds) = @_;
+ @$hds == 1 or return;
+
+ my @l = fsedit::get_fstab(@$hds);
+ @l == 1 && isFat($l[0]) && fsedit::free_space(@$hds) < 10 << 11;
+}
+
sub computeSize($$$$) {
my ($part, $best, $hds, $suggestions) = @_;
my $max = $part->{maxsize} || $part->{size};
- my $tot_ratios = sum(map { $_->{ratio} } grep { !has_mntpoint($_->{mntpoint}, $hds) } @$suggestions);
+ return min($max, $best->{size}) unless $best->{ratio};
+
+ my $free_space = free_space(@$hds);
+ my @l = my @L = grep {
+ if (!has_mntpoint($_->{mntpoint}, $hds) && $free_space >= $_->{size}) {
+ $free_space -= $_->{size};
+ 1;
+ } else { 0 } } @$suggestions;
+
+ my $tot_ratios = 0;
+ while (1) {
+ my $old_free_space = $free_space;
+ my $old_tot_ratios = $tot_ratios;
+
+ $tot_ratios = sum(map { $_->{ratio} } @l);
+ last if $tot_ratios == $old_tot_ratios;
+
+ @l = grep {
+ if ($_->{ratio} && $_->{maxsize} && $tot_ratios &&
+ $_->{size} + $_->{ratio} / $tot_ratios * $old_free_space >= $_->{maxsize}) {
+ return min($max, $best->{maxsize}) if $best->{mntpoint} eq $_->{mntpoint};
+ $free_space -= $_->{maxsize} - $_->{size};
+ 0;
+ } else {
+ $_->{ratio};
+ }
+ } @l;
+ }
+ my $size = min($max, $best->{size} + $free_space * ($tot_ratios && $best->{ratio} / $tot_ratios));
- min($max,
- $best->{maxsize} || $max,
- $best->{size}
- + free_space(@$hds)
- * ($tot_ratios && $best->{ratio} / $tot_ratios));
+ #- verify other entry can fill the hole
+ if (grep { $_->{size} < $max - $size } @L) { $size } else { $max }
}
sub suggest_part($$$;$) {