2 # Show the partitions on a single disk
4 require './fdisk-lib.pl';
6 &can_edit_disk($in{'device'}) || &error($text{'disk_ecannot'});
10 @disks = &list_disks_partitions();
11 ($d) = grep { $_->{'device'} eq $in{'device'} } @disks;
12 $d || &error($text{'disk_egone'});
13 @parts = @{$d->{'parts'}};
14 &ui_print_header($d->{'desc'}, $text{'disk_title'}, "");
16 # Work out links to add partitions
18 $usedpri++ if ($p->{'number'} <= 4);
19 $extended++ if ($p->{'extended'});
20 if ($p->{'end'} > $d->{'cylinders'}) {
21 $d->{'cylinders'} = $p->{'end'};
23 if (!$p->{'extended'} && $stat[2] &&
24 &indexof($p->{'type'}, @space_type) >= 0 &&
25 (@space = &disk_space($p->{'device'}, $stat[0])) &&
27 $p->{'free'} = sprintf "%d %%\n", 100 * $space[1] / $space[0];
32 push(@edlinks, "<a href=\"edit_part.cgi?disk=$d->{'index'}&new=1\">".
33 $text{'index_addpri'}."</a>");
36 push(@edlinks, "<a href=\"edit_part.cgi?disk=$d->{'index'}&new=2\">".
37 $text{'index_addlog'}."</a>");
39 elsif ($usedpri != 4 && &supports_extended()) {
40 push(@edlinks, "<a href=\"edit_part.cgi?disk=$d->{'index'}&new=3\">".
41 $text{'index_addext'}."</a>");
44 # Show brief disk info
46 if ($d->{'cylsize'}) {
47 push(@info, &text('disk_dsize', &nice_size($d->{'cylinders'}*$d->{'cylsize'})));
50 push(@info, &text('disk_model', $d->{'model'}));
52 push(@info, &text('disk_cylinders', $d->{'cylinders'}));
54 push(@info, &text('disk_table', uc($d->{'table'})));
56 print &ui_links_row(\@info),"<p>\n";
58 # Show table of partitions, if any
60 print &ui_links_row(\@edlinks);
61 @tds = ( "width=5%", "width=10%", "width=45%", "width=5%", "width=5%", "width=5%", "width=15%", "width=10%" );
62 @tds = map { "nowrap $_" } @tds;
63 print &ui_columns_start([ $text{'disk_no'},
70 $anyfree ? ( $text{'disk_free'} ) : ( ),
73 $url = "edit_part.cgi?disk=$d->{'index'}&part=$p->{'index'}";
75 # Create extent images
77 $ext .= sprintf "<img src=images/gap.gif height=10 width=%d>",
78 $extwidth*($p->{'start'} - 1) /
80 $ext .= sprintf "<img src=images/%s.gif height=10 width=%d>",
81 $p->{'extended'} ? "ext" : "use",
82 $extwidth*($p->{'end'} - $p->{'start'}) /
84 $ext .= sprintf "<img src=images/gap.gif height=10 width=%d>",
85 $extwidth*($d->{'cylinders'} - ($p->{'end'} - 1)) /
89 @stat = &device_status($p->{'device'});
91 $statdesc = $stat[0] =~ /^swap/ ? "<i>$text{'disk_vm'}</i>"
92 : "<tt>$stat[0]</tt>";
93 if ($stat[1] eq 'raid') {
96 elsif ($stat[1] eq 'lvm') {
97 if (&foreign_available("lvm")) {
98 $stat = "<a href='../lvm/'>".
99 "LVM VG $statdesc</a>";
102 $stat = "LVM VG $statdesc";
105 elsif ($stat[0] && !&foreign_available("mount")) {
108 elsif ($stat[0] && $stat[3] == -1) {
109 $stat = "<a href='../mount/edit_mount.cgi?".
110 "index=$stat[4]&temp=1&return=/$module_name/'>".
114 $stat = "<a href='../mount/edit_mount.cgi?".
115 "index=$stat[3]&return=/$module_name/'>".
119 print &ui_columns_row([
120 "<a href='$url'>$p->{'number'}</a>",
121 "<a href='$url'>".($p->{'extended'} ?
122 $text{'extended'} : &tag_name($p->{'type'}))."</a>",
124 $d->{'cylsize'} ? &nice_size(($p->{'end'} - $p->{'start'} + 1) * $d->{'cylsize'}) : &text('edit_blocks', $p->{'blocks'}),
128 $anyfree ? ( $p->{'free'} ) : ( ),
132 print &ui_columns_end();
135 print "<b>$text{'disk_none'}</b><p>\n";
137 print &ui_links_row(\@edlinks);
139 # Buttons for IDE params and SMART
141 print &ui_buttons_start();
142 if (&supports_hdparm($d)) {
143 print &ui_buttons_row("edit_hdparm.cgi", $text{'index_hdparm'},
144 $text{'index_hdparmdesc'},
145 &ui_hidden("disk", $d->{'index'}));
147 if (&supports_smart($d)) {
148 print &ui_buttons_row("../smart-status/index.cgi", $text{'index_smart'},
149 $text{'index_smartdesc'},
150 &ui_hidden("drive", $d->{'device'}));
152 if (&supports_relabel($d)) {
153 print &ui_buttons_row("edit_relabel.cgi", $text{'index_relabel'},
154 $text{'index_relabeldesc'},
155 &ui_hidden("device", $d->{'device'}));
157 print &ui_buttons_end();
159 &ui_print_footer("", $text{'index_return'});