diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2004-07-27 10:31:34 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2004-07-27 10:31:34 +0000 |
commit | 0306ad0100b9d40606d723706f909438a27dfac1 (patch) | |
tree | 232eab774506632a3796a5a36cf09771aa614e64 /perl-install/partition_table | |
parent | 54a662b712a584c66a9f5762d264cce50acbb6ab (diff) | |
download | drakx-backup-do-not-use-0306ad0100b9d40606d723706f909438a27dfac1.tar drakx-backup-do-not-use-0306ad0100b9d40606d723706f909438a27dfac1.tar.gz drakx-backup-do-not-use-0306ad0100b9d40606d723706f909438a27dfac1.tar.bz2 drakx-backup-do-not-use-0306ad0100b9d40606d723706f909438a27dfac1.tar.xz drakx-backup-do-not-use-0306ad0100b9d40606d723706f909438a27dfac1.zip |
- add field {fs_type} partially replacing {pt_type}
{pt_type} is always a number, {fs_type} is always a string
- introduce set_isFormatted()
(to ensure {notFormatted} but also {fs_type_from_magic} and {bad_fs_type_magic} are updated)
- don't use 0x483 for ext3 anymore (same for reiserfs...),
the type_name gives both a pt_type and a fs_type
- many accessors from partition_table removed (type2fs(), fs2pt_type())
- remove isThisFs() (not useful anymore since we can use directly {fs_type})
- remove isFat() (inline the function)
- other isXXX() from partition_table are moved to fs::type
- part2name() is now fs::type::part2type_name
- name2pt_type() is now fs::type::type_name2subpart()
- partition_table::important_types() is now fs::type::type_names()
- fsedit::typeOfPart() is now fs::type::fs_type_from_magic()
- no need to truncate type_name since they are shorter
Diffstat (limited to 'perl-install/partition_table')
-rw-r--r-- | perl-install/partition_table/bsd.pm | 2 | ||||
-rw-r--r-- | perl-install/partition_table/dos.pm | 4 | ||||
-rw-r--r-- | perl-install/partition_table/gpt.pm | 4 | ||||
-rw-r--r-- | perl-install/partition_table/mac.pm | 17 | ||||
-rw-r--r-- | perl-install/partition_table/sun.pm | 6 |
5 files changed, 19 insertions, 14 deletions
diff --git a/perl-install/partition_table/bsd.pm b/perl-install/partition_table/bsd.pm index cdf18e6d1..0e2421c25 100644 --- a/perl-install/partition_table/bsd.pm +++ b/perl-install/partition_table/bsd.pm @@ -73,7 +73,7 @@ sub read($$) { my $size = psizeof($format); my @pt = map { my %h; @h{@fields} = unpack $format, $_; - $h{pt_type} = $pt_typeToDos{$h{pt_type}} || $h{pt_type}; + fs::type::set_pt_type(\%h, $pt_typeToDos{$h{pt_type}} || $h{pt_type}); \%h; } $info{partitions} =~ /(.{$size})/g; diff --git a/perl-install/partition_table/dos.pm b/perl-install/partition_table/dos.pm index 38cdf60ed..8c30e6558 100644 --- a/perl-install/partition_table/dos.pm +++ b/perl-install/partition_table/dos.pm @@ -185,7 +185,9 @@ sub read { 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; + my %h; + @h{@fields} = unpack $format, $tmp; + fs::type::set_pt_type(\%h, $h{pt_type}); \%h; } (1..$nb_primary); diff --git a/perl-install/partition_table/gpt.pm b/perl-install/partition_table/gpt.pm index 2f1506bbd..423d73a7a 100644 --- a/perl-install/partition_table/gpt.pm +++ b/perl-install/partition_table/gpt.pm @@ -130,8 +130,8 @@ sub read_partitionEntries { sysread $F, $tmp, psizeof($partitionEntry_format) or die "error while reading partition table in sector $info->{partitionEntriesLBA}"; my %h; @h{@$partitionEntry_fields} = unpack $partitionEntry_format, $tmp; $h{size} = $h{ending} - $h{start} + 1; - $h{pt_type} = $gpt_types_rev{$h{gpt_type}}; - $h{pt_type} = 0x100 if !defined $h{pt_type}; + my $pt_type = $gpt_types_rev{$h{gpt_type}}; + fs::type::set_pt_type(\%h, defined $pt_type ? $pt_type : 0x100); \%h; } (1 .. $info->{nbPartitions}); \@pt; diff --git a/perl-install/partition_table/mac.pm b/perl-install/partition_table/mac.pm index 219b6434d..4b60710bb 100644 --- a/perl-install/partition_table/mac.pm +++ b/perl-install/partition_table/mac.pm @@ -7,6 +7,7 @@ use vars qw(@ISA $freepart $bootstrap_part $macos_part); @ISA = qw(partition_table::raw); use common; +use fs::type; use partition_table::raw; use partition_table; use c; @@ -139,7 +140,7 @@ sub read($$) { $h{start} = ($h{pPBlockStart} * $info{bzBlkSize}) / 512; if ($h{pType} =~ /^Apple_UNIX_SVR2/i) { - $h{pName} =~ /swap/i ? ($h{pt_type} = 0x82) : ($h{pt_type} = 0x83); + $h{fs_type} = $h{pName} =~ /swap/i ? 'swap' : 'ext2'; } elsif ($h{pType} =~ /^Apple_Free/i) { #- need to locate a 1MB partition to setup a bootstrap on if ($freepart && $freepart->{size} >= 1) { @@ -151,7 +152,7 @@ sub read($$) { $h{pt_type} = 0x0; $h{pName} = 'Extra'; } elsif ($h{pType} =~ /^Apple_HFS/i) { - $h{pt_type} = 0x402; + fs::type::set_pt_type(\%h, 0x402); if (defined $macos_part) { #- swag at identifying MacOS - 1st HFS partition } else { @@ -297,27 +298,27 @@ sub write($$$;$) { log::l("writing a bootstrap at /dev/$_->{device}"); $install_steps_interactive::new_bootstrap = 1 if !(defined $partition_table::mac::bootstrap_part); $bootstrap_part = "/dev/" . $_->{device}; - } elsif ($_->{pt_type} == 0x82) { + } elsif (isSwap($_)) { $_->{pType} = "Apple_UNIX_SVR2"; $_->{pName} = "swap"; $_->{pFlags} = 0x33; - } elsif ($_->{pt_type} == 0x83) { + } elsif ($_->{fs_type} eq 'ext2') { $_->{pType} = "Apple_UNIX_SVR2"; $_->{pName} = "Linux Native"; $_->{pFlags} = 0x33; - } elsif ($_->{pt_type} == 0x183) { + } elsif ($_->{fs_type} eq 'reiserfs') { $_->{pType} = "Apple_UNIX_SVR2"; $_->{pName} = "Linux ReiserFS"; $_->{pFlags} = 0x33; - } elsif ($_->{pt_type} == 0x283) { + } elsif ($_->{fs_type} eq 'xfs') { $_->{pType} = "Apple_UNIX_SVR2"; $_->{pName} = "Linux XFS"; $_->{pFlags} = 0x33; - } elsif ($_->{pt_type} == 0x383) { + } elsif ($_->{fs_type} eq 'jfs') { $_->{pType} = "Apple_UNIX_SVR2"; $_->{pName} = "Linux JFS"; $_->{pFlags} = 0x33; - } elsif ($_->{pt_type} == 0x483) { + } elsif ($_->{fs_type} eq 'ext3') { $_->{pType} = "Apple_UNIX_SVR2"; $_->{pName} = "Linux ext3"; $_->{pFlags} = 0x33; diff --git a/perl-install/partition_table/sun.pm b/perl-install/partition_table/sun.pm index 7c8a6beb9..54e734ca8 100644 --- a/perl-install/partition_table/sun.pm +++ b/perl-install/partition_table/sun.pm @@ -9,6 +9,7 @@ use vars qw(@ISA); use common; use partition_table::raw; use partition_table; +use fs::type; use c; my ($main_format, $main_fields) = list2kv( @@ -92,8 +93,9 @@ sub read($$) { my @infos_up = unpack $format1 x $nb_primary, $info{infos}; my @partitions_up = unpack $format2 x $nb_primary, $info{partitions}; foreach (0..$nb_primary-1) { - my $h = { pt_type => $infos_up[2 * $_], flag => $infos_up[1 + 2 * $_], + my $h = { flag => $infos_up[1 + 2 * $_], start_cylinder => $partitions_up[2 * $_], size => $partitions_up[1 + 2 * $_] }; + fs::type::set_pt_type($h, $infos_up[2 * $_]); $h->{start} = $sector + $h->{start_cylinder} * $hd->cylinder_size; $h->{pt_type} && $h->{size} or $h->{$_} = 0 foreach keys %$h; push @pt, $h; @@ -133,7 +135,7 @@ sub write($$$;$) { # $csize += $_->{size} if $_->{pt_type} != 5; # $wdsize += $_->{size} if $_->{pt_type} == 5; $_->{flags} |= 0x10 if $_->{mntpoint} eq '/'; - $_->{flags} |= 0x01 if partition_table::isSwap($_); + $_->{flags} |= 0x01 if !isSwap($_); local $_->{start_cylinder} = $_->{start} / $hd->cylinder_size - $sector; pack($format1, @$_{@$fields1}), pack($format2, @$_{@$fields2}); } @$pt; |