summaryrefslogtreecommitdiffstats
path: root/perl-install/resize_fat/info_sector.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>1999-10-09 13:26:41 +0000
committerPascal Rigaux <pixel@mandriva.com>1999-10-09 13:26:41 +0000
commitfc5950e2eb1f9c0b7a1553f5717940d880e4853c (patch)
treef8fa3478c37b137673fca970963558e564f0916e /perl-install/resize_fat/info_sector.pm
parent870d622c6e3ed5d9a81c84e3f3d0fc287733472f (diff)
downloaddrakx-backup-do-not-use-fc5950e2eb1f9c0b7a1553f5717940d880e4853c.tar
drakx-backup-do-not-use-fc5950e2eb1f9c0b7a1553f5717940d880e4853c.tar.gz
drakx-backup-do-not-use-fc5950e2eb1f9c0b7a1553f5717940d880e4853c.tar.bz2
drakx-backup-do-not-use-fc5950e2eb1f9c0b7a1553f5717940d880e4853c.tar.xz
drakx-backup-do-not-use-fc5950e2eb1f9c0b7a1553f5717940d880e4853c.zip
no_comment
Diffstat (limited to 'perl-install/resize_fat/info_sector.pm')
-rw-r--r--perl-install/resize_fat/info_sector.pm36
1 files changed, 36 insertions, 0 deletions
diff --git a/perl-install/resize_fat/info_sector.pm b/perl-install/resize_fat/info_sector.pm
new file mode 100644
index 000000000..3a6f7cfed
--- /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->{info_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);
+}