summaryrefslogtreecommitdiffstats
path: root/perl-install/partition_table_dos.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2001-10-19 11:23:35 +0000
committerPascal Rigaux <pixel@mandriva.com>2001-10-19 11:23:35 +0000
commit071da3cb69853ddae845b603d373c84600dbbfef (patch)
treeedfd96afc857c926f8c7904e3299d1c08932ad5d /perl-install/partition_table_dos.pm
parent3dce65778c396390312ed89798e619a6a60b7389 (diff)
downloaddrakx-backup-do-not-use-071da3cb69853ddae845b603d373c84600dbbfef.tar
drakx-backup-do-not-use-071da3cb69853ddae845b603d373c84600dbbfef.tar.gz
drakx-backup-do-not-use-071da3cb69853ddae845b603d373c84600dbbfef.tar.bz2
drakx-backup-do-not-use-071da3cb69853ddae845b603d373c84600dbbfef.tar.xz
drakx-backup-do-not-use-071da3cb69853ddae845b603d373c84600dbbfef.zip
better handling of CHS overflow (mainly for non cylinder-boundary aligned part (like ia64))
Diffstat (limited to 'perl-install/partition_table_dos.pm')
-rw-r--r--perl-install/partition_table_dos.pm19
1 files changed, 12 insertions, 7 deletions
diff --git a/perl-install/partition_table_dos.pm b/perl-install/partition_table_dos.pm
index 0358be6de..00ee589b9 100644
--- a/perl-install/partition_table_dos.pm
+++ b/perl-install/partition_table_dos.pm
@@ -23,19 +23,24 @@ sub hasExtended { 1 }
sub compute_CHS($$) {
my ($hd, $e) = @_;
my @l = qw(cyl head sec);
- @$e{map { "start_$_" } @l} = $e->{start} || $e->{type} ? CHS2rawCHS(sector2CHS($hd, $e->{start})) : (0,0,0);
- @$e{map { "end_$_" } @l} = $e->{start} || $e->{type} ? CHS2rawCHS(sector2CHS($hd, $e->{start} + $e->{size} - 1)) : (0,0,0);
+ @$e{map { "start_$_" } @l} = $e->{start} || $e->{type} ? CHS2rawCHS($hd, sector2CHS($hd, $e->{start})) : (0,0,0);
+ @$e{map { "end_$_" } @l} = $e->{start} || $e->{type} ? CHS2rawCHS($hd, sector2CHS($hd, $e->{start} + $e->{size} - 1)) : (0,0,0);
1;
}
-sub CHS2rawCHS($$$) {
- my ($c, $h, $s) = @_;
- $c = min($c, 1023); #- no way to have a #cylinder >= 1024
+sub CHS2rawCHS {
+ my ($hd, $c, $h, $s) = @_;
+ if ($c > 1023) {
+ #- no way to have a #cylinder >= 1024
+ $c = 1023;
+ $h = $hd->{geom}{heads} - 1;
+ $s = $hd->{geom}{sectors};
+ }
($c & 0xff, $h, $s | ($c >> 2 & 0xc0));
}
# returns (cylinder, head, sector)
-sub sector2CHS($$) {
+sub sector2CHS {
my ($hd, $start) = @_;
my ($s, $h);
($start, $s) = divide($start, $hd->{geom}{sectors});
@@ -43,7 +48,7 @@ sub sector2CHS($$) {
($start, $h, $s + 1);
}
-sub read($$) {
+sub read {
my ($hd, $sector) = @_;
my $tmp;