diff options
author | Francois Pons <fpons@mandriva.com> | 2000-01-24 15:12:16 +0000 |
---|---|---|
committer | Francois Pons <fpons@mandriva.com> | 2000-01-24 15:12:16 +0000 |
commit | a31aa764b35315eda2caf3bd269db45fc56a9d66 (patch) | |
tree | df5c8c426e21dddb236a4e600ab7162c1806c758 /perl-install | |
parent | 7fa1fd93ecd790ae288102dcb4ec4cf3ca3bc760 (diff) | |
download | drakx-a31aa764b35315eda2caf3bd269db45fc56a9d66.tar drakx-a31aa764b35315eda2caf3bd269db45fc56a9d66.tar.gz drakx-a31aa764b35315eda2caf3bd269db45fc56a9d66.tar.bz2 drakx-a31aa764b35315eda2caf3bd269db45fc56a9d66.tar.xz drakx-a31aa764b35315eda2caf3bd269db45fc56a9d66.zip |
*** empty log message ***
Diffstat (limited to 'perl-install')
-rw-r--r-- | perl-install/Makefile | 2 | ||||
-rw-r--r-- | perl-install/fsedit.pm | 6 | ||||
-rw-r--r-- | perl-install/partition_table.pm | 26 | ||||
-rw-r--r-- | perl-install/partition_table_bsd.pm | 10 | ||||
-rw-r--r-- | perl-install/partition_table_dos.pm | 8 | ||||
-rw-r--r-- | perl-install/partition_table_raw.pm | 27 | ||||
-rw-r--r-- | perl-install/partition_table_sun.pm | 41 |
7 files changed, 45 insertions, 75 deletions
diff --git a/perl-install/Makefile b/perl-install/Makefile index ebad67be4..ddc412be3 100644 --- a/perl-install/Makefile +++ b/perl-install/Makefile @@ -136,7 +136,7 @@ endif tar xyC $(DEST) -f ../install/install1_pcmcia.tar.bz2 ./etc/pcmcia full_stage2: - $(SUDO) rm -rf $(DEST) + if [ `id -u` = 0 ]; then rm -rf $(DEST); else $(SUDO) rm -rf $(DEST); fi mkdir -p $(DEST) $(MAKE) get_needed_files $(MAKE) stage2 diff --git a/perl-install/fsedit.pm b/perl-install/fsedit.pm index 57f29e8cc..95b5006df 100644 --- a/perl-install/fsedit.pm +++ b/perl-install/fsedit.pm @@ -173,7 +173,7 @@ sub suggest_part($$$;$) { $best = $second if $best->{mntpoint} eq '/boot' && - $part->{start} + $best->{size} > 1024 * partition_table::cylinder_size($hd); #- if the empty slot is beyond the 1024th cylinder, no use having /boot + $part->{start} + $best->{size} > 1024 * $hd->cylinder_size(); #- if the empty slot is beyond the 1024th cylinder, no use having /boot defined $best or return; #- sorry no suggestion :( @@ -227,7 +227,7 @@ sub check_mntpoint { has_mntpoint($mntpoint, $hds) and die _("There is already a partition with mount point %s", $mntpoint); - if ($part->{start} + $part->{size} > 1024 * partition_table::cylinder_size($hd)) { + if ($part->{start} + $part->{size} > 1024 * $hd->cylinder_size()) { die "/boot ending on cylinder > 1024" if $mntpoint eq "/boot"; die "/ ending on cylinder > 1024" if $mntpoint eq "/" && !has_mntpoint("/boot", $hds); } @@ -298,7 +298,7 @@ sub move { my $part1 = { %$part }; my $part2 = { %$part }; $part2->{start} = $sector2; - $part2->{size} += partition_table::cylinder_size($hd2) - 1; + $part2->{size} += $hd2->cylinder_size() - 1; partition_table::remove($hd, $part); { local ($part2->{notFormatted}, $part2->{isFormatted}); #- do not allow partition::add to change this diff --git a/perl-install/partition_table.pm b/perl-install/partition_table.pm index 19e425872..82c950349 100644 --- a/perl-install/partition_table.pm +++ b/perl-install/partition_table.pm @@ -12,6 +12,7 @@ use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK @important_types @fields2save); use common qw(:common :system :functional); +use partition_table_raw; use partition_table_dos; use partition_table_bsd; use partition_table_sun; @@ -201,29 +202,6 @@ sub isPrimary($$) { 0; } -sub cylinder_size($) { - my ($hd) = @_; - $hd->{geom}{sectors} * $hd->{geom}{heads}; -} - -sub adjustStart($$) { - my ($hd, $part) = @_; - my $end = $part->{start} + $part->{size}; - - $part->{start} = round_up($part->{start}, - $part->{start} % cylinder_size($hd) < 2 * $hd->{geom}{sectors} ? - $hd->{geom}{sectors} : cylinder_size($hd)); - $part->{size} = $end - $part->{start}; -} -sub adjustEnd($$) { - my ($hd, $part) = @_; - my $end = $part->{start} + $part->{size}; - my $end2 = round_down($end, cylinder_size($hd)); - unless ($part->{start} < $end2) { - $end2 = round_up($end, cylinder_size($hd)); - } - $part->{size} = $end2 - $part->{start}; -} sub adjustStartAndEnd($$) { my ($hd, $part) = @_; @@ -527,7 +505,7 @@ The only solution is to move your primary partitions to have the hole next to th my $l = first (@{$hd->{extended}}); #- the first is a special case, must recompute its real size - $l->{start} = round_down($l->{normal}{start} - 1, cylinder_size($hd)); + $l->{start} = round_down($l->{normal}{start} - 1, $hd->cylinder_size()); $l->{size} = $l->{normal}{start} + $l->{normal}{size} - $l->{start}; my $ext = { %$l }; unshift @{$hd->{extended}}, { type => 5, raw => [ $part, $ext, {}, {} ], normal => $part, extended => $ext }; diff --git a/perl-install/partition_table_bsd.pm b/perl-install/partition_table_bsd.pm index c0af9cf48..13398e007 100644 --- a/perl-install/partition_table_bsd.pm +++ b/perl-install/partition_table_bsd.pm @@ -56,14 +56,6 @@ my $magic = 0x82564557; my $nb_primary = 8; my $offset = 0x40; -#- use default partition table adust functions. -sub adjustStart($$) { - &partition_table::adjustStart; -} -sub adjustEnd($$) { - &partition_table::adjustEnd; -} - sub read($$) { my ($hd, $sector) = @_; my $tmp; @@ -132,7 +124,7 @@ sub info { dtype => $hd->{device} =~ /^sd/ ? $dtype_scsi : $dtype_ST506, secsize => $common::SECTORSIZE, ncylinders => $hd->{geom}{cylinders}, - secpercyl => partition_table::cylinder_size($hd), + secpercyl => $hd->cylinder_size(), secprtunit => $hd->{geom}{totalsectors}, rpm => 3600, interleave => 1, diff --git a/perl-install/partition_table_dos.pm b/perl-install/partition_table_dos.pm index 624f13ecf..305aa862b 100644 --- a/perl-install/partition_table_dos.pm +++ b/perl-install/partition_table_dos.pm @@ -43,14 +43,6 @@ sub sector2CHS($$) { ($start, $h, $s + 1); } -#- use default partition table adust functions. -sub adjustStart($$) { - &partition_table::adjustStart; -} -sub adjustEnd($$) { - &partition_table::adjustEnd; -} - sub read($$) { my ($hd, $sector) = @_; my $tmp; diff --git a/perl-install/partition_table_raw.pm b/perl-install/partition_table_raw.pm index cafb439f9..668913d9c 100644 --- a/perl-install/partition_table_raw.pm +++ b/perl-install/partition_table_raw.pm @@ -31,6 +31,30 @@ sub typeOfMBR_($) { typeFromMagic($_[0], @MBR_signatures) } sub hasExtended { 0 } +sub cylinder_size($) { + my ($hd) = @_; + $hd->{geom}{sectors} * $hd->{geom}{heads}; +} + +sub adjustStart($$) { + my ($hd, $part) = @_; + my $end = $part->{start} + $part->{size}; + + $part->{start} = round_up($part->{start}, + $part->{start} % cylinder_size($hd) < 2 * $hd->{geom}{sectors} ? + $hd->{geom}{sectors} : cylinder_size($hd)); + $part->{size} = $end - $part->{start}; +} +sub adjustEnd($$) { + my ($hd, $part) = @_; + my $end = $part->{start} + $part->{size}; + my $end2 = round_down($end, cylinder_size($hd)); + unless ($part->{start} < $end2) { + $end2 = round_up($end, cylinder_size($hd)); + } + $part->{size} = $end2 - $part->{start}; +} + sub get_geometry($) { my ($dev) = @_; my $g = ""; @@ -40,9 +64,6 @@ sub get_geometry($) { my %geom; @geom{qw(heads sectors cylinders start)} = unpack "CCSL", $g; - #- handle this strange but necessary reduction of visible cylinders on sparc, assume 2 for instance. - $geom{total_cylinders} = $geom{cylinders}; $geom{cylinders} -= 2 if arch() =~ /^sparc/; - { geom => \%geom, totalsectors => $geom{heads} * $geom{sectors} * $geom{cylinders} }; } diff --git a/perl-install/partition_table_sun.pm b/perl-install/partition_table_sun.pm index 808944b8c..9ffa008a8 100644 --- a/perl-install/partition_table_sun.pm +++ b/perl-install/partition_table_sun.pm @@ -52,12 +52,9 @@ sub adjustStart($$) { #- since partition must always start on cylinders boundaries on sparc, #- note that if start sector is on the first cylinder, it is adjusted #- to 0 and it is valid. - $part->{start} = $part->{start} >= partition_table::cylinder_size() ? round_up($part->{start}, partition_table::cylinder_size($hd)) : 0; + $part->{start} = $part->{start} >= $hd->cylinder_size() ? round_up($part->{start}, $hd->cylinder_size()) : 0; $part->{size} = $end - $part->{start}; } -sub adjustEnd($$) { - &partition_table::adjustEnd; -} #- compute crc checksum used for Sun Label partition, expect #- $tmp to be the 512 bytes buffer to be read/written to MBR. @@ -93,7 +90,7 @@ sub read($$) { my %h; @h{@$fields1} = unpack $format1, $_[0]; @h{@$fields2} = unpack $format2, $_[1]; - $h{start} = $sector + $h{start_cylinder} * partition_table::cylinder_size($hd); + $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; @@ -118,9 +115,9 @@ sub write($$$;$) { } ($info->{infos}, $info->{partitions}) = map { join '', @$_ } list2kv map { - $_->{start} % partition_table::cylinder_size($hd) == 0 or die "partition not at beginning of cylinder"; + $_->{start} % $hd->cylinder_size() == 0 or die "partition not at beginning of cylinder"; # local $_->{type} = $typeFromDos{$_->{type}} || $_->{type}; - local $_->{start_cylinder} = $_->{start} / partition_table::cylinder_size($hd) - $sector; + local $_->{start_cylinder} = $_->{start} / $hd->cylinder_size() - $sector; pack($format1, @$_{@$fields1}), pack($format2, @$_{@$fields2}); } @$pt; @@ -137,6 +134,15 @@ sub write($$$;$) { sub info { my ($hd) = @_; + #- take care of reduction of the number of cylinders, avoid loop of reduction! + unless ($hd->{geom}{total_cylinders} > $hd->{geom}{cylinders}) { + $hd->{geom}{total_cylinders} = $hd->{geom}{cylinders}; + $hd->{geom}{cylinders} -= 2; + + #- rebuild some constants according to number of cylinders. + $hd->{totalsectors} = $hd->{geom}{heads} * $hd->{geom}{sectors} * $hd->{geom}{cylinders}; + } + #- build a default suitable partition table, #- checksum will be built when writing on disk. #- note third partition is ALWAYS of type Whole disk. @@ -154,25 +160,6 @@ sub info { }; $info; -# my $dtype_scsi = 4; #- taken from fdisk, removed unused one, -# my $dtype_ST506 = 6; #- see fdisk for more -# { -# magic => $magic, -# magic2 => $magic, -# dtype => $hd->{device} =~ /^sd/ ? $dtype_scsi : $dtype_ST506, -# secsize => $common::SECTORSIZE, -# ncylinders => $hd->{geom}{cylinders}, -# secpercyl => partition_table::cylinder_size($hd), -# secprtunit => $hd->{geom}{totalsectors}, -# rpm => 3600, -# interleave => 1, -# trackskew => 0, -# cylskew => 0, -# headswitch => 0, -# trkseek => 0, -# bbsize => 8192, #- size of boot area, with label -# sbsize => 8192, #- max size of fs superblock -# }; } sub clear_raw { @@ -184,7 +171,7 @@ sub clear_raw { type => 5, #- the whole disk type. flags => 0, start_cylinder => 0, - size => $hd->{geom}{cylinders} * partition_table::cylinder_size($hd), + size => $hd->{geom}{cylinders} * $hd->cylinder_size(), }; $pt; |