diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2001-10-18 22:09:38 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2001-10-18 22:09:38 +0000 |
commit | fbdf055c5f169b4605e8c7e3b4142dc92e22baee (patch) | |
tree | 15a815c0dec92435c70e853f870b166ed5af2b5f /perl-install | |
parent | 86d42155bc11e397d502e9876aad2dd3082946f4 (diff) | |
download | drakx-backup-do-not-use-fbdf055c5f169b4605e8c7e3b4142dc92e22baee.tar drakx-backup-do-not-use-fbdf055c5f169b4605e8c7e3b4142dc92e22baee.tar.gz drakx-backup-do-not-use-fbdf055c5f169b4605e8c7e3b4142dc92e22baee.tar.bz2 drakx-backup-do-not-use-fbdf055c5f169b4605e8c7e3b4142dc92e22baee.tar.xz drakx-backup-do-not-use-fbdf055c5f169b4605e8c7e3b4142dc92e22baee.zip |
- add checksum verif on partition entries
- detect the type of partition since the partition table types seem quite poor
Diffstat (limited to 'perl-install')
-rw-r--r-- | perl-install/fsedit.pm | 3 | ||||
-rw-r--r-- | perl-install/partition_table_gpt.pm | 20 |
2 files changed, 15 insertions, 8 deletions
diff --git a/perl-install/fsedit.pm b/perl-install/fsedit.pm index 1e22b87a6..f5a52ea8f 100644 --- a/perl-install/fsedit.pm +++ b/perl-install/fsedit.pm @@ -153,6 +153,9 @@ sub hds { member($_->{device}, @{$flags->{clear} || []}) and partition_table::remove($hd, $_) foreach partition_table::get_normal_parts($hd); + # special case for Various type + $_->{type} = typeOfPart($_->{device}) || 0x100 foreach grep { $_->{type} == 0x100 } partition_table::get_normal_parts($hd); + #- special case for type overloading (eg: reiserfs is 0x183) foreach (grep { isExt2($_) } partition_table::get_normal_parts($hd)) { my $type = typeOfPart($_->{device}); diff --git a/perl-install/partition_table_gpt.pm b/perl-install/partition_table_gpt.pm index d908a8103..55bc1a49f 100644 --- a/perl-install/partition_table_gpt.pm +++ b/perl-install/partition_table_gpt.pm @@ -68,14 +68,13 @@ sub crc32 { } $crc = ($crc >> 8) ^ $subcrc; } - $crc; + $crc ^ 0xFFFFFFFF; } -sub compute_crc { +sub compute_headerCRC32 { my ($info) = @_; local $info->{headerCRC32} = 0; - my $tmp = pack($main_format, @$info{@$main_fields}); - crc32($tmp) ^ 0xFFFFFFFF; + crc32(pack($main_format, @$info{@$main_fields})); } sub read { @@ -100,12 +99,17 @@ sub read { $info{partitionEntrySize} == psizeof($partitionEntry_format) or die "bad partitionEntrySize"; $info{revision} <= $current_revision or log::l("oops, this is a new GPT revision ($info{revision} > $current_revision)"); - my $chksum = compute_crc(\%info); - $chksum == $info{headerCRC32} or die "bad checksum"; + $info{headerCRC32} == compute_headerCRC32(\%info) or die "bad partition table checksum"; + + c::lseek_sector(fileno(F), $info{partitionEntriesLBA}, 0) or die "can't seek to sector partitionEntriesLBA"; + sysread F, $tmp, psizeof($partitionEntry_format) * $info{nbPartitions} or die "error while reading partition table in sector $sector"; + $info{partitionEntriesCRC32} == crc32($tmp) or die "bad partition entries checksum"; c::lseek_sector(fileno(F), $info{partitionEntriesLBA}, 0) or die "can't seek to sector partitionEntriesLBA"; my %gpt_types_rev = reverse %gpt_types; - my @pt = map { + my @pt = + grep { $_->{size} && $_->{type} } #- compress empty partitions as kernel skip them + map { sysread F, $tmp, psizeof($partitionEntry_format) or die "error while reading partition table in sector $sector"; my %h; @h{@$partitionEntry_fields} = unpack $partitionEntry_format, $tmp; $h{size} = $h{ending} - $h{start}; @@ -127,7 +131,7 @@ sub write { foreach (@$pt) { $_->{ending} = $_->{start} + $_->{size}; - $_->{gpt_type} = $gpt_types{$_->{type}} || $gpt_types{0x83}; + $_->{gpt_type} = $gpt_types{$_->{type}} || $_->{gpt_type} || $gpt_types{0x83}; } $info->{csum} = compute_crc($info); |