3 # Display a list of known disks and partitions
5 require './fdisk-lib.pl';
6 &error_setup($text{'index_err'});
9 # Work out which disks are accessible
10 @disks = &list_disks_partitions();
11 @disks = grep { $access{'view'} || &can_edit_disk($_->{'device'}) } @disks;
12 if (@disks == 1 && &can_edit_disk($disks[0]->{'device'})) {
13 # Just one .. go direct to it's page
14 &redirect("edit_disk.cgi?device=$disks[0]->{'device'}");
18 $pdesc = $has_parted ? $text{'index_parted'} : $text{'index_fdisk'};
19 &ui_print_header($pdesc, $module_info{'desc'}, "", undef, 1, 1, 0,
20 &help_search_link("fdisk", "man", "doc", "howto"));
23 # Check for critical commands
25 &has_command("parted") ||
26 &ui_print_endpage(&text('index_ecmd', '<tt>parted</tt>'));
29 &has_command("fdisk") ||
30 &ui_print_endpage(&text('index_ecmd', '<tt>fdisk</tt>'));
33 # Show a table of just disks
34 @disks = sort { $a->{'device'} cmp $b->{'device'} } @disks;
36 ($hasctrl) = grep { defined($d->{'scsiid'}) ||
37 defined($d->{'controller'}) ||
38 $d->{'raid'} } @disks;
39 print &ui_columns_start([ $text{'index_dname'},
41 $text{'index_dmodel'},
42 $text{'index_dparts'},
43 $hasctrl ? ( $text{'index_dctrl'} ) : ( ),
44 $text{'index_dacts'} ]);
46 $ed = &can_edit_disk($d->{'device'});
47 $smart = &supports_smart($d);
50 if (defined($d->{'scsiid'}) && defined($d->{'controller'})) {
51 push(@ctrl, &text('index_dscsi', $d->{'scsiid'},
55 push(@ctrl, &text('index_draid', $d->{'raid'}));
57 if ($ed && &supports_hdparm($d)) {
58 # Display link to IDE params form
59 push(@links, "<a href='edit_hdparm.cgi?".
60 "disk=$d->{'index'}'>$text{'index_dhdparm'}</a>");
62 if (&supports_smart($d)) {
63 # Display link to smart module
64 push(@links, "<a href='../smart-status/index.cgi?".
65 "drive=$d->{'device'}'>$text{'index_dsmart'}</a>");
67 print &ui_columns_row([
68 $ed ? "<a href='edit_disk.cgi?device=$d->{'device'}'>".
72 &nice_size($d->{'cylinders'}*$d->{'cylsize'}) : "",
74 scalar(@{$d->{'parts'}}),
75 $hasctrl ? ( join(" ", @ctrl) ) : ( ),
76 &ui_links_row(\@links),
79 print &ui_columns_end();
82 print "<b>$text{'index_none2'}</b><p>\n";
85 &ui_print_footer("/", $text{'index'});