[Fai-commit] r3614 - people/michael/features/setup_harddisks_2/implementation

fai-commit at lists.alioth.debian.org fai-commit at lists.alioth.debian.org
Sat Jul 22 13:35:13 UTC 2006


Author: michael-guest
Date: 2006-07-22 13:35:12 +0000 (Sat, 22 Jul 2006)
New Revision: 3614

Modified:
   people/michael/features/setup_harddisks_2/implementation/shdd2-fstab
   people/michael/features/setup_harddisks_2/implementation/shdd2-parser
Log:
implemented fstab script


Modified: people/michael/features/setup_harddisks_2/implementation/shdd2-fstab
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/shdd2-fstab	2006-07-22 13:25:23 UTC (rev 3613)
+++ people/michael/features/setup_harddisks_2/implementation/shdd2-fstab	2006-07-22 13:35:12 UTC (rev 3614)
@@ -4,5 +4,80 @@
 
 package FAI;
 
+
+
+#call this function only with one parameter (generate_fstab($hash_ref)). The rest is used for recursion
+sub generate_fstab
+{
+  my ($hash_ref, $modus, $device, $listref, $call_count) = @_;
+
+  if(!$listref)
+  {
+    my @newlist = ();
+    $listref = \@newlist;
+  }
+
+  if(!$call_count)
+  {
+    $call_count = 1; 
+  }
+  else
+  {
+    $call_count++;
+  }
+
+  foreach my $key (keys %$hash_ref)
+  {
+
+    if (ref($hash_ref->{$key}) && $key  =~ /^PHY_(.*)$/  )
+    {
+      $modus = "PHY";
+      $device = $1;
+    }
+
+
+    if (ref($hash_ref->{$key}) && $key eq "partitions")
+    {
+
+      foreach my $partition (keys %{$hash_ref->{$key}})
+      {
+        my $p_ref = $hash_ref->{$key}->{$partition};
+        if(!$p_ref->{'size'}->{'extended'})
+        {
+          my @fstab_line=();
+          push @fstab_line, $device.$partition;
+          push @fstab_line, $p_ref->{'mountpoint'};
+          push @fstab_line, $p_ref->{'filesystem'};
+          push @fstab_line, $p_ref->{'mount_options'};
+          push @fstab_line, 0;
+          if($p_ref->{'mountpoint'} eq "/root")
+          {
+            push @fstab_line, 1;
+          }
+          else
+          {
+            push @fstab_line, 2;         
+          }
+          push @$listref, join("\t", @fstab_line);
+        }
+
+      }
+
+    }
+    if (ref($hash_ref->{$key}))
+    {
+      &generate_fstab($hash_ref->{$key},$modus,$device,$listref,$call_count);
+    }
+
+  }
+  if($call_count eq 1)
+  {
+    return @$listref; 
+  }
+}
+
+
+
+
 1;
 

Modified: people/michael/features/setup_harddisks_2/implementation/shdd2-parser
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/shdd2-parser	2006-07-22 13:25:23 UTC (rev 3613)
+++ people/michael/features/setup_harddisks_2/implementation/shdd2-parser	2006-07-22 13:35:12 UTC (rev 3614)
@@ -2,6 +2,7 @@
 
 use strict;
 
+require "shdd2-fstab";
 
 #
 # file ::= <lines> EOF
@@ -393,6 +394,11 @@
 defined $Parser->file( $input ) or die "Syntax error\n";
 
 &print_hash(\%FAI::configs);
+my @fstab = &FAI::generate_fstab(\%FAI::configs);
+foreach my $line (@fstab)
+{
+  printf $line."\n";
+}
 
 
 1;




More information about the Fai-commit mailing list