Re-use free low MD numbers
authorJamie Cameron <jcameron@webmin.com>
Fri, 21 Aug 2009 05:58:56 +0000 (22:58 -0700)
committerJamie Cameron <jcameron@webmin.com>
Fri, 21 Aug 2009 05:58:56 +0000 (22:58 -0700)
raid/raid_form.cgi

index d42a57c..8e711d3 100755 (executable)
@@ -8,14 +8,16 @@ require './raid-lib.pl';
 &ReadParse();
 $conf = &get_raidtab();
 
-# Display headers
-$max = 0;
+# Create initial object
 foreach $c (@$conf) {
-       if ($c->{'value'} =~ /md(\d+)$/ && $1 >= $max) {
-               $max = $1+1;
+       if ($c->{'value'} =~ /md(\d+)$/) {
+               $taken{$1} = 1;
                }
        }
-&ui_print_header(undef, $text{'create_title'}, "");
+$max = 0;
+while($taken{$max}) {
+       $max++;
+       }
 $raid = { 'value' => "/dev/md$max",
          'members' => [ { 'name' => 'raid-level',
                           'value' => $in{'level'} },
@@ -23,6 +25,8 @@ $raid = { 'value' => "/dev/md$max",
                           'value' => 1 }
                       ] };
 
+&ui_print_header(undef, $text{'create_title'}, "");
+
 # Find available partitions
 @disks = &find_free_partitions(undef, 1, 1);
 if (!@disks) {