diff options
Diffstat (limited to 'perl-install/resize_fat')
-rw-r--r-- | perl-install/resize_fat/any.pm | 4 | ||||
-rw-r--r-- | perl-install/resize_fat/boot_sector.pm | 5 | ||||
-rw-r--r-- | perl-install/resize_fat/info_sector.pm | 2 | ||||
-rw-r--r-- | perl-install/resize_fat/main.pm | 7 |
4 files changed, 7 insertions, 11 deletions
diff --git a/perl-install/resize_fat/any.pm b/perl-install/resize_fat/any.pm index d78a342be..8c57eb6b0 100644 --- a/perl-install/resize_fat/any.pm +++ b/perl-install/resize_fat/any.pm @@ -21,11 +21,11 @@ $DIRECTORY = 2; # returns the number of clusters for a given filesystem type sub min_cluster_count($) { my ($fs) = @_; - (1 << $ {{ FAT16 => 12, FAT32 => 16 }}{$fs->{fs_type}}) - 12; + (1 << $ {{ FAT16 => 12, FAT32 => 12 }}{$fs->{fs_type}}) - 12; } sub max_cluster_count($) { my ($fs) = @_; - $resize_fat::bad_cluster_value - 2; + 2 ** $fs->{fs_type_size} - 11; } diff --git a/perl-install/resize_fat/boot_sector.pm b/perl-install/resize_fat/boot_sector.pm index c236b1617..cd8f52cac 100644 --- a/perl-install/resize_fat/boot_sector.pm +++ b/perl-install/resize_fat/boot_sector.pm @@ -64,6 +64,7 @@ sub read($) { $fs->{fs_type} = 'FAT16'; $fs->{fs_type_size} = 16; $fs->{fat_length} = $fs->{fat16_fat_length}; + $resize_fat::bad_cluster_value = 0xfff7; # 2**16 - 1 } else { $resize_fat::isFAT32 = 1; $fs->{fs_type} = 'FAT32'; @@ -72,8 +73,8 @@ sub read($) { $fs->{nb_root_dir_entries} = 0; $fs->{info_offset} = $fs->{info_offset_in_sectors} * $fs->{sector_size}; + $resize_fat::bad_cluster_value = 0xffffff7; } - $resize_fat::bad_cluster_value = (1 << $fs->{fs_type_size}) - 9; $fs->{fat_offset} = $fs->{nb_reserved} * $fs->{sector_size}; $fs->{fat_size} = $fs->{fat_length} * $fs->{sector_size}; @@ -88,7 +89,7 @@ sub read($) { $fs->{dir_entries_per_cluster} = divide($fs->{cluster_size}, psizeof($format)); - $fs->{nb_clusters} >= resize_fat::any::min_cluster_count($fs) or die "error: not enough sectors for a $fs->{fs_type}\n"; +# $fs->{nb_clusters} >= resize_fat::any::min_cluster_count($fs) or die "error: not enough sectors for a $fs->{fs_type}\n"; $fs->{nb_clusters} < resize_fat::any::max_cluster_count($fs) or die "error: too many sectors for a $fs->{fs_type}\n"; } diff --git a/perl-install/resize_fat/info_sector.pm b/perl-install/resize_fat/info_sector.pm index c46ae15fc..5b92501ea 100644 --- a/perl-install/resize_fat/info_sector.pm +++ b/perl-install/resize_fat/info_sector.pm @@ -20,7 +20,7 @@ my @fields = ( sub read($) { my ($fs) = @_; - my $info = resize_fat::io::read($fs, $fs->{offset}, psizeof($format)); + my $info = resize_fat::io::read($fs, $fs->{info_offset}, psizeof($format)); @{$fs->{info_sector}}{@fields} = unpack $format, $info; $fs->{info_sector}->{signature} == 0x61417272 or die "Invalid information sector signature\n"; } diff --git a/perl-install/resize_fat/main.pm b/perl-install/resize_fat/main.pm index 2d5f4f969..d9f7a2181 100644 --- a/perl-install/resize_fat/main.pm +++ b/perl-install/resize_fat/main.pm @@ -15,11 +15,6 @@ use resize_fat::fat; use resize_fat::any; -#@ARGV == 2 or die "usage: fatresize <device> <size>\n <size> = 100 means `resize to 100Mb'\n <size> = +10 means `keep 10Mb of free space'\n"; -# -#my $fs = init($ARGV[0]); -#resize($fs, $ARGV[1]); - 1; # - reads in the boot sector/partition info., and tries to make some sense of it @@ -134,7 +129,7 @@ sub resize { $fs->{nb_sectors} = $size; $fs->{nb_clusters} = $new_nb_clusters; $fs->{clusters}->{count}->{free} = - $fs->{nb_clusters} - $fs->{clusters}->{count}->{used} - $fs->{clusters}->{count}->{bad}; + $fs->{nb_clusters} - $fs->{clusters}->{count}->{used} - $fs->{clusters}->{count}->{bad} - 2; $fs->{system_id} = 'was here!'; $fs->{small_nb_sectors} = 0; |