summaryrefslogtreecommitdiffstats
path: root/perl-install/resize_fat
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/resize_fat')
-rw-r--r--perl-install/resize_fat/.cvsignore5
-rwxr-xr-x[-rw-r--r--]perl-install/resize_fat/Makefile.PL0
-rw-r--r--perl-install/resize_fat/README2
-rw-r--r--perl-install/resize_fat/any.pm13
-rw-r--r--perl-install/resize_fat/boot_sector.pm6
-rw-r--r--perl-install/resize_fat/c_rewritten.pm2
-rw-r--r--perl-install/resize_fat/c_rewritten.xs10
-rw-r--r--perl-install/resize_fat/dir_entry.pm2
-rw-r--r--perl-install/resize_fat/directory.pm2
-rw-r--r--perl-install/resize_fat/fat.pm4
-rw-r--r--perl-install/resize_fat/info_sector.pm2
-rw-r--r--perl-install/resize_fat/io.pm14
-rw-r--r--perl-install/resize_fat/main.pm9
13 files changed, 33 insertions, 38 deletions
diff --git a/perl-install/resize_fat/.cvsignore b/perl-install/resize_fat/.cvsignore
deleted file mode 100644
index 3001c7424..000000000
--- a/perl-install/resize_fat/.cvsignore
+++ /dev/null
@@ -1,5 +0,0 @@
-blib
-pm_to_blib
-Makefile_c
-c_rewritten.c
-c_rewritten.bs
diff --git a/perl-install/resize_fat/Makefile.PL b/perl-install/resize_fat/Makefile.PL
index 712f4e395..712f4e395 100644..100755
--- a/perl-install/resize_fat/Makefile.PL
+++ b/perl-install/resize_fat/Makefile.PL
diff --git a/perl-install/resize_fat/README b/perl-install/resize_fat/README
index 12b64dea9..ad5656f0b 100644
--- a/perl-install/resize_fat/README
+++ b/perl-install/resize_fat/README
@@ -5,4 +5,4 @@ resize_fat::fat::update($fs) should be called before doing undoable things
BUGS:
no known bugs :)
-if you found one, please mail pixel@mandrakesoft.com !!
+if you found one, please mail pixel !!
diff --git a/perl-install/resize_fat/any.pm b/perl-install/resize_fat/any.pm
index ccc0d4845..fc3c438eb 100644
--- a/perl-install/resize_fat/any.pm
+++ b/perl-install/resize_fat/any.pm
@@ -1,4 +1,4 @@
-package resize_fat::any; # $Id$
+package resize_fat::any;
use diagnostics;
use strict;
@@ -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);
@@ -110,7 +118,6 @@ sub flag_clusters {
} else { return }
my $nb = resize_fat::c_rewritten::checkFat($cluster, $type, "$curr_dir_name/$entry->{name}");
- print "resize_fat:flag_clusters: check fat returned $nb of type $type for $curr_dir_name/$entry->{name}\n";
$nb_dirs += $nb if $type == $DIRECTORY;
0;
};
diff --git a/perl-install/resize_fat/boot_sector.pm b/perl-install/resize_fat/boot_sector.pm
index ffb1b1f34..f93647579 100644
--- a/perl-install/resize_fat/boot_sector.pm
+++ b/perl-install/resize_fat/boot_sector.pm
@@ -1,4 +1,4 @@
-package resize_fat::boot_sector; # $Id$
+package resize_fat::boot_sector;
use diagnostics;
use strict;
@@ -57,7 +57,7 @@ sub read($) {
$fs->{cluster_size} = $fs->{cluster_size_in_sectors} * $fs->{sector_size};
$fs->{boot_sign} == 0xAA55 or die "Invalid signature for a MS-based filesystem.\n";
- $fs->{nb_sectors} < 32 and die "Too few sectors for viable file system\n";
+ $fs->{nb_sectors} < 32 and die "Too few sectors for viable filesystem\n";
$fs->{nb_fats} == 2 or cdie "Weird number of FATs: $fs->{nb_fats}, not 2.\n";
$fs->{sector_size} == 512 or cdie "Strange sector_size != 512\n";
@@ -87,7 +87,7 @@ sub read($) {
$fs->{nb_fat_entries} = divide($fs->{fat_size}, $fs->{fs_type_size} / 8);
- #- - 2 because clusters 0 & 1 doesn't exist
+ #- - 2 because clusters 0 & 1 does not exist
$fs->{nb_clusters} = divide($fs->{nb_sectors} * $fs->{sector_size} - $fs->{cluster_offset}, $fs->{cluster_size}) - 2;
$fs->{dir_entries_per_cluster} = divide($fs->{cluster_size}, psizeof($format));
diff --git a/perl-install/resize_fat/c_rewritten.pm b/perl-install/resize_fat/c_rewritten.pm
index bc0548314..39ba9253f 100644
--- a/perl-install/resize_fat/c_rewritten.pm
+++ b/perl-install/resize_fat/c_rewritten.pm
@@ -1,4 +1,4 @@
-package resize_fat::c_rewritten; # $Id$
+package resize_fat::c_rewritten;
use strict;
diff --git a/perl-install/resize_fat/c_rewritten.xs b/perl-install/resize_fat/c_rewritten.xs
index 92361097d..2bca483c0 100644
--- a/perl-install/resize_fat/c_rewritten.xs
+++ b/perl-install/resize_fat/c_rewritten.xs
@@ -40,12 +40,18 @@ void set_next(unsigned int cluster, unsigned int val) {
free_all();
croak("fat::set_next: cluster %d outside filesystem", cluster);
}
- type_size == 1 ? *p : *((unsigned int *) p) = val;
+ if (type_size == 1)
+ *p = val;
+ else
+ *((unsigned int *) p) = val;
}
MODULE = resize_fat::c_rewritten PACKAGE = resize_fat::c_rewritten
-void
+PROTOTYPES: DISABLE
+
+
+void
read_fat(fd, offset, size, magic)
int fd
int offset
diff --git a/perl-install/resize_fat/dir_entry.pm b/perl-install/resize_fat/dir_entry.pm
index 130bac7c8..27d2ea33f 100644
--- a/perl-install/resize_fat/dir_entry.pm
+++ b/perl-install/resize_fat/dir_entry.pm
@@ -1,4 +1,4 @@
-package resize_fat::dir_entry; # $Id$
+package resize_fat::dir_entry;
use diagnostics;
use strict;
diff --git a/perl-install/resize_fat/directory.pm b/perl-install/resize_fat/directory.pm
index 6f8ae9445..9c04fb62b 100644
--- a/perl-install/resize_fat/directory.pm
+++ b/perl-install/resize_fat/directory.pm
@@ -1,4 +1,4 @@
-package resize_fat::directory; # $Id$
+package resize_fat::directory;
use diagnostics;
use strict;
diff --git a/perl-install/resize_fat/fat.pm b/perl-install/resize_fat/fat.pm
index c08232628..20145982b 100644
--- a/perl-install/resize_fat/fat.pm
+++ b/perl-install/resize_fat/fat.pm
@@ -1,4 +1,4 @@
-package resize_fat::fat; # $Id$
+package resize_fat::fat;
use diagnostics;
use strict;
@@ -30,7 +30,7 @@ sub write($) {
#- allocates where all the clusters will be moved to. Clusters before cut_point
#- remain in the same position, however cluster that are part of a directory are
#- moved regardless (this is a mechanism to prevent data loss) (cut_point is the
-#- first cluster that won't occur in the new fs)
+#- first cluster that will not occur in the new fs)
sub allocate_remap {
my ($fs, $cut_point) = @_;
my ($cluster, $new_cluster);
diff --git a/perl-install/resize_fat/info_sector.pm b/perl-install/resize_fat/info_sector.pm
index 11aa7f153..47de2db1c 100644
--- a/perl-install/resize_fat/info_sector.pm
+++ b/perl-install/resize_fat/info_sector.pm
@@ -1,4 +1,4 @@
-package resize_fat::info_sector; # $Id$
+package resize_fat::info_sector;
use diagnostics;
use strict;
diff --git a/perl-install/resize_fat/io.pm b/perl-install/resize_fat/io.pm
index 7ece56533..78e3a3724 100644
--- a/perl-install/resize_fat/io.pm
+++ b/perl-install/resize_fat/io.pm
@@ -1,4 +1,4 @@
-package resize_fat::io; # $Id$
+package resize_fat::io;
use diagnostics;
use strict;
@@ -50,21 +50,9 @@ sub read_file($$) {
$buf;
}
-sub check_mounted($) {
- my ($f) = @_;
-
- local *F;
- open F, "/proc/mounts" or die "error opening /proc/mounts\n";
- foreach (<F>) {
- /^$f\s/ and die "device is mounted";
- }
-}
-
sub open {
my ($fs) = @_;
- check_mounted($fs->{device});
-
sysopen $fs->{fd}, $fs->{fs_name}, 2 or
sysopen $fs->{fd}, $fs->{fs_name}, 0 or die "error opening device $fs->{fs_name} for writing\n";
}
diff --git a/perl-install/resize_fat/main.pm b/perl-install/resize_fat/main.pm
index 3e82c71a3..681aec756 100644
--- a/perl-install/resize_fat/main.pm
+++ b/perl-install/resize_fat/main.pm
@@ -1,4 +1,4 @@
-package resize_fat::main; # $Id$
+package resize_fat::main;
# This is mainly a perl rewrite of the work of Andrew Clausen (libresize)
@@ -7,7 +7,6 @@ use strict;
use log;
use common;
-use MDK::Common::System;
use resize_fat::boot_sector;
use resize_fat::info_sector;
use resize_fat::directory;
@@ -45,7 +44,7 @@ sub DESTROY {
#- copy all clusters >= <start_cluster> to a new place on the partition, less
#- than <start_cluster>. Only copies files, not directories.
-#- (use of buffer needed because the seeks slow like hell the hard drive)
+#- (use of buffer needed because the seeks slow like hell the hard disk drive)
sub copy_clusters {
my ($fs, $cluster) = @_;
my @buffer;
@@ -71,7 +70,7 @@ sub construct_dir_tree {
if ($resize_fat::isFAT32) {
#- fat32's root must remain in the first 64k clusters
- #- so don't set it as DIRECTORY, it will be specially handled
+ #- so do not set it as DIRECTORY, it will be specially handled
resize_fat::c_rewritten::set_flag($fs->{fat32_root_dir_cluster}, $resize_fat::any::FREE);
}
@@ -158,7 +157,7 @@ sub resize {
resize_fat::boot_sector::write($fs);
- $resize_fat::isFAT32 and eval { resize_fat::info_sector::write($fs) }; #- doesn't matter if this fails - its pretty useless!
+ $resize_fat::isFAT32 and eval { resize_fat::info_sector::write($fs) }; #- does not matter if this fails - its pretty useless!
MDK::Common::System::sync();
close $fs->{fd};