summaryrefslogtreecommitdiffstats
path: root/perl-install/partition_table.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>1999-07-30 20:34:38 +0000
committerPascal Rigaux <pixel@mandriva.com>1999-07-30 20:34:38 +0000
commit91419eac51774d733b905ac2d54b3bde60a208df (patch)
tree80b2b4ebd499f750df5a12a0237bf6ab736619d4 /perl-install/partition_table.pm
parent5ed323fc9a6c7e36a81242fa4a104ba3ea514339 (diff)
downloaddrakx-backup-do-not-use-91419eac51774d733b905ac2d54b3bde60a208df.tar
drakx-backup-do-not-use-91419eac51774d733b905ac2d54b3bde60a208df.tar.gz
drakx-backup-do-not-use-91419eac51774d733b905ac2d54b3bde60a208df.tar.bz2
drakx-backup-do-not-use-91419eac51774d733b905ac2d54b3bde60a208df.tar.xz
drakx-backup-do-not-use-91419eac51774d733b905ac2d54b3bde60a208df.zip
no_comment
Diffstat (limited to 'perl-install/partition_table.pm')
-rw-r--r--perl-install/partition_table.pm38
1 files changed, 38 insertions, 0 deletions
diff --git a/perl-install/partition_table.pm b/perl-install/partition_table.pm
index 8ea4744bc..49058e9ed 100644
--- a/perl-install/partition_table.pm
+++ b/perl-install/partition_table.pm
@@ -13,6 +13,7 @@ use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK @important_types);
use common qw(:common :system);
use partition_table_raw;
+use Data::Dumper;
@important_types = ("Linux native", "Linux swap", "DOS FAT16", "Win98 FAT32");
@@ -75,6 +76,8 @@ my %type2fs = (
my %types_rev = reverse %types;
my %fs2type = reverse %type2fs;
+my @fields2save = qw(primary extended totalsectors);
+
1;
@@ -355,3 +358,38 @@ sub raw_add($$) {
die "raw_add: partition table already full";
}
+sub load($$;$) {
+ my ($hd, $file, $force) = @_;
+
+ local *F;
+ open F, $file or die _("Error reading file $file");
+
+ my $h;
+ {
+ no strict 'vars';
+ $h = eval join '', <F>;
+ }
+ $@ and die _("Restoring from file $file failed: $@");
+
+ ref $h eq 'HASH' or die _("Bad backup file");
+
+ $h->{totalsectors} == $hd->{totalsectors} or $force
+ or die "Bad totalsectors";
+
+ # unsure we don't modify totalsectors
+ $h->{totalsectors} = $hd->{totalsectors} if $force;
+
+ @{$hd}{@fields2save} = @{$h}{@fields2save};
+
+ $hd->{isDirty} = $hd->{needKernelReread} = 1;
+}
+
+
+sub save($$) {
+ my ($hd, $file) = @_;
+ my %h; @h{@fields2save} = @{$hd}{@fields2save};
+ local *F;
+ open F, ">$file"
+ and print F Dumper(\%h)
+ or die _("Error writing to file $file");
+}