summaryrefslogtreecommitdiffstats
path: root/perl-install/resize_fat/any.pm
diff options
context:
space:
mode:
authorFrancois Pons <fpons@mandriva.com>2000-02-09 11:40:32 +0000
committerFrancois Pons <fpons@mandriva.com>2000-02-09 11:40:32 +0000
commit77d16a3330cab8b9c86667220114542958e7a348 (patch)
treee7fa44df3f8315f3e9cbad50b87bfc8250aeb6d4 /perl-install/resize_fat/any.pm
parent4ce69234e573c58002f3d1a9f361489410e883b2 (diff)
downloaddrakx-77d16a3330cab8b9c86667220114542958e7a348.tar
drakx-77d16a3330cab8b9c86667220114542958e7a348.tar.gz
drakx-77d16a3330cab8b9c86667220114542958e7a348.tar.bz2
drakx-77d16a3330cab8b9c86667220114542958e7a348.tar.xz
drakx-77d16a3330cab8b9c86667220114542958e7a348.zip
*** empty log message ***
Diffstat (limited to 'perl-install/resize_fat/any.pm')
-rw-r--r--perl-install/resize_fat/any.pm47
1 files changed, 40 insertions, 7 deletions
diff --git a/perl-install/resize_fat/any.pm b/perl-install/resize_fat/any.pm
index 252caed4b..47f15558b 100644
--- a/perl-install/resize_fat/any.pm
+++ b/perl-install/resize_fat/any.pm
@@ -2,7 +2,7 @@ package resize_fat::any;
use diagnostics;
use strict;
-use vars qw($FREE $FILE $DIRECTORY);
+use vars qw($FREE $FILE $DIRECTORY $UNMOVEABLE);
use common qw(:common :constant);
use resize_fat::fat;
@@ -11,9 +11,10 @@ use resize_fat::dir_entry;
use resize_fat::c_rewritten;
-$FREE = 0;
-$FILE = 1;
-$DIRECTORY = 2;
+$FREE = 0;
+$FILE = 1;
+$DIRECTORY = 2;
+$UNMOVEABLE = 8;
1;
@@ -31,6 +32,23 @@ sub max_cluster_count($) {
+#- patch to get the function last_used that return the last used cluster of a fs.
+sub last_used($) {
+ my ($fs) = @_;
+
+ #- count in negative so absolute value count back to 2.
+ foreach (-($fs->{nb_clusters}+1)..-2) { return -$_ if resize_fat::c_rewritten::flag(-$_) }
+ return 2;
+}
+#- patch to get the function last_unmoveable that return the last unmoveable cluster of a fs.
+sub last_unmoveable($) {
+ my ($fs) = @_;
+
+ #- count in negative so absolute value count back to 2.
+ foreach (-($fs->{nb_clusters}+1)..-2) { return -$_ if 0x8 & resize_fat::c_rewritten::flag(-$_) }
+ return 2;
+}
+
#- calculates the minimum size of a partition, in physical sectors
sub min_size($) {
my ($fs) = @_;
@@ -40,6 +58,7 @@ sub min_size($) {
#- It's done on purpose since we're moving all directories. So at the worse
#- moment, 2 directories are there, but that way nothing wrong can happen :)
my $min_cluster_count = max(2 + $count->{used} + $count->{bad} + $count->{dirs}, min_cluster_count($fs));
+ $min_cluster_count = max($min_cluster_count, 2 + last_unmoveable($fs));
$min_cluster_count * divide($fs->{cluster_size}, $SECTORSIZE) +
divide($fs->{cluster_offset}, $SECTORSIZE);
@@ -53,28 +72,42 @@ sub max_size($) {
$max_cluster_count * divide($fs->{cluster_size}, $SECTORSIZE) +
divide($fs->{cluster_offset}, $SECTORSIZE);
}
+#- calculates used size in order to avoid modifying anything.
+sub used_size($) {
+ my ($fs) = @_;
+
+ my $used_cluster_count = max(2 + last_used($fs), min_cluster_count($fs));
+
+ $used_cluster_count * divide($fs->{cluster_size}, $SECTORSIZE) +
+ divide($fs->{cluster_offset}, $SECTORSIZE);
+}
#- fills in fat_flag_map in c_rewritten.
#- Each FAT entry is flagged as either FREE, FILE or DIRECTORY.
sub flag_clusters {
my ($fs) = @_;
- my ($cluster, $entry, $type, $nb_dirs);
+ my ($cluster, $curr_dir_name, $entry, $type, $nb_dirs);
my $f = sub {
- ($entry) = @_;
+ ($curr_dir_name, $entry) = @_;
$cluster = resize_fat::dir_entry::get_cluster($entry);
if (resize_fat::dir_entry::is_file($entry)) {
$type = $FILE;
+ $type |= $UNMOVEABLE if resize_fat::dir_entry::is_unmoveable($entry);
} elsif (resize_fat::dir_entry::is_directory($entry)) {
$type = $DIRECTORY;
} else { return }
- my $nb = resize_fat::c_rewritten::checkFat($cluster, $type, $entry->{name});
+ my $nb = resize_fat::c_rewritten::checkFat($cluster, $type, "$curr_dir_name/$entry->{name}");
$nb_dirs += $nb if $type == $DIRECTORY;
0;
};
resize_fat::c_rewritten::allocate_fat_flag($fs->{nb_clusters} + 2);
+
+ #- patch to reset contents of memory allocated by allocate_fat_flag
+ foreach (0..$fs->{nb_clusters} + 1) { resize_fat::c_rewritten::set_flag($_, 0) }
+
resize_fat::directory::traverse_all($fs, $f);
$fs->{clusters}{count}{dirs} = $nb_dirs;
}