summaryrefslogtreecommitdiffstats
path: root/perl-install/partition_table_raw.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2000-01-16 13:08:32 +0000
committerPascal Rigaux <pixel@mandriva.com>2000-01-16 13:08:32 +0000
commitcc29fc49a0427da3225c4d77f95827bed24073f7 (patch)
treefd86687bc4af7767098267052df70f9bff24d63b /perl-install/partition_table_raw.pm
parent30c83c5730279a3f2279b515c416a283e0c50d82 (diff)
downloaddrakx-cc29fc49a0427da3225c4d77f95827bed24073f7.tar
drakx-cc29fc49a0427da3225c4d77f95827bed24073f7.tar.gz
drakx-cc29fc49a0427da3225c4d77f95827bed24073f7.tar.bz2
drakx-cc29fc49a0427da3225c4d77f95827bed24073f7.tar.xz
drakx-cc29fc49a0427da3225c4d77f95827bed24073f7.zip
no_comment
Diffstat (limited to 'perl-install/partition_table_raw.pm')
-rw-r--r--perl-install/partition_table_raw.pm73
1 files changed, 2 insertions, 71 deletions
diff --git a/perl-install/partition_table_raw.pm b/perl-install/partition_table_raw.pm
index 50d6a0b3e..9aa790aee 100644
--- a/perl-install/partition_table_raw.pm
+++ b/perl-install/partition_table_raw.pm
@@ -7,13 +7,6 @@ use common qw(:common :system :file);
use devices;
use c;
-my @fields = qw(active start_head start_sec start_cyl type end_head end_sec end_cyl start size);
-my $format = "C8 I2";
-my $magic = "\x55\xAA";
-my $nb_primary = 4;
-
-my $offset = $common::SECTORSIZE - length($magic) - $nb_primary * common::psizeof($format);
-
my @MBR_signatures = (
[ 'empty', 0, "\0\0\0\0" ],
[ 'lilo', 0x2, "LILO" ],
@@ -36,28 +29,7 @@ my @MBR_signatures = (
sub typeOfMBR($) { typeFromMagic(devices::make($_[0]), @MBR_signatures) }
sub typeOfMBR_($) { typeFromMagic($_[0], @MBR_signatures) }
-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);
- 1;
-}
-
-sub CHS2rawCHS($$$) {
- my ($c, $h, $s) = @_;
- $c = min($c, 1023); #- no way to have a #cylinder >= 1024
- ($c & 0xff, $h, $s | ($c >> 2 & 0xc0));
-}
-
-# returns (cylinder, head, sector)
-sub sector2CHS($$) {
- my ($hd, $start) = @_;
- my ($s, $h);
- ($start, $s) = divide($start, $hd->{geom}{sectors});
- ($start, $h) = divide($start, $hd->{geom}{heads});
- ($start, $h, $s + 1);
-}
+sub hasExtended { 0 }
sub get_geometry($) {
my ($dev) = @_;
@@ -80,51 +52,10 @@ sub kernel_read($) {
$hd->{rebootNeeded} = !ioctl(F, c::BLKRRPART(), 0);
}
-sub read($$) {
- my ($hd, $sector) = @_;
- my $tmp;
-
- local *F; openit($hd, *F) or return;
- c::lseek_sector(fileno(F), $sector, $offset) or die "reading of partition in sector $sector failed";
-
- my @pt = map {
- sysread F, $tmp, psizeof($format) or return "error while reading partition table in sector $sector";
- my %h; @h{@fields} = unpack $format, $tmp;
- \%h;
- } (1..$nb_primary);
-
- #- check magic number
- sysread F, $tmp, length $magic or die "error reading magic number";
- $tmp eq $magic or die "bad magic number";
-
- [ @pt ];
-}
-
-# write the partition table (and extended ones)
-# for each entry, it uses fields: start, size, type, active
-sub write($$$) {
- my ($hd, $sector, $pt) = @_;
-
- local *F; openit($hd, *F, 2) or die "error opening device $hd->{device} for writing";
- c::lseek_sector(fileno(F), $sector, $offset) or return 0;
-
- @$pt == $nb_primary or die "partition table does not have $nb_primary entries";
- foreach (@$pt) {
- compute_CHS($hd, $_);
- local $_->{start} = $_->{local_start} || 0;
- $_->{active} ||= 0; $_->{type} ||= 0; $_->{size} ||= 0; #- for no warning
- syswrite F, pack($format, @$_{@fields}), psizeof($format) or return 0;
- }
- syswrite F, $magic, length $magic or return 0;
- 1;
-}
-
-sub clear_raw { { raw => [ ({}) x $nb_primary ] } }
-
sub zero_MBR($) {
my ($hd) = @_;
$hd->{isDirty} = $hd->{needKernelReread} = 1;
- $hd->{primary} = clear_raw();
+ $hd->{primary} = $hd->clear_raw();
delete $hd->{extended};
}