Handle hostnames with upper-case letters
[webmin.git] / format / copy_part_form.cgi
1 #!/usr/local/bin/perl
2 # copy_part_form.cgi
3 # Display a form for copying the partitions map of this disk to otthers
4
5 require './format-lib.pl';
6 &ReadParse();
7 $access{'view'} && &error($text{'ecannot'});
8 &ui_print_header(undef, "Copy Partition Map", "");
9 $extwidth = 400;
10
11 print "This form allows you to copy the partition map from this disk\n";
12 print "to others of the same size. This is useful for setting up disks\n";
13 print "for use as parts of a RAID or mirrored MetaDisk.<p>\n";
14 print "<table border width=100%>\n";
15 print "<tr $tb> <td><b>Partition</b></td> <td><b>Tag</b></td>\n";
16 print "<td><b>Extent</b></td> <td><b>Start</b></td> <td><b>End</b></td></tr>\n";
17 @dlist = &list_disks();
18 @dinfo = split(/\s+/, $dlist[$in{disk}]); $cyl = $dinfo[2];
19 @plist = &list_partitions($in{disk});
20 for($i=0; $i<@plist; $i++) {
21         @p = split(/\s+/, $plist[$i]);
22         print "<tr $cb> <td>$i</td> <td>$p[0]</td>\n";
23         if ($p[3]) {
24                 printf "<td><img src=images/gap.gif height=10 width=%d>",
25                         $extwidth*$p[2]/$cyl;
26                 printf "<img src=images/use.gif height=10 width=%d>",
27                         $extwidth*($p[3]-$p[2])/$cyl;
28                 printf "<img src=images/gap.gif height=10 width=%d></td>\n",
29                         $extwidth*($cyl-$p[3])/$cyl;
30                 print "<td>$p[2]</td> <td>$p[3]</td> </tr>\n";
31                 }
32         else { print "<td colspan=3><br></td>\n"; }
33         print "</tr>\n";
34         }
35 print "</table><p>\n";
36
37 # find all disks that are not in use
38 print "Select the disks to copy this partition map to..<br>\n";
39 print "<form action=copy_part.cgi>\n";
40 print "<table border width=100%>\n";
41 print "<tr $tb><td></td> <td><b>Disk Type</b></td> <td><b>Cylinders</b></td>\n";
42 print "     <td><b>Controller</b></td> <td><b>Target</b></td>\n";
43 print "     <td><b>Unit</b></td> <td><b>Device</b></td> <td><br></td> </tr>\n";
44 for($i=0; $i<@dlist; $i++) {
45         print "<tr $cb> <td width=20>";
46         @d = split(/\s+/, $dlist[$i]);
47         undef($err);
48         if ($d[2] ne $cyl) { $err = "Different disk size"; }
49         elsif ($i == $in{disk}) { $err = "Source disk"; }
50         else {
51                 @plist = split(/\s+/, &list_partitions($i));
52                 for($j=0; $j<@plist; $j++) {
53                         $dev = "/dev/dsk/$d[0]s$j";
54                         if (&device_status($dev)) {
55                                 $err = "Currently in use";
56                                 }
57                         }
58                 }
59
60         if (!$err) { print "<input type=checkbox name=disk$i>\n"; }
61         else { print "<br>"; }
62         print "</td>\n";
63
64         print "<td>$d[1]</td> <td>$d[2]</td>\n";
65         $d[0] =~ /c(\d+)t(\d+)d(\d+)/;
66         print "<td>$1</td> <td>$2</td> <td>$3</td> <td>$d[0]</td>\n";
67         if ($err) { print "<td><font color=#ff0000>$err</font></td> </tr>\n"; }
68         else { print "<td><font color=#00ff00>Possible target</font></td> </tr>\n"; }
69         if (!$err) { $foundone = 1; }
70         }
71 print "</table><p>\n";
72 if ($foundone) { print "<input type=submit value=Copy>\n"; }
73 else { print "No disks are possible targets for copying.\n"; }
74 print "</form>\n";
75
76 &ui_print_footer("", "disk list");
77