From 1b1814210966f20efdf911da57c5d15a282112a5 Mon Sep 17 00:00:00 2001 From: Pascal Terjan Date: Thu, 15 Apr 2010 12:45:18 +0000 Subject: - Allow resizing empty FAT (#58770) --- perl-install/resize_fat/any.pm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'perl-install/resize_fat') diff --git a/perl-install/resize_fat/any.pm b/perl-install/resize_fat/any.pm index 59ec02098..99478661a 100644 --- a/perl-install/resize_fat/any.pm +++ b/perl-install/resize_fat/any.pm @@ -86,7 +86,15 @@ sub max_size($) { sub used_size($) { my ($fs) = @_; - my $used_cluster_count = max(last_used($fs), min_cluster_count($fs)); + my $last_used; + my $used_cluster_count; + + eval { $last_used = last_used($fs) }; + if ($@) { + # Empty FAT + $last_used = 0; + } + $used_cluster_count = max($last_used, min_cluster_count($fs)); $used_cluster_count * divide($fs->{cluster_size}, $SECTORSIZE) + divide($fs->{cluster_offset}, $SECTORSIZE); -- cgit v1.2.1