summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorGwenolé Beauchesne <gbeauchesne@mandriva.org>2001-10-19 17:21:19 +0000
committerGwenolé Beauchesne <gbeauchesne@mandriva.org>2001-10-19 17:21:19 +0000
commit0e215bd9359b82933600adb884b5a71a993a5521 (patch)
treee449fcaa22a56511c0b56ca39d20385ec8103449 /perl-install
parent3efb824ba70e138a2063fe2a2609f4456fc7de0e (diff)
downloaddrakx-backup-do-not-use-0e215bd9359b82933600adb884b5a71a993a5521.tar
drakx-backup-do-not-use-0e215bd9359b82933600adb884b5a71a993a5521.tar.gz
drakx-backup-do-not-use-0e215bd9359b82933600adb884b5a71a993a5521.tar.bz2
drakx-backup-do-not-use-0e215bd9359b82933600adb884b5a71a993a5521.tar.xz
drakx-backup-do-not-use-0e215bd9359b82933600adb884b5a71a993a5521.zip
- Use /dev/random through devices::make() instead of /dev/urandom
- Localize file descriptor - Capitalize error message if no /dev/random found
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/partition_table_gpt.pm28
1 files changed, 24 insertions, 4 deletions
diff --git a/perl-install/partition_table_gpt.pm b/perl-install/partition_table_gpt.pm
index 3f30da4b9..7512bb0c2 100644
--- a/perl-install/partition_table_gpt.pm
+++ b/perl-install/partition_table_gpt.pm
@@ -51,10 +51,30 @@ my ($partitionEntry_format, $partitionEntry_fields) = list2kv(
a72 => 'name',
);
-$_ = join('', @$_) foreach $main_format, $partitionEntry_format;
+my ($guid_format, $guid_fields) = list2kv(
+ N => 'time_low',
+ n => 'time_mid',
+ n => 'time_hi_and_version',
+ n => 'clock_seq',
+ a6 => 'node',
+);
+
+$_ = join('', @$_) foreach $main_format, $partitionEntry_format, $guid_format;
my $magic = "EFI PART";
+sub generate_guid {
+ local *F;
+ open F, devices::make("random") or die "Could not open /dev/random for GUID generation";
+ read F, $tmp, psizeof($guid_format);
+ close F;
+
+ my %guid; @guid{@$guid_fields} = unpack $guid_format, $tmp;
+ $guid{clock_seq} = ($guid{clock_seq} & 0x3fff) | 0x8000;
+ $guid{time_hi_and_version} = ($guid{time_hi_and_version} & 0x0fff) | 0x4000;
+ pack($guid_format, @guid{@$guid_fields});
+}
+
sub crc32 {
my ($buffer) = @_;
@@ -147,7 +167,7 @@ sub write {
foreach (@$pt) {
$_->{ending} = $_->{start} + $_->{size} - 1;
- $_->{guid} ||= 'TODO';
+ $_->{guid} ||= generate_guid;
$_->{gpt_type} = $gpt_types{$_->{type}} || $_->{gpt_type} || $gpt_types{0x83};
}
my $partitionEntries = join('', map {
@@ -219,8 +239,8 @@ sub info {
alternateLBA => $hd->{totalsectors} - 1,
firstUsableLBA => $nb_sect + 2,
lastUsableLBA => $hd->{totalsectors} - $nb_sect - 2,
- guid => 'TODO',
- partitionEntriesLBA => 2,
+ guid => generate_guid,
+ partitionEntriesLBA => 2,
nbPartitions => $nb_sect * 512 / psizeof($partitionEntry_format),
partitionEntrySize => psizeof($partitionEntry_format),
};