#!/usr/local/bin/perl # index.cgi # Display a list of known disks and partitions require './fdisk-lib.pl'; &error_setup($text{'index_err'}); &check_fdisk(); # Work out which disks are accessible @disks = &list_disks_partitions(); @disks = grep { $access{'view'} || &can_edit_disk($_->{'device'}) } @disks; if (@disks == 1 && &can_edit_disk($disks[0]->{'device'})) { # Just one .. go direct to it's page &redirect("edit_disk.cgi?device=$disks[0]->{'device'}"); edit; } $pdesc = $has_parted ? $text{'index_parted'} : $text{'index_fdisk'}; &ui_print_header($pdesc, $module_info{'desc'}, "", undef, 1, 1, 0, &help_search_link("fdisk", "man", "doc", "howto")); $extwidth = 250; # Check for critical commands if ($has_parted) { &has_command("parted") || &ui_print_endpage(&text('index_ecmd', 'parted')); } else { &has_command("fdisk") || &ui_print_endpage(&text('index_ecmd', 'fdisk')); } # Show a table of just disks @disks = sort { $a->{'device'} cmp $b->{'device'} } @disks; if (@disks) { ($hasctrl) = grep { defined($d->{'scsiid'}) || defined($d->{'controller'}) || $d->{'raid'} } @disks; print &ui_columns_start([ $text{'index_dname'}, $text{'index_dsize'}, $text{'index_dmodel'}, $text{'index_dparts'}, $hasctrl ? ( $text{'index_dctrl'} ) : ( ), $text{'index_dacts'} ]); foreach $d (@disks) { $ed = &can_edit_disk($d->{'device'}); $smart = &supports_smart($d); @links = ( ); @ctrl = ( ); if (defined($d->{'scsiid'}) && defined($d->{'controller'})) { push(@ctrl, &text('index_dscsi', $d->{'scsiid'}, $d->{'controller'})); } if ($d->{'raid'}) { push(@ctrl, &text('index_draid', $d->{'raid'})); } if ($ed && &supports_hdparm($d)) { # Display link to IDE params form push(@links, "$text{'index_dhdparm'}"); } if (&supports_smart($d)) { # Display link to smart module push(@links, "$text{'index_dsmart'}"); } print &ui_columns_row([ $ed ? "". $d->{'desc'}."" : $d->{'desc'}, $d->{'cylsize'} ? &nice_size($d->{'cylinders'}*$d->{'cylsize'}) : "", $d->{'model'}, scalar(@{$d->{'parts'}}), $hasctrl ? ( join(" ", @ctrl) ) : ( ), &ui_links_row(\@links), ]); } print &ui_columns_end(); } else { print "$text{'index_none2'}

\n"; } &ui_print_footer("/", $text{'index'});