diff options
Diffstat (limited to 'perl-install/fs/get.pm')
| -rw-r--r-- | perl-install/fs/get.pm | 75 |
1 files changed, 60 insertions, 15 deletions
diff --git a/perl-install/fs/get.pm b/perl-install/fs/get.pm index 5ea9071a8..00c807738 100644 --- a/perl-install/fs/get.pm +++ b/perl-install/fs/get.pm @@ -1,4 +1,4 @@ -package fs::get; # $Id$ +package fs::get; use diagnostics; use strict; @@ -6,32 +6,45 @@ use strict; use partition_table; use fs::type; use fs::loopback; +use fs::wild_device; use fs; use common; use log; + +=head1 SYNOPSYS + +B<fs::get> + +=head1 Functions + +=over + +=cut + sub empty_all_hds() { - { hds => [], lvms => [], raids => [], loopbacks => [], raw_hds => [], nfss => [], smbs => [], davs => [], special => [] }; + { hds => [], lvms => [], raids => [], dmcrypts => [], loopbacks => [], raw_hds => [], nfss => [], smbs => [], davs => [], special => [] }; } sub fstab { my ($all_hds) = @_; my @parts = map { partition_table::get_normal_parts($_) } hds($all_hds); - @parts, @{$all_hds->{raids}}, @{$all_hds->{loopbacks}}; + @parts, @{$all_hds->{raids}}, @{$all_hds->{dmcrypts}}, @{$all_hds->{loopbacks}}; } sub really_all_fstab { my ($all_hds) = @_; my @l = fstab($all_hds); - @l, @{$all_hds->{raw_hds}}, @{$all_hds->{nfss}}, @{$all_hds->{smbs}}, @{$all_hds->{davs}}; + @l, (grep { !$_->{is_removable} } @{$all_hds->{raw_hds}}), @{$all_hds->{nfss}}, @{$all_hds->{smbs}}, @{$all_hds->{davs}}; } sub fstab_and_holes { - my ($all_hds) = @_; - hds_fstab_and_holes(hds($all_hds)), @{$all_hds->{raids}}, @{$all_hds->{loopbacks}}; + my ($all_hds, $b_non_readonly) = @_; + my @hds = grep { !($b_non_readonly && $_->{readonly}) } hds($all_hds); + hds_fstab_and_holes(@hds), @{$all_hds->{raids}}, @{$all_hds->{dmcrypts}}, @{$all_hds->{loopbacks}}; } sub holes { - my ($all_hds) = @_; - grep { isEmpty($_) } fstab_and_holes($all_hds); + my ($all_hds, $b_non_readonly) = @_; + grep { isEmpty($_) } fstab_and_holes($all_hds, $b_non_readonly); } sub hds_holes { grep { isEmpty($_) } hds_fstab_and_holes(@_); @@ -49,16 +62,27 @@ sub hds { (@{$all_hds->{hds}}, @{$all_hds->{lvms}}); } -#- get all normal partition including special ones as found on sparc. +=item hds_fstab(@hds) + +Get all normal partition. + +=cut + sub hds_fstab { map { partition_table::get_normal_parts($_) } @_; } +sub vg_free_space { + my ($hd) = @_; + my @parts = partition_table::get_normal_parts($hd); + $hd->{totalsectors} - sum map { $_->{size} } @parts; +} + sub hds_fstab_and_holes { map { if (isLVM($_)) { my @parts = partition_table::get_normal_parts($_); - my $free = $_->{totalsectors} - sum map { $_->{size} } @parts; + my $free = vg_free_space($_); my $free_part = { start => 0, size => $free, pt_type => 0, rootDevice => $_->{VG_name} }; @parts, if_($free >= $_->cylinder_size, $free_part); } else { @@ -70,7 +94,7 @@ sub hds_fstab_and_holes { sub device2part { my ($dev, $fstab) = @_; - my $subpart = fs::subpart_from_wild_device_name($dev); + my $subpart = fs::wild_device::to_subpart($dev); my $part = find { is_same_hd($subpart, $_) } @$fstab; log::l("fs::get::device2part: unknown device <<$dev>>") if !$part; $part; @@ -88,7 +112,7 @@ sub file2part { $file = $b_keep_simple_symlinks ? common::expand_symlinks_but_simple("$::prefix$file") : expand_symlinks("$::prefix$file"); unless ($file =~ s/^$::prefix//) { - my $part = find { fs::loopback::carryRootLoopback($_) } @$fstab or die; + my $part = find { fs::type::carry_root_loopback($_) } @$fstab or die; log::l("found $part->{mntpoint}"); $file =~ s|/initrd/loopfs|$part->{mntpoint}|; } @@ -111,6 +135,15 @@ sub has_mntpoint { my ($mntpoint, $all_hds) = @_; mntpoint2part($mntpoint, [ really_all_fstab($all_hds) ]); } + +sub root_from_mounted() { + foreach (`df -P`) { + next if m!^[^/]!; # ignore tootfs + my ($fs, undef, undef, undef, undef, $mntpnt) = split(/\s+/); + return $fs if $mntpnt eq '/'; + } +} + sub root_ { my ($fstab, $o_boot) = @_; $o_boot && mntpoint2part("/boot", $fstab) || mntpoint2part("/", $fstab); @@ -134,10 +167,22 @@ sub is_same_hd { my ($s2) = $hd2->{device} =~ m|https?://(.+?)/*$|; $s1 eq $s2; } else { - $hd1->{devfs_device} && $hd2->{devfs_device} && $hd1->{devfs_device} eq $hd2->{devfs_device} - || $hd1->{device_LABEL} && $hd2->{device_LABEL} && $hd1->{device_LABEL} eq $hd2->{device_LABEL} - || $hd1->{device} && $hd2->{device} && $hd1->{device} eq $hd2->{device}; + $hd1->{device_LABEL} && $hd2->{device_LABEL} && $hd1->{device_LABEL} eq $hd2->{device_LABEL} + || $hd1->{device_UUID} && $hd2->{device_UUID} && $hd1->{device_UUID} eq $hd2->{device_UUID} + || $hd1->{device} && $hd2->{device} && $hd1->{device} eq $hd2->{device} + || $hd1->{device} && $hd2->{device_alias} && $hd1->{device} eq $hd2->{device_alias} + || $hd1->{device_alias} && $hd2->{device} && $hd1->{device_alias} eq $hd2->{device} + || $hd1->{device_alias} && $hd2->{device_alias} && $hd1->{device_alias} eq $hd2->{device_alias}; } } +sub mntpoint_prefixed { + my ($part) = @_; + $::prefix . $part->{mntpoint}; +} + +=back + +=cut + 1; |
