Handle hostnames with upper-case letters
[webmin.git] / format / index.cgi
1 #!/usr/local/bin/perl
2 # index.cgi
3 # Display a list of known disks and partitions
4
5 require './format-lib.pl';
6 &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0,
7         &help_search_link("format", "man"));
8 $extwidth = 250;
9
10 print "<table border width=100%>\n";
11 print "<tr $tb> <td><b>$text{'index_disk'}</b></td> ",
12       "<td><b>$text{'index_parts'}</b></td> </tr>\n";
13 @dlist = &list_disks();
14 $mountcan = &foreign_available("mount");
15 for($i=0; $i<@dlist; $i++) {
16         $dl = $dlist[$i];
17         next if (!&can_edit_disk($dl->{'device'}));
18         print "<tr $cb> <td valign=top><table>\n";
19         print "<tr> <td><b>$text{'index_location'}</b></td> ";
20         print "<td>$dl->{'desc'}</td> </tr>\n";
21         print "<tr> <td><b>$text{'index_cyl'}</b></td>\n";
22         print "<td>$dl->{'cyl'}</td> </tr>\n";
23         print "<tr> <td><b>$text{'index_model'}</b></td> ";
24         print "<td>",$dl->{'type'} ? $dl->{'type'} : $text{'index_unknown'},
25               "</td> </tr>\n";
26         print "</table></td> <td valign=top>\n";
27         if (!$dl->{'device'}) {
28                 # Drive type unknown..
29                 print "<b>$text{'index_unknown2'}</b>\n";
30                 }
31         elsif (@parts = &list_partitions($dl->{'device'})) {
32                 # Known and formatted..
33                 print "<table width=100%>\n";
34                 print "<tr> <td><b>$text{'index_no'}</b></td> ",
35                       "<td><b>$text{'index_type'}</b></td> ",
36                       "<td><b>$text{'index_extent'}</b></td> ",
37                       "<td><b>$text{'index_start'}</b></td> ",
38                       "<td><b>$text{'index_end'}</b></td> ",
39                       "<td><b>$text{'index_use'}</b></td> ",
40                       "<td><b>$text{'index_free'}</b></td> </tr>\n";
41                 for($j=0; $j<@parts; $j++) {
42                         $p = $parts[$j];
43                         print "<tr> <td>\n";
44                         if ($access{'view'}) {
45                                 print $j;
46                                 }
47                         else {
48                                 print "<a href=\"edit_part.cgi?$i+$j\">$j</a>";
49                                 }
50                         print "</td> <td>$p->{'tag'}</td> <td>\n";
51                         if ($p->{'end'} != 0) {
52                                 printf
53                                   "<img src=images/gap.gif height=10 width=%d>",
54                                   $extwidth*$p->{'start'}/$dl->{'cyl'};
55                                 printf
56                                   "<img src=images/use.gif height=10 width=%d>",
57                                   $extwidth*($p->{'end'}-$p->{'start'})/
58                                   $dl->{'cyl'};
59                                 printf
60                                   "<img src=images/gap.gif height=10 width=%d>",
61                                   $extwidth*($dl->{'cyl'}-$p->{'end'})/
62                                   $dl->{'cyl'};
63                                 print "</td> <td>$p->{'start'}</td> ",
64                                       "<td>$p->{'end'}</td> <td>\n";
65                                 @stat = &device_status($p->{'device'});
66                                 if ($stat[1] =~ /^meta/) {
67                                         print "MetaDisk\n";
68                                         }
69                                 elsif (!$mountcan) {
70                                         print "<tt>$stat[0]</tt>\n";
71                                         }
72                                 elsif ($stat[0] && $stat[3] == -1) {
73                                         print "<tt><a href=/mount/edit_mount.cgi?index=$stat[4]&temp=1&return=/$module_name/>$stat[0]</a></tt>\n";
74                                         }
75                                 elsif ($stat[0]) {
76                                         print "<tt><a href=/mount/edit_mount.cgi?index=$stat[3]&return=/$module_name/>$stat[0]</a></tt>\n";
77                                         }
78                                 print "</td> <td>\n";
79                                 if ($stat[0] ne 'swap' &&
80                                     (@space = &disk_space($p->{'device'})) &&
81                                     $space[0]) {
82                                         printf "%d %%\n",
83                                                100 * $space[1] / $space[0];
84                                         }
85                                 print "</td> </tr>\n";
86                                 }
87                         else { print "<td colspan=5></td>\n"; }
88                         }
89                 print "</table>\n";
90                 }
91         else {
92                 # Disk is not formatted.. 
93                 print "<b>$text{'index_format'}</b>\n";
94                 }
95         print "</td> </tr>\n";
96         }
97 print "</table><p>\n";
98
99 &ui_print_footer("/", $text{'index'});
100