summaryrefslogtreecommitdiffstats
path: root/perl-install/fsedit.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/fsedit.pm')
-rw-r--r--perl-install/fsedit.pm51
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 :(
#-######################################################################################