From e1729dfdb9c341fe0b9fed7d7b0a80691a547d82 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Thu, 1 Jul 1999 12:29:54 +0000 Subject: "See_The_Changelog" --- perl-install/resize_fat/info_sector.pm | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 perl-install/resize_fat/info_sector.pm (limited to 'perl-install/resize_fat/info_sector.pm') diff --git a/perl-install/resize_fat/info_sector.pm b/perl-install/resize_fat/info_sector.pm new file mode 100644 index 000000000..c46ae15fc --- /dev/null +++ b/perl-install/resize_fat/info_sector.pm @@ -0,0 +1,36 @@ +package resize_fat::info_sector; + +use diagnostics; +use strict; + +use common qw(:system); +use resize_fat::io; + +my $format = "a484 I I I a16"; +my @fields = ( + 'unused', + 'signature', # should be 0x61417272 + 'free_clusters', # -1 for unknown + 'next_cluster', # most recently allocated cluster + 'unused2', +); + +1; + + +sub read($) { + my ($fs) = @_; + my $info = resize_fat::io::read($fs, $fs->{offset}, psizeof($format)); + @{$fs->{info_sector}}{@fields} = unpack $format, $info; + $fs->{info_sector}->{signature} == 0x61417272 or die "Invalid information sector signature\n"; +} + +sub write($) { + my ($fs) = @_; + $fs->{info_sector}->{free_clusters} = $fs->{clusters}->{count}->{free}; + $fs->{info_sector}->{next_cluster} = 2; + + my $info = pack $format, @{$fs->{info_sector}}{@fields}; + + resize_fat::io::write($fs, $fs->{info_offset}, psizeof($format), $info); +} -- cgit v1.2.1