summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancois Pons <fpons@mandriva.com>2000-05-24 16:04:57 +0000
committerFrancois Pons <fpons@mandriva.com>2000-05-24 16:04:57 +0000
commit37f32e37d8870ec75af337258486ad00bc90848f (patch)
tree9fc976fca0d71a9d2744a4692e1fd34db0ca4fe4
parent0260588cd0fec3eebfb5c293d742df84ff4d8a75 (diff)
downloaddrakx-backup-do-not-use-37f32e37d8870ec75af337258486ad00bc90848f.tar
drakx-backup-do-not-use-37f32e37d8870ec75af337258486ad00bc90848f.tar.gz
drakx-backup-do-not-use-37f32e37d8870ec75af337258486ad00bc90848f.tar.bz2
drakx-backup-do-not-use-37f32e37d8870ec75af337258486ad00bc90848f.tar.xz
drakx-backup-do-not-use-37f32e37d8870ec75af337258486ad00bc90848f.zip
*** empty log message ***
-rw-r--r--perl-install/ChangeLog5
-rw-r--r--perl-install/install_any.pm1
-rw-r--r--perl-install/partition_table.pm16
-rw-r--r--perl-install/partition_table_sun.pm40
4 files changed, 39 insertions, 23 deletions
diff --git a/perl-install/ChangeLog b/perl-install/ChangeLog
index aca2013e9..07083b01f 100644
--- a/perl-install/ChangeLog
+++ b/perl-install/ChangeLog
@@ -1,3 +1,8 @@
+2000-05-24 François Pons <fpons@mandrakesoft.com>
+
+ * partition_table_sun.pm: fixed a bug when reading partition table
+ with unused partition in the middle of the table.
+
2000-05-23 François Pons <fpons@mandrakesoft.com>
* common.pm: update arch to take into account sparc and sparc64. added
diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm
index 9e02cb149..d1fb27060 100644
--- a/perl-install/install_any.pm
+++ b/perl-install/install_any.pm
@@ -327,6 +327,7 @@ sub getHds {
getHds:
$o->{hds} = catch_cdie { fsedit::hds(\@drives, $o->{partitioning}) }
sub {
+ log::l("error reading partition table: $@");
my ($err) = $@ =~ /(.*) at /;
$@ =~ /overlapping/ and $o->ask_warn('', $@), return 1;
$o->ask_okcancel(_("Error"),
diff --git a/perl-install/partition_table.pm b/perl-install/partition_table.pm
index e941a1529..84c7cfa5a 100644
--- a/perl-install/partition_table.pm
+++ b/perl-install/partition_table.pm
@@ -204,16 +204,16 @@ sub name2type($) {
}
sub isWholedisk($) { arch() =~ /^sparc/ && $_[0]{type} == 5 }
-sub isExtended($) { (arch() !~ /^sparc/ && $_[0]{type} == 5) || $_[0]{type} == 0xf || $_[0]{type} == 0x85 }
+sub isExtended($) { arch() !~ /^sparc/ && ($_[0]{type} == 5 || $_[0]{type} == 0xf || $_[0]{type} == 0x85) }
sub isRAID($) { $_[0]{type} == 0xfd }
sub isSwap($) { $type2fs{$_[0]{type}} eq 'swap' }
sub isExt2($) { $type2fs{$_[0]{type}} eq 'ext2' }
sub isReiserfs($) { $type2fs{$_[0]{type}} eq 'reiserfs' }
-sub isDos($) { $ {{ 1=>1, 4=>1, 6=>1 }}{$_[0]{type}} }
+sub isDos($) { arch() !~ /^sparc/ && $ {{ 1=>1, 4=>1, 6=>1 }}{$_[0]{type}} }
sub isWin($) { $ {{ 0xb=>1, 0xc=>1, 0xe=>1, 0x1b=>1, 0x1c=>1, 0x1e=>1 }}{$_[0]{type}} }
sub isFat($) { isDos($_[0]) || isWin($_[0]) }
sub isNfs($) { $_[0]{type} eq 'nfs' } #- small hack
-sub isNT($) { $_[0]{type} == 0x7 }
+sub isNT($) { arch() !~ /^sparc/ && $_[0]{type} == 0x7 }
sub isSupermount($) { $_[0]{type} eq 'supermount' }
sub isHFS($) { $type2fs{$_[0]{type}} eq 'hfs' }
sub isApplePartMap { defined $_[0]{isMap} }
@@ -359,17 +359,23 @@ sub read_one($$) {
my ($pt, $info);
#- SUN bioses may blank disk or refuse to load it if the partition is unknown.
- my @parttype = arch() =~ /^sparc/ ? ('sun', 'unknown') : ('dos', 'bsd', 'sun', 'mac', 'unknown');
+ my @parttype = arch() =~ /^sparc/ ? ('sun', 'bsd', 'unknown') : ('dos', 'bsd', 'sun', 'mac', 'unknown');
foreach (@parttype) {
/unknown/ and die "unknown partition table format";
eval {
bless $hd, "partition_table_$_";
($pt, $info) = $hd->read($sector);
+ log::l("found a $_ partition table on $hd->{file}");
+ {
+ foreach my $e (@$pt) {
+ my $logtext = join(" ", map { "$_=$e->{$_}" } keys %$e);
+ log::l("$logtext");
+ }
+ }
};
$@ or last;
}
-
my @extended = $hd->hasExtended ? grep { isExtended($_) } @$pt : ();
my @normal = grep { $_->{size} && $_->{type} && !isExtended($_) } @$pt;
diff --git a/perl-install/partition_table_sun.pm b/perl-install/partition_table_sun.pm
index 26371e598..c2f8ce9e9 100644
--- a/perl-install/partition_table_sun.pm
+++ b/perl-install/partition_table_sun.pm
@@ -11,12 +11,6 @@ use partition_table_raw;
use partition_table;
use c;
-#- very bad and rough handling :(
-my %typeToDos = (
- 5 => 0,
-);
-my %typeFromDos = reverse %typeToDos;
-
my ($main_format, $main_fields) = list2kv(
a128 => 'info',
a14 => 'spare0',
@@ -39,7 +33,7 @@ my ($main_format, $main_fields) = list2kv(
$main_format = join '', @$main_format;
my ($fields1, $fields2) = ([ qw(type flags) ], [ qw(start_cylinder size) ]);
-my ($format1, $format2) = ("x C x C", "N N");
+my ($format1, $format2) = ("xCxC", "N2");
my ($size1, $size2) = map { psizeof($_) } ($format1, $format2);
my $magic = 0xDABE;
my $nb_primary = 8;
@@ -97,17 +91,28 @@ sub read($$) {
#- check crc, csum contains the crc so result should be 0.
compute_crc($tmp) == 0 or die "bad checksum";
- @{$hd->{geom}}{qw(cylinders heads sectors)} = @info{qw(ncyl nsect ntrks)};
+ @{$hd->{geom}}{qw(cylinders heads sectors)} = @info{qw(ncyl ntrks nsect)};
+
+ my @pt;
+ my @infos_up = unpack $format1 x $nb_primary, $info{infos};
+ my @partitions_up = unpack $format2 x $nb_primary, $info{partitions};
+ for (0..$nb_primary-1) {
+ my $h = { type => $infos_up[2 * $_], flag => $infos_up[1 + 2 * $_],
+ start_cylinder => $partitions_up[2 * $_], size => $partitions_up[1 + 2 * $_] };
+ $h->{start} = $sector + $h->{start_cylinder} * $hd->cylinder_size();
+ $h->{type} && $h->{size} or $h->{$_} = 0 foreach keys %$h;
+ push @pt, $h;
+ }
- my @pt = mapn {
- my %h;
- @h{@$fields1} = unpack $format1, $_[0];
- @h{@$fields2} = unpack $format2, $_[1];
- $h{start} = $sector + $h{start_cylinder} * $hd->cylinder_size();
-# $h{type} = $typeToDos{$h{type}} || $h{type}; #- for rewrite it ?
- $h{size} or $h{$_} = 0 foreach keys %h;
- \%h;
- } [ $info{infos} =~ /(.{$size1})/g ], [ $info{partitions} =~ /(.{$size2})/g ];
+#- this code is completely broken by null char inside strings, it gets completely crazy :-)
+# my @pt = mapn {
+# my %h;
+# @h{@$fields1} = unpack $format1, $_[0];
+# @h{@$fields2} = unpack $format2, $_[1];
+# $h{start} = $sector + $h{start_cylinder} * $hd->cylinder_size();
+# $h{type} && $h{size} or $h{$_} = 0 foreach keys %h;
+# \%h;
+# } [ grep { $_ } split /(.{$size1})/o, $info{infos} ], [ grep { $_ } split /(.{$size2})/o, $info{partitions} ];
[ @pt ], \%info;
}
@@ -134,7 +139,6 @@ sub write($$$;$) {
# $wdsize += $_->{size} if $_->{type} == 5;
$_->{flags} |= 0x10 if $_->{mntpoint} eq '/';
$_->{flags} |= 0x01 if partition_table::isSwap($_);
-# local $_->{type} = $typeFromDos{$_->{type}} || $_->{type};
local $_->{start_cylinder} = $_->{start} / $hd->cylinder_size() - $sector;
pack($format1, @$_{@$fields1}), pack($format2, @$_{@$fields2});
} @$pt;