summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perl-install/partition_table.pm7
-rw-r--r--perl-install/partition_table/bsd.pm2
-rw-r--r--perl-install/partition_table/dos.pm22
-rw-r--r--perl-install/partition_table/gpt.pm2
-rw-r--r--perl-install/partition_table/mac.pm2
-rw-r--r--perl-install/partition_table/raw.pm10
-rw-r--r--perl-install/partition_table/sun.pm2
7 files changed, 36 insertions, 11 deletions
diff --git a/perl-install/partition_table.pm b/perl-install/partition_table.pm
index c99cb10f8..049c7bb2e 100644
--- a/perl-install/partition_table.pm
+++ b/perl-install/partition_table.pm
@@ -482,16 +482,17 @@ sub write {
#- it will never be writed back on partition table.
verifyParts($hd);
- $hd->write(0, $hd->{primary}{raw}, $hd->{primary}{info}) or die "writing of partition table failed";
-
+ my $handle = $hd->start_write();
+ $hd->write($handle, 0, $hd->{primary}{raw}, $hd->{primary}{info}) or die "writing of partition table failed";
#- should be fixed but a extended exist with no real extended partition, that blanks mbr!
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};
- $hd->write($_->{start}, $_->{raw}) or die "writing of partition table failed";
+ $hd->write($handle, $_->{start}, $_->{raw}) or die "writing of partition table failed";
}
+ $hd->end_write($handle);
$hd->{isDirty} = 0;
if (my $tell_kernel = delete $hd->{will_tell_kernel}) {
diff --git a/perl-install/partition_table/bsd.pm b/perl-install/partition_table/bsd.pm
index b27df6d3a..ec2a2edf4 100644
--- a/perl-install/partition_table/bsd.pm
+++ b/perl-install/partition_table/bsd.pm
@@ -90,7 +90,7 @@ sub read_one {
# write the partition table (and extended ones)
# for each entry, it uses fields: start, size, pt_type, active
sub write($$$;$) {
- my ($hd, $sector, $pt, $info) = @_;
+ my ($hd, $_handle, $sector, $pt, $info) = @_;
#- handle testing for writing partition table on file only!
my $F;
diff --git a/perl-install/partition_table/dos.pm b/perl-install/partition_table/dos.pm
index 004c8a11f..c56cdab31 100644
--- a/perl-install/partition_table/dos.pm
+++ b/perl-install/partition_table/dos.pm
@@ -236,10 +236,9 @@ sub read_one {
[ @pt ];
}
-# write the partition table (and extended ones)
-# for each entry, it uses fields: start, size, pt_type, active
-sub write {
- my ($hd, $sector, $pt) = @_;
+# prepare to write the partition table (and extended ones)
+sub start_write {
+ my ($hd) = @_;
log::l("partition::dos::write $hd->{device}");
@@ -250,6 +249,16 @@ sub write {
open $F, ">$file" or die "error opening test file $file";
} else {
$F = partition_table::raw::openit($hd, 2) or die "error opening device $hd->{device} for writing";
+ }
+ $F;
+}
+
+# write the partition table (and extended ones)
+# for each entry, it uses fields: start, size, pt_type, active
+sub write {
+ my ($hd, $F, $sector, $pt) = @_;
+
+ if (!$::testing) {
c::lseek_sector(fileno($F), $sector, $offset) or return 0;
}
@@ -264,6 +273,11 @@ sub write {
1;
}
+sub end_write {
+ my ($hd, $F) = @_;
+ close $F;
+}
+
sub empty_raw { { raw => [ ({}) x $nb_primary ] } }
sub initialize {
diff --git a/perl-install/partition_table/gpt.pm b/perl-install/partition_table/gpt.pm
index 3ac6673d6..df8ead3be 100644
--- a/perl-install/partition_table/gpt.pm
+++ b/perl-install/partition_table/gpt.pm
@@ -71,7 +71,7 @@ sub read_one {
}
sub write {
- my ($hd, $_sector, $pt, $_info) = @_;
+ my ($hd, $_handle, $_sector, $pt, $_info) = @_;
my $partitions_killed;
diff --git a/perl-install/partition_table/mac.pm b/perl-install/partition_table/mac.pm
index 547704b45..78e5469cd 100644
--- a/perl-install/partition_table/mac.pm
+++ b/perl-install/partition_table/mac.pm
@@ -193,7 +193,7 @@ sub read_one {
}
sub write($$$;$) {
- my ($hd, $sector, $pt, $info) = @_;
+ my ($hd, $_handle, $sector, $pt, $info) = @_;
#- handle testing for writing partition table on file only!
my $F;
diff --git a/perl-install/partition_table/raw.pm b/perl-install/partition_table/raw.pm
index 7b4e7d5cf..e9b293b90 100644
--- a/perl-install/partition_table/raw.pm
+++ b/perl-install/partition_table/raw.pm
@@ -295,4 +295,14 @@ A test to check the integrity of data has failed.
It means writing anything on the disk will end up with random, corrupted data.");
}
+sub start_write {
+ my ($_hd) = @_;
+ 1;
+}
+
+sub end_write {
+ my ($_hd, $_handle) = @_;
+ 1;
+}
+
1;
diff --git a/perl-install/partition_table/sun.pm b/perl-install/partition_table/sun.pm
index e2fd747ac..e665d0168 100644
--- a/perl-install/partition_table/sun.pm
+++ b/perl-install/partition_table/sun.pm
@@ -119,7 +119,7 @@ sub read_one {
# write the partition table (and extended ones)
# for each entry, it uses fields: start, size, pt_type, active
sub write($$$;$) {
- my ($hd, $sector, $pt, $info) = @_;
+ my ($hd, $_handle, $sector, $pt, $info) = @_;
# my ($csize, $wdsize) = (0, 0);
#- handle testing for writing partition table on file only!