diff options
author | Pascal Rigaux <pixel@mandriva.com> | 1999-10-08 11:42:45 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 1999-10-08 11:42:45 +0000 |
commit | 0f48e147d39575f98db29f7e21d5347e6e309d04 (patch) | |
tree | fba03e3d6c57d3b202f973fc11907372dd26f64e /perl-install/fsedit.pm | |
parent | c5a4cbe6c55d38bcc411bd94f088f36b85681899 (diff) | |
download | drakx-backup-do-not-use-0f48e147d39575f98db29f7e21d5347e6e309d04.tar drakx-backup-do-not-use-0f48e147d39575f98db29f7e21d5347e6e309d04.tar.gz drakx-backup-do-not-use-0f48e147d39575f98db29f7e21d5347e6e309d04.tar.bz2 drakx-backup-do-not-use-0f48e147d39575f98db29f7e21d5347e6e309d04.tar.xz drakx-backup-do-not-use-0f48e147d39575f98db29f7e21d5347e6e309d04.zip |
no_comment
Diffstat (limited to 'perl-install/fsedit.pm')
-rw-r--r-- | perl-install/fsedit.pm | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/perl-install/fsedit.pm b/perl-install/fsedit.pm index c4e43e148..cdebe6608 100644 --- a/perl-install/fsedit.pm +++ b/perl-install/fsedit.pm @@ -6,11 +6,14 @@ use strict; #-###################################################################################### #- misc imports #-###################################################################################### -use common qw(:common :constant :functional); +use common qw(:common :constant :functional :file); use partition_table qw(:types); use partition_table_raw; +use detect_devices; use Data::Dumper; +use fsedit; use devices; +use fs; use log; #-##################################################################################### @@ -29,6 +32,13 @@ my @suggestions = ( my @suggestions_mntpoints = qw(/mnt/dos); +my @partitions_signatures = ( + [ 0x83, 0x438, "\xEF\x53" ], + [ 0x82, 4086, "SWAP-SPACE" ], +); + +sub typeOfPart($) { typeFromMagic(devices::make($_[0]), @partitions_signatures) } + #-###################################################################################### #- Functions #-###################################################################################### @@ -63,6 +73,21 @@ sub hds($$) { [ @hds ]; } +sub readProcPartitions { + my ($hds) = @_; + my @parts; + foreach (cat_("/proc/partitions")) { + my (undef, undef, $size, $device) = split; + next if $size eq "1"; #- extended partitions + foreach (@$hds) { + push @parts, { start => 0, size => $size * 2, device => $device, + type => typeOfPart($device), rootDevice => $_->{device} + } if $device =~ /^$_->{device}./; + } + } + @parts; +} + sub get_fstab(@) { map { partition_table::get_normal_parts($_) } @_; } @@ -329,6 +354,30 @@ sub rescuept($) { } } +sub verifyHds { + my ($hds, $readonly, $ok) = @_; + + if (is_empty_array_ref($hds)) { #- no way + die _("An error has occurred - no valid devices were found on which to create new filesystems. Please check your hardware for the cause of this problem"); + } + + my @parts = readProcPartitions($hds); + $ok &&= @parts == listlength(get_fstab(@$hds)); + + if ($readonly && !$ok) { + log::l("using /proc/partitions as diskdrake failed :("); + foreach my $hd (@$hds) { + $hd->{primary} = [ grep { $hd->{device} eq $_->{rootDevice} } @parts ]; + delete $hd->{extended}; + } + } + my $fstab = [ get_fstab(@$hds) ]; + if (is_empty_array_ref($fstab) && $readonly) { + die _("You don't have any partitions!"); + } + ($hds, $fstab, $ok); +} + #-###################################################################################### #- Wonderful perl :( #-###################################################################################### |