Skip to content

Commit

Permalink
convert find_boot_mnt_point() to use argument instead of %FAI::configs
Browse files Browse the repository at this point in the history
old function signature:

  my $boot_mnt_point = find_boot_mnt_point();

new function signature:

  my $boot_mnt_point = find_boot_mnt_point(%FAI::config);

This change does not change the actual functionality. Providing the
configuration via a function argument makes it possible to get rid
of the global variable %FAI::configs later on. As an immediate
benefit it is now obvious that find_boot_mnt_point() uses the data
stored in %FAI::configs to find the boot device.
  • Loading branch information
Thomas Neumann authored and Thomas Lange committed Sep 9, 2015
1 parent e8a8041 commit 0b1f2f9
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions lib/setup-storage/Fstab.pm
Expand Up @@ -143,14 +143,16 @@ sub get_fstab_key {
#
################################################################################
sub find_boot_mnt_point {
my %config = @_;

my $mnt_point = ".NO_SUCH_MOUNTPOINT";

# walk through all configured parts
foreach my $c (keys %FAI::configs) {
foreach my $c (keys %config) {

if ($c =~ /^PHY_(.+)$/) {
foreach my $p (keys %{ $FAI::configs{$c}{partitions} }) {
my $this_mp = $FAI::configs{$c}{partitions}{$p}{mountpoint};
foreach my $p (keys %{ $config{$c}->{partitions} }) {
my $this_mp = $config{$c}->{partitions}->{$p}->{mountpoint};

next if (!defined($this_mp));

Expand All @@ -159,24 +161,24 @@ sub find_boot_mnt_point {
}
} elsif ($c =~ /^VG_(.+)$/) {
next if ($1 eq "--ANY--");
foreach my $l (keys %{ $FAI::configs{$c}{volumes} }) {
my $this_mp = $FAI::configs{$c}{volumes}{$l}{mountpoint};
foreach my $l (keys %{ $config{$c}->{volumes} }) {
my $this_mp = $config{$c}->{volumes}->{$l}->{mountpoint};

next if (!defined($this_mp));

return $this_mp if ($this_mp eq "/boot");
$mnt_point = $this_mp if ($this_mp eq "/");
}
} elsif ($c eq "BTRFS") {
foreach my $b (keys %{ $FAI::configs{$c}{volumes}}) {
my $this_mp = $FAI::configs{$c}{volumes}{mountpoint};
foreach my $b (keys %{ $config{$c}->{volumes}}) {
my $this_mp = $config{$c}->{volumes}->{mountpoint};
next if (!defined($this_mp));
return $this_mp if ($this_mp eq "/boot");
$mnt_point = $this_mp if ($this_mp eq "/");
}
} elsif ($c eq "RAID" || $c eq "CRYPT") {
foreach my $r (keys %{ $FAI::configs{$c}{volumes} }) {
my $this_mp = $FAI::configs{$c}{volumes}{$r}{mountpoint};
foreach my $r (keys %{ $config{$c}->{volumes} }) {
my $this_mp = $config{$c}->{volumes}->{$r}->{mountpoint};

next if (!defined($this_mp));

Expand Down Expand Up @@ -214,7 +216,7 @@ sub generate_fstab {
my @fstab = ();

# mount point for /boot
my $boot_mnt_point = find_boot_mnt_point();
my $boot_mnt_point = find_boot_mnt_point(%FAI::configs);

# walk through all configured parts
# the order of entries is most likely wrong, it is fixed at the end
Expand Down

0 comments on commit 0b1f2f9

Please sign in to comment.