diff options
author | Pascal Rigaux <pixel@mandriva.com> | 1999-09-09 09:02:47 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 1999-09-09 09:02:47 +0000 |
commit | 1d3ac921d66022bb6e19a96dce95472cc31f0987 (patch) | |
tree | 4da18678cee71134f6cec6004f0b41afe6d25145 /perl-install/resize_fat | |
parent | db4013c2a40eaeb3752cc69623037e4bb274693b (diff) | |
download | drakx-1d3ac921d66022bb6e19a96dce95472cc31f0987.tar drakx-1d3ac921d66022bb6e19a96dce95472cc31f0987.tar.gz drakx-1d3ac921d66022bb6e19a96dce95472cc31f0987.tar.bz2 drakx-1d3ac921d66022bb6e19a96dce95472cc31f0987.tar.xz drakx-1d3ac921d66022bb6e19a96dce95472cc31f0987.zip |
no_comment
Diffstat (limited to 'perl-install/resize_fat')
-rw-r--r-- | perl-install/resize_fat/any.pm | 16 | ||||
-rw-r--r-- | perl-install/resize_fat/boot_sector.pm | 58 | ||||
-rw-r--r-- | perl-install/resize_fat/dir_entry.pm | 8 | ||||
-rw-r--r-- | perl-install/resize_fat/directory.pm | 16 | ||||
-rw-r--r-- | perl-install/resize_fat/fat.pm | 26 | ||||
-rw-r--r-- | perl-install/resize_fat/info_sector.pm | 6 | ||||
-rw-r--r-- | perl-install/resize_fat/main.pm | 32 |
7 files changed, 81 insertions, 81 deletions
diff --git a/perl-install/resize_fat/any.pm b/perl-install/resize_fat/any.pm index e4747dc87..26c98f886 100644 --- a/perl-install/resize_fat/any.pm +++ b/perl-install/resize_fat/any.pm @@ -18,7 +18,7 @@ $DIRECTORY = 2; 1; -# returns the number of clusters for a given filesystem type +#- returns the number of clusters for a given filesystem type sub min_cluster_count($) { my ($fs) = @_; (1 << $ {{ FAT16 => 12, FAT32 => 12 }}{$fs->{fs_type}}) - 12; @@ -30,20 +30,20 @@ sub max_cluster_count($) { -# calculates the minimum size of a partition, in physical sectors +#- calculates the minimum size of a partition, in physical sectors sub min_size($) { my ($fs) = @_; my $count = $fs->{clusters}{count}; - # directories are both in `used' and `dirs', so are counted twice - # It's done on purpose since we're moving all directories. So at the worse - # moment, 2 directories are there, but that way nothing wrong can happen :) + #- directories are both in `used' and `dirs', so are counted twice + #- It's done on purpose since we're moving all directories. So at the worse + #- moment, 2 directories are there, but that way nothing wrong can happen :) my $min_cluster_count = max(2 + $count->{used} + $count->{bad} + $count->{dirs}, min_cluster_count($fs)); $min_cluster_count * divide($fs->{cluster_size}, $SECTORSIZE) + divide($fs->{cluster_offset}, $SECTORSIZE); } -# calculates the maximum size of a partition, in physical sectors +#- calculates the maximum size of a partition, in physical sectors sub max_size($) { my ($fs) = @_; @@ -53,8 +53,8 @@ sub max_size($) { divide($fs->{cluster_offset}, $SECTORSIZE); } -# fills in $fs->{fat_flag_map}. -# Each FAT entry is flagged as either FREE, FILE or DIRECTORY. +#- fills in $fs->{fat_flag_map}. +#- Each FAT entry is flagged as either FREE, FILE or DIRECTORY. sub flag_clusters { my ($fs) = @_; my ($cluster, $entry, $type); diff --git a/perl-install/resize_fat/boot_sector.pm b/perl-install/resize_fat/boot_sector.pm index cd8f52cac..6da81e420 100644 --- a/perl-install/resize_fat/boot_sector.pm +++ b/perl-install/resize_fat/boot_sector.pm @@ -11,41 +11,41 @@ use resize_fat::directory; my $format = "a3 a8 S C S C S S C S S S I I I S S I S S a458 S"; my @fields = ( - 'boot_jump', # boot strap short or near jump - 'system_id', # Name - can be used to special case partition manager volumes - 'sector_size', # bytes per logical sector - 'cluster_size_in_sectors', # sectors/cluster - 'nb_reserved', # reserved sectors - 'nb_fats', # number of FATs - 'nb_root_dir_entries', # number of root directory entries - 'small_nb_sectors', # number of sectors: big_nb_sectors supersedes - 'media', # media code - 'fat16_fat_length', # sectors/FAT for FAT12/16 + 'boot_jump', #- boot strap short or near jump + 'system_id', #- Name - can be used to special case partition manager volumes + 'sector_size', #- bytes per logical sector + 'cluster_size_in_sectors', #- sectors/cluster + 'nb_reserved', #- reserved sectors + 'nb_fats', #- number of FATs + 'nb_root_dir_entries', #- number of root directory entries + 'small_nb_sectors', #- number of sectors: big_nb_sectors supersedes + 'media', #- media code + 'fat16_fat_length', #- sectors/FAT for FAT12/16 'sectors_per_track', 'nb_heads', - 'nb_hidden', # (unused) - 'big_nb_sectors', # number of sectors (if small_nb_sectors == 0) - -# FAT32-only entries - 'fat32_fat_length', # size of FAT in sectors - 'fat32_flags', # bit8: fat mirroring, - # low4: active fat - 'fat32_version', # minor * 256 + major + 'nb_hidden', #- (unused) + 'big_nb_sectors', #- number of sectors (if small_nb_sectors == 0) + +#- FAT32-only entries + 'fat32_fat_length', #- size of FAT in sectors + 'fat32_flags', #- bit8: fat mirroring, + #- low4: active fat + 'fat32_version', #- minor * 256 + major 'fat32_root_dir_cluster', 'info_offset_in_sectors', 'fat32_backup_sector', -# Common again... - 'boot_code', # Boot code (or message) - 'boot_sign', # 0xAA55 +#- Common again... + 'boot_code', #- Boot code (or message) + 'boot_sign', #- 0xAA55 ); 1; -# trimfs_init_boot_sector() - reads in the boot sector - gets important info out -# of boot sector, and puts in main structure - performs sanity checks - returns 1 -# on success, 0 on failureparameters: filesystem an empty structure to fill. +#- trimfs_init_boot_sector() - reads in the boot sector - gets important info out +#- of boot sector, and puts in main structure - performs sanity checks - returns 1 +#- on success, 0 on failureparameters: filesystem an empty structure to fill. sub read($) { my ($fs) = @_; @@ -60,11 +60,11 @@ sub read($) { $fs->{nb_sectors} < 32 and die "Too few sectors for viable file system\n"; if ($fs->{fat16_fat_length}) { - # asserting FAT16, will be verified later on + #- asserting FAT16, will be verified later on $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 + $resize_fat::bad_cluster_value = 0xfff7; #- 2**16 - 1 } else { $resize_fat::isFAT32 = 1; $fs->{fs_type} = 'FAT32'; @@ -84,12 +84,12 @@ 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 doesn't 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)); -# $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"; } @@ -100,7 +100,7 @@ sub write($) { eval { resize_fat::io::write($fs, 0, $SECTORSIZE, $boot) }; $@ and die "writing the boot sector failed on device $fs->{fs_name}"; if ($resize_fat::isFAT32) { - # write backup + #- write backup eval { resize_fat::io::write($fs, $fs->{fat32_backup_sector} * $SECTORSIZE, $SECTORSIZE, $boot) }; $@ and die "writing the backup boot sector (#$fs->{fat32_backup_sector}) failed on device $fs->{fs_name}"; } diff --git a/perl-install/resize_fat/dir_entry.pm b/perl-install/resize_fat/dir_entry.pm index fa5ebb344..47f326735 100644 --- a/perl-install/resize_fat/dir_entry.pm +++ b/perl-install/resize_fat/dir_entry.pm @@ -46,7 +46,7 @@ sub is_special_entry($) { my ($entry) = @_; my ($c) = unpack "C", $entry->{name}; - # skip empty slots, deleted files, and 0xF6?? (taken from kernel) + #- skip empty slots, deleted files, and 0xF6?? (taken from kernel) $c == 0 || $c == $DELETED_FLAG || $c == 0xF6 and return 1; $entry->{attributes} == $VFAT_ATTR and return 1; @@ -54,7 +54,7 @@ sub is_special_entry($) { } -# return true if entry has been modified +#- return true if entry has been modified sub remap { my ($fat_remap, $entry) = @_; @@ -63,9 +63,9 @@ sub remap { my $cluster = get_cluster($entry); my $new_cluster = $fat_remap->[$cluster]; - #print "remapping cluster ", get_first_cluster($fs, $entry), " to $new_cluster"; + #-print "remapping cluster ", get_first_cluster($fs, $entry), " to $new_cluster"; - $new_cluster == $cluster and return; # no need to modify + $new_cluster == $cluster and return; #- no need to modify set_cluster($entry, $new_cluster); 1; diff --git a/perl-install/resize_fat/directory.pm b/perl-install/resize_fat/directory.pm index 00ae6a870..3b779e2de 100644 --- a/perl-install/resize_fat/directory.pm +++ b/perl-install/resize_fat/directory.pm @@ -14,11 +14,11 @@ my @fields = ( 'extension', 'attributes', 'is_upper_case_name', - 'creation_time_low', # milliseconds + 'creation_time_low', #- milliseconds 'creation_time_high', 'creation_date', 'access_date', - 'first_cluster_high', # for FAT32 + 'first_cluster_high', #- for FAT32 'time', 'date', 'first_cluster', @@ -29,15 +29,15 @@ my @fields = ( sub entry_size { psizeof($format) } -# call `f' for each entry of the directory -# if f return true, then modification in the entry are taken back +#- call `f' for each entry of the directory +#- if f return true, then modification in the entry are taken back sub traverse($$$) { my ($fs, $directory, $f) = @_; for (my $i = 0;; $i++) { my $raw = \substr($directory, $i * psizeof($format), psizeof($format)); - # empty entry means end of directory + #- empty entry means end of directory $$raw =~ /^\0*$/ and return $directory; my $entry; @{$entry}{@fields} = unpack $format, $$raw; @@ -59,7 +59,7 @@ sub traverse_all($$) { resize_fat::dir_entry::is_directory($entry) and traverse($fs, resize_fat::io::read_file($fs, resize_fat::dir_entry::get_cluster($entry)), $traverse_all); - undef; # no need to write back (cf traverse) + undef; #- no need to write back (cf traverse) }; my $directory = $resize_fat::isFAT32 ? @@ -69,8 +69,8 @@ sub traverse_all($$) { } -# function used by construct_dir_tree to translate the `cluster' fields in each -# directory entry +#- function used by construct_dir_tree to translate the `cluster' fields in each +#- directory entry sub remap { my ($fs, $directory) = @_; diff --git a/perl-install/resize_fat/fat.pm b/perl-install/resize_fat/fat.pm index 87ce2af71..5c0b259b4 100644 --- a/perl-install/resize_fat/fat.pm +++ b/perl-install/resize_fat/fat.pm @@ -42,10 +42,10 @@ 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) +#- 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) sub allocate_remap { my ($fs, $cut_point) = @_; my ($cluster, $new_cluster); @@ -53,8 +53,8 @@ sub allocate_remap { my $get_new = sub { $new_cluster = get_free($fs); 0 < $new_cluster && $new_cluster < $cut_point or die "no free clusters"; - set_eof($fs, $new_cluster); # mark as used - #log::ld("resize_fat: [$cluster,", &next($fs, $cluster), "...]->$new_cluster..."); + set_eof($fs, $new_cluster); #- mark as used + #-log::ld("resize_fat: [$cluster,", &next($fs, $cluster), "...]->$new_cluster..."); }; $fs->{fat_remap}[0] = 0; @@ -75,7 +75,7 @@ sub allocate_remap { } -# updates the fat for the resized filesystem +#- updates the fat for the resized filesystem sub update { my ($fs) = @_; @@ -95,9 +95,9 @@ sub update { } -# - compares the two FATs (one's a backup that should match) - skips first entry -# - its just a signature (already checked above) NOTE: checks for cross-linking -# are done in count.c +#- - compares the two FATs (one's a backup that should match) - skips first entry +#- - its just a signature (already checked above) NOTE: checks for cross-linking +#- are done in count.c sub check($) { my ($fs) = @_; foreach (@{$fs->{fats}}) { @@ -140,7 +140,7 @@ sub get_free($) { die "no free clusters"; } -# returns true if <cluster> represents an EOF marker +#- returns true if <cluster> represents an EOF marker sub is_eof($) { my ($cluster) = @_; $cluster >= $resize_fat::bad_cluster_value; @@ -150,13 +150,13 @@ sub set_eof($$) { set_next($fs, $cluster, $resize_fat::bad_cluster_value + 1); } -# returns true if <cluster> is empty. Note that this includes bad clusters. +#- returns true if <cluster> is empty. Note that this includes bad clusters. sub is_empty($) { my ($cluster) = @_; $cluster == 0 || $cluster == $resize_fat::bad_cluster_value; } -# returns true if <cluster> is available. +#- returns true if <cluster> is available. sub is_available($) { my ($cluster) = @_; $cluster == 0; diff --git a/perl-install/resize_fat/info_sector.pm b/perl-install/resize_fat/info_sector.pm index 2eacf58ca..3a6f7cfed 100644 --- a/perl-install/resize_fat/info_sector.pm +++ b/perl-install/resize_fat/info_sector.pm @@ -9,9 +9,9 @@ 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 + 'signature', #- should be 0x61417272 + 'free_clusters', #- -1 for unknown + 'next_cluster', #- most recently allocated cluster 'unused2', ); diff --git a/perl-install/resize_fat/main.pm b/perl-install/resize_fat/main.pm index 55cc34d7b..692ade0cb 100644 --- a/perl-install/resize_fat/main.pm +++ b/perl-install/resize_fat/main.pm @@ -36,7 +36,7 @@ use resize_fat::any; 1; -# - reads in the boot sector/partition info., and tries to make some sense of it +#- - reads in the boot sector/partition info., and tries to make some sense of it sub new($$$) { my ($type, $device, $fs_name) = @_; my $fs = { device => $device, fs_name => $fs_name } ; @@ -51,9 +51,9 @@ sub new($$$) { bless $fs, $type; } -# 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) +#- 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) sub copy_clusters { my ($fs, $cluster) = @_; my @buffer; @@ -71,13 +71,13 @@ sub copy_clusters { &$flush(); } -# Constructs the new directory tree to match the new file locations. +#- Constructs the new directory tree to match the new file locations. sub construct_dir_tree { my ($fs) = @_; 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 + #- fat32's root must remain in the first 64k clusters + #- so don't set it as DIRECTORY, it will be specially handled $fs->{fat_flag_map}[$fs->{fat32_root_dir_cluster}] = $resize_fat::any::FREE; } @@ -91,12 +91,12 @@ sub construct_dir_tree { sync(); - # until now, only free clusters have been written. it's a null operation if we stop here. - # it means no corruption :) + #- until now, only free clusters have been written. it's a null operation if we stop here. + #- it means no corruption :) # - # now we must be as fast as possible! + #- now we must be as fast as possible! - # remapping non movable root directory + #- remapping non movable root directory if ($resize_fat::isFAT32) { my $cluster = $fs->{fat32_root_dir_cluster}; @@ -112,10 +112,10 @@ sub construct_dir_tree { sub min_size($) { &resize_fat::any::min_size } sub max_size($) { &resize_fat::any::max_size } -# resize -# - size is in sectors -# - checks boundaries before starting -# - copies all data beyond new_cluster_count behind the frontier +#- resize +#- - size is in sectors +#- - checks boundaries before starting +#- - copies all data beyond new_cluster_count behind the frontier sub resize { my ($fs, $size) = @_; @@ -158,7 +158,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) }; #- doesn't matter if this fails - its pretty useless! sync(); log::l("resize_fat: done"); |