#!/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(); &ui_print_header(undef, $text{'index_title'}, "", undef, 0, 1, 0, &help_search_link("fdisk", "man", "doc", "howto")); $extwidth = 250; $smart = &foreign_installed("smart-status") && &foreign_available("smart-status"); print "\n"; print " ", "\n"; foreach $d (&list_disks_partitions()) { local $ed = &can_edit_disk($d->{'device'}); next if (!$ed && !$access{'view'}); print "\n"; } print "
$text{'index_disk'}$text{'index_parts'}
\n"; print " "; print "\n"; print " ", "\n"; if ($d->{'cylsize'}) { print " ", "\n"; } if ($d->{'model'}) { print " ", "\n"; } if (defined($d->{'scsiid'}) && defined($d->{'controller'})) { print " ", "\n"; print " ", "\n"; } if ($d->{'raid'}) { print " ", "\n"; } # Show links to other modules @links = ( ); if (($d->{'type'} eq 'ide' || $d->{'type'} eq 'scsi' && $d->{'model'} =~ /ATA/) && $ed) { # Display link to IDE params form push(@links, "$text{'index_hdparm'}"); } if ($smart) { # Display link to smart module push(@links, "$text{'index_smart'}"); } if (@links) { print "\n"; } print "
$text{'index_location'}$d->{'desc'}
$text{'index_cylinders'}$d->{'cylinders'}
$text{'index_size'}",&nice_size($d->{'cylinders'}*$d->{'cylsize'}), "
$text{'index_model'}$d->{'model'}
$text{'index_controller'}$d->{'controller'}
$text{'index_scsiid'}$d->{'scsiid'}
$text{'index_raid'}$d->{'raid'}
",&ui_links_row(\@links), "
\n"; @parts = @{$d->{'parts'}}; foreach $p (@parts) { if ($p->{'end'} > $d->{'cylinders'}-1) { $d->{'cylinders'} = $p->{'end'}+1; } } local $extended = 0; local $usedpri = 0; if (!@parts) { print "$text{'index_none'}

\n"; } else { print " ", " ", " ", " ", " ", " ", " ", "\n"; foreach $p (@parts) { print "\n"; if (!$ed) { $lb = $la = ""; } else { $lb = "{'index'}&part=$p->{'index'}\">"; $la = ""; $extended++ if ($p->{'extended'}); } print "\n"; $usedpri++ if ($p->{'number'} <= 4); print " ", "\n"; } print "
$text{'index_num'}$text{'index_type'}$text{'index_extent'}$text{'index_start'}$text{'index_end'}$text{'index_use'}$text{'index_free'}
",$lb,$p->{'number'},$la,"",$lb,$p->{'extended'} ? $text{'extended'} : &tag_name($p->{'type'}), $la," \n"; printf "", $extwidth*($p->{'start'} - 1) / $d->{'cylinders'}; printf "", $p->{'extended'} ? "ext" : "use", $extwidth*($p->{'end'} - $p->{'start'}) / $d->{'cylinders'}; printf "", $extwidth*($d->{'cylinders'} - ($p->{'end'} - 1)) / $d->{'cylinders'}; print " $p->{'start'}$p->{'end'} \n"; @stat = &device_status($p->{'device'}); if ($stat[1] eq 'raid') { print "$stat[0]\n"; } elsif ($stat[1] eq 'lvm') { if (&foreign_available("lvm")) { print "VG $stat[0]\n"; } else { print "VG $stat[0]\n"; } } elsif ($stat[0] && !&foreign_available("mount")) { print "$stat[0]\n"; } elsif ($stat[0] && $stat[3] == -1) { print "$stat[0]\n"; } elsif ($stat[0]) { print "$stat[0]\n"; } print " \n"; if (!$p->{'extended'} && $stat[2] && &indexof($p->{'type'}, @space_type) >= 0 && (@space = &disk_space($p->{'device'}, $stat[0])) && $space[0]) { printf "%d %%\n", 100 * $space[1] / $space[0]; } print "
\n"; } # Show links for adding partitions @edlinks = ( ); if ($usedpri != 4 && $ed) { push(@edlinks, "{'index'}&new=1\">". $text{'index_addpri'}.""); } if ($extended && $ed) { push(@edlinks, "{'index'}&new=2\">". $text{'index_addlog'}.""); } elsif ($usedpri != 4 && $ed) { push(@edlinks, "{'index'}&new=3\">". $text{'index_addext'}.""); } print &ui_links_row(\@edlinks); print "

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