diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2000-01-16 13:08:32 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2000-01-16 13:08:32 +0000 |
commit | cc29fc49a0427da3225c4d77f95827bed24073f7 (patch) | |
tree | fd86687bc4af7767098267052df70f9bff24d63b | |
parent | 30c83c5730279a3f2279b515c416a283e0c50d82 (diff) | |
download | drakx-backup-do-not-use-cc29fc49a0427da3225c4d77f95827bed24073f7.tar drakx-backup-do-not-use-cc29fc49a0427da3225c4d77f95827bed24073f7.tar.gz drakx-backup-do-not-use-cc29fc49a0427da3225c4d77f95827bed24073f7.tar.bz2 drakx-backup-do-not-use-cc29fc49a0427da3225c4d77f95827bed24073f7.tar.xz drakx-backup-do-not-use-cc29fc49a0427da3225c4d77f95827bed24073f7.zip |
no_comment
-rw-r--r-- | perl-install/Xconfigurator.pm | 2 | ||||
-rw-r--r-- | perl-install/common.pm | 3 | ||||
-rw-r--r-- | perl-install/fsedit.pm | 4 | ||||
-rw-r--r-- | perl-install/interactive.pm | 5 | ||||
-rw-r--r-- | perl-install/my_gtk.pm | 5 | ||||
-rw-r--r-- | perl-install/partition_table.pm | 27 | ||||
-rw-r--r-- | perl-install/partition_table_bsd.pm | 133 | ||||
-rw-r--r-- | perl-install/partition_table_dos.pm | 86 | ||||
-rw-r--r-- | perl-install/partition_table_raw.pm | 73 |
9 files changed, 248 insertions, 90 deletions
diff --git a/perl-install/Xconfigurator.pm b/perl-install/Xconfigurator.pm index 9db1dcdd5..14f0c8c68 100644 --- a/perl-install/Xconfigurator.pm +++ b/perl-install/Xconfigurator.pm @@ -82,6 +82,7 @@ sub readCardsDB { #- this entry is broken in X11R6 cards db $cards{I128}{flags}{noclockprobe} = 1; + \%cards; } sub readMonitorsDB { @@ -174,6 +175,7 @@ sub cardConfiguration(;$$$) { unless ($card->{type}) { $card->{flags}{noclockprobe} = member($card->{server}, qw(I128 S3 S3V Mach64)); } + $card->{options}{power_saver} = 1; $card->{flags}{needVideoRam} and $card->{memory} ||= diff --git a/perl-install/common.pm b/perl-install/common.pm index 9f7117254..441440033 100644 --- a/perl-install/common.pm +++ b/perl-install/common.pm @@ -7,7 +7,7 @@ use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK $printable_chars $sizeof_int $bitof_int @ISA = qw(Exporter); %EXPORT_TAGS = ( common => [ qw(__ even odd min max sqr sum and_ or_ sign product bool invbool listlength bool2text text2bool to_int to_float ikeys member divide is_empty_array_ref is_empty_hash_ref add2hash add2hash_ set_new set_add round round_up round_down first second top uniq translate untranslate warp_text formatAlaTeX formatLines deref) ], - functional => [ qw(fold_left compose map_index grep_index map_each grep_each map_tab_hash mapn mapn_ difference2 before_leaving catch_cdie cdie) ], + functional => [ qw(fold_left compose map_index grep_index map_each grep_each list2kv map_tab_hash mapn mapn_ difference2 before_leaving catch_cdie cdie) ], file => [ qw(dirname basename touch all glob_ cat_ output symlinkf chop_ mode typeFromMagic) ], system => [ qw(sync makedev unmakedev psizeof strcpy gettimeofday syscall_ salt getVarsFromSh setVarsInSh setVarsInCsh substInFile availableRam availableMemory removeXiBSuffix template2file formatTime) ], constant => [ qw($printable_chars $sizeof_int $bitof_int $SECTORSIZE) ], @@ -129,6 +129,7 @@ sub grep_each(&%) { while (($::a, $::b) = each %h) { $l{$::a} = $::b if &$f($::a, $::b) } %l; } +sub list2kv { [ grep_index { even($::i) } @_ ], [ grep_index { odd($::i) } @_ ] } #- pseudo-array-hash :) sub map_tab_hash(&$@) { diff --git a/perl-install/fsedit.pm b/perl-install/fsedit.pm index 6060a1cc7..5bcabddeb 100644 --- a/perl-install/fsedit.pm +++ b/perl-install/fsedit.pm @@ -110,8 +110,8 @@ sub is_one_big_fat { my ($hds) = @_; @$hds == 1 or return; - my @l = fsedit::get_fstab(@$hds); - @l == 1 && isFat($l[0]) && fsedit::free_space(@$hds) < 10 << 11; + my @l = get_fstab(@$hds); + @l == 1 && isFat($l[0]) && free_space(@$hds) < 10 << 11; } diff --git a/perl-install/interactive.pm b/perl-install/interactive.pm index 4e1f9662b..79df5be2c 100644 --- a/perl-install/interactive.pm +++ b/perl-install/interactive.pm @@ -145,9 +145,8 @@ sub ask_from_entries($$$$;$%) { sub ask_from_entries_refH($$$;$%) { my ($o, $title, $message, $h, %callback) = @_; - ask_from_entries_ref($o, $title, $message, - [ grep_index { even($::i) } @$h ], - [ grep_index { odd($::i) } @$h ], + ask_from_entries_ref($o, $title, $message, + list2kv(@$h), %callback); } diff --git a/perl-install/my_gtk.pm b/perl-install/my_gtk.pm index 84f285ba0..988045458 100644 --- a/perl-install/my_gtk.pm +++ b/perl-install/my_gtk.pm @@ -143,10 +143,7 @@ sub gtkroot { sub gtkcolor($$$) { my ($r, $g, $b) = @_; - my $color = bless {}, 'Gtk::Gdk::Color'; - $color->red ($r); - $color->green($g); - $color->blue ($b); + my $color = bless { red => $r, green => $g, blue => $b }, 'Gtk::Gdk::Color'; gtkroot()->get_colormap->color_alloc($color); } diff --git a/perl-install/partition_table.pm b/perl-install/partition_table.pm index 18c9c9a14..3bf6506bc 100644 --- a/perl-install/partition_table.pm +++ b/perl-install/partition_table.pm @@ -12,7 +12,8 @@ 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 Data::Dumper; @@ -326,7 +327,15 @@ sub get_holes($) { sub read_one($$) { my ($hd, $sector) = @_; - my $pt = partition_table_raw::read($hd, $sector) or return; + my ($pt, $info); + foreach ('dos', 'bsd') { + eval { + bless $hd, "partition_table_$_"; + ($pt, $info) = $hd->read($sector); + }; + print ">>> $@\n"; + $@ or last; + } my @extended = grep { isExtended($_) } @$pt; my @normal = grep { $_->{size} && $_->{type} && !isExtended($_) } @$pt; @@ -334,13 +343,13 @@ sub read_one($$) { @extended > 1 and die "more than one extended partition"; $_->{rootDevice} = $hd->{device} foreach @normal, @extended; - { raw => $pt, extended => $extended[0], normal => \@normal }; + { raw => $pt, extended => $extended[0], normal => \@normal, info => $info }; } sub read($;$) { my ($hd, $clearall) = @_; my $pt = $clearall ? - partition_table_raw::clear_raw() : + $hd->clear_raw : read_one($hd, 0) || return 0; $hd->{primary} = $pt; @@ -394,21 +403,21 @@ sub write($) { for ($hd->{primary}{raw}) { (grep { $_->{local_start} = $_->{start}; $_->{active} ||= 0 } @$_) or $_->[0]{active} = 0x80; } - partition_table_raw::write($hd, 0, $hd->{primary}{raw}) or die "writing of partition table failed"; + $hd->write(0, $hd->{primary}{raw}, $hd->{primary}{info}) or die "writing of partition table failed"; foreach (@{$hd->{extended}}) { # in case of extended partitions, the start sector must be local to the partition $_->{normal}{local_start} = $_->{normal}{start} - $_->{start}; $_->{extended} and $_->{extended}{local_start} = $_->{extended}{start} - $hd->{primary}{extended}{start}; - partition_table_raw::write($hd, $_->{start}, $_->{raw}) or die "writing of partition table failed"; + $hd->write($_->{start}, $_->{raw}) or die "writing of partition table failed"; } $hd->{isDirty} = 0; #- now sync disk and re-read the partition table if ($hd->{needKernelReread}) { sync(); - partition_table_raw::kernel_read($hd); + $hd->kernel_read; $hd->{needKernelReread} = 0; } } @@ -530,8 +539,8 @@ sub add($$;$$) { eval { add_primary($hd, $part) }; return unless $@; } - eval { add_extended($hd, $part) }; #- try adding extended - if (my $err = $@) { + eval { add_extended($hd, $part) } if $hd->hasExtended; #- try adding extended + if ($@ || !$hd->hasExtended) { eval { add_primary($hd, $part) }; die $@ if $@; #- send the add extended error which should be better } diff --git a/perl-install/partition_table_bsd.pm b/perl-install/partition_table_bsd.pm new file mode 100644 index 000000000..0b03249c1 --- /dev/null +++ b/perl-install/partition_table_bsd.pm @@ -0,0 +1,133 @@ +package partition_table_bsd; + +use diagnostics; +use strict; +use vars qw(@ISA); + +@ISA = qw(partition_table_raw); + +use common qw(:common :system :file :functional); +use partition_table_raw; +use partition_table; +use c; + +#- very bad and rough handling :( +my %typeToDos = ( + 8 => 0x83, + 1 => 0x82, +); +my %typeFromDos = reverse %typeToDos; + +my ($main_format, $main_fields) = list2kv( + I => 'magic', + S => 'type', + S => 'subtype', + a16 => 'typename', + a16 => 'packname', + I => 'secsize', + I => 'nsectors', + I => 'ntracks', + I => 'ncylinders', + I => 'secpercyl', + I => 'secprtunit', + S => 'sparespertrack', + S => 'sparespercyl', + I => 'acylinders', + S => 'rpm', + S => 'interleave', + S => 'trackskew', + S => 'cylskew', + I => 'headswitch', + I => 'trkseek', + I => 'flags', + a20 => 'drivedata', + a20 => 'spare', + I => 'magic2', + S => 'checksum', + S => 'npartitions', + I => 'bbsize', + I => 'sbsize', +); +$main_format = join '', @$main_format; + +my @fields = qw(size start fsize type frag cpg); +my $format = "I I I C C S"; +my $magic = 0x82564557; +my $nb_primary = 8; +my $offset = 0x40; + +sub read($$) { + my ($hd, $sector) = @_; + my $tmp; + + local *F; partition_table_raw::openit($hd, *F) or die "failed to open device"; + c::lseek_sector(fileno(F), $sector, $offset) or die "reading of partition in sector $sector failed"; + + sysread F, $tmp, psizeof($main_format) or die "error while reading partition table in sector $sector"; + my %info; @info{@$main_fields} = unpack $main_format, $tmp; + + my @pt = map { + sysread F, $tmp, psizeof($format) or die "error while reading partition table in sector $sector"; + my %h; @h{@fields} = unpack $format, $tmp; + $h{type} = $typeToDos{$h{type}} || $h{type}; + \%h; + } (1..$nb_primary); + + #- check magic number + $info{magic} == $magic or die "bad magic number"; + $info{magic2} == $magic or die "bad magic number"; + + [ @pt ], \%info; +} + +# write the partition table (and extended ones) +# for each entry, it uses fields: start, size, type, active +sub write($$$;$) { + my ($hd, $sector, $pt, $info) = @_; + + print "Her\n"; + local *F; partition_table_raw::openit($hd, *F, 2) or die "error opening device $hd->{device} for writing"; + c::lseek_sector(fileno(F), $sector, $offset) or return 0; + + $info->{npartitions} = $nb_primary; #- is it ok? + + syswrite F, pack($main_format, @$info{@$main_fields}), psizeof($main_format) or return 0; + + @$pt == $nb_primary or die "partition table does not have $nb_primary entries"; + foreach (@$pt) { + local $_->{type} = $typeFromDos{$_->{type}} || $_->{type}; + syswrite F, pack($format, @$_{@fields}), psizeof($format) or return 0; + } + 1; +} + +sub info { + my ($hd) = @_; + 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 { + my ($hd) = @_; + { raw => [ ({}) x $nb_primary ], info => info($hd) }; +} + +1; diff --git a/perl-install/partition_table_dos.pm b/perl-install/partition_table_dos.pm new file mode 100644 index 000000000..1b25a8f0b --- /dev/null +++ b/perl-install/partition_table_dos.pm @@ -0,0 +1,86 @@ +package partition_table_dos; + +use diagnostics; +use strict; +use vars qw(@ISA); + +@ISA = qw(partition_table_raw); + +use common qw(:common :system :file); +use partition_table_raw; +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); + +sub hasExtended { 1 } + +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 read($$) { + my ($hd, $sector) = @_; + my $tmp; + + local *F; partition_table_raw::openit($hd, *F) or die "failed to open device"; + 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 die "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; partition_table_raw::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 ] } } + +1; 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}; } |