\n";
print "\n";
print "\n";
print "\n";
@plist = @{$dinfo->{'parts'}};
if ($in{'new'}) {
if ($in{'new'} == 1 || $in{'new'} == 3) {
# Adding a new primary or extended partition
$np = 1;
for($i=0; $i<@plist; $i++) {
if ($plist[$i]->{'number'} == $np) { $np++; }
push(@start, $plist[$i]->{'start'});
push(@end, $plist[$i]->{'end'});
}
$min = 1;
$max = $dinfo->{'cylinders'};
}
else {
# Adding a new logical partition (inside the extended partition)
$np = 5;
for($i=0; $i<@plist; $i++) {
if ($plist[$i]->{'number'} == $np) { $np++; }
if ($plist[$i]->{'extended'}) {
$min = $plist[$i]->{'start'};
$max = $plist[$i]->{'end'};
}
else {
push(@start, $plist[$i]->{'start'});
push(@end, $plist[$i]->{'end'});
}
}
}
print "\n";
print "\n";
print "\n";
# find a gap in the partition map
for($start=$min; $start<=$max; $start++) {
$found = 1;
for($i=0; $i<@start; $i++) {
if ($start >= $start[$i] && $start <= $end[$i]) {
$found = 0;
last;
}
}
if ($found) { last; }
}
if ($found) {
# starting place found.. find the end
$found = 0;
for($end=$start; $end<=$max; $end++) {
for($i=0; $i<@start; $i++) {
if ($end >= $start[$i] && $end <= $end[$i]) {
$found = 1;
last;
}
}
if ($found) { last; }
}
$end--;
}
else {
# no place for new partition!
$start = $end = 0;
}
}
else {
# Just editing an existing partition
$pinfo = $plist[$in{'part'}];
$np = $pinfo->{'number'};
}
print "\n";
print " | $text{'edit_location'} | \n";
print "",$dinfo->{'device'} =~ /^\/dev\/(s|h)d([a-z])$/ ?
&text('select_part', $1 eq 's' ? 'SCSI' : 'IDE', uc($2), $np) :
$dinfo->{'device'} =~ /rd\/c(\d+)d(\d+)$/ ?
&text('select_mpart', "$1", "$2", $np) :
$dinfo->{'device'} =~ /ida\/c(\d+)d(\d+)$/ ?
&text('select_cpart', "$1", "$2", $np) :
$dinfo->{'device'} =~ /scsi\/host(\d+)\/bus(\d+)\/target(\d+)\/lun(\d+)\/disc/ ?
&text('select_spart', "$1", "$2", "$3", "$4", $np) :
$dinfo->{'device'} =~ /ide\/host(\d+)\/bus(\d+)\/target(\d+)\/lun(\d+)\/disc/ ?
&text('select_snewide', "$1", "$2", "$3", "$4", $np) :
$dinfo->{'device'}," | \n";
print "$text{'edit_device'} | \n";
$dev = $dinfo->{'prefix'}.$np;
print "$dev | \n";
print " | $text{'edit_type'} | \n";
if ($pinfo->{'extended'} || $in{'new'} == 3) {
print "$text{'extended'} | \n";
}
else {
print " | \n";
}
print "$text{'edit_extent'} | \n";
if ($in{'new'}) {
print " - \n";
print "\n";
}
else {
print " | $pinfo->{'start'} - $pinfo->{'end'}\n";
}
print $text{'edit_of'}," $dinfo->{'cylinders'} | \n";
print " | $text{'edit_status'} | \n";
if ($pinfo->{'extended'}) {
foreach $p (@plist) {
$ecount++ if ($p->{'number'} > 4);
}
if ($ecount == 1) {
print "", $text{'edit_cont1'}, " | \n";
}
else {
if ($ecount > 4) {
print "", &text('edit_cont5', $ecount), " | \n";
}
else {
print "", &text('edit_cont234', $ecount), " | \n";
}
}
}
else {
@stat = &device_status($dev);
if ($in{'new'}) { print "$text{'edit_notexist'} | \n"; }
elsif (@stat) {
$msg = $stat[2] ? 'edit_mount' : 'edit_umount';
$msg .= 'vm' if ($stat[1] eq 'swap');
$msg .= 'raid' if ($stat[1] eq 'raid');
$msg .= 'lvm' if ($stat[1] eq 'lvm');
print "",&text($msg, "$stat[0]",
"$stat[1]")," | \n";
}
else { print "$text{'edit_notused'} | \n"; }
}
print "$text{'edit_size'} | \n";
if ($in{'new'}) {
print "$text{'edit_notexist'} | \n";
}
elsif ($dinfo->{'cylsize'}) {
print "",&nice_size(($pinfo->{'end'} - $pinfo->{'start'} + 1) * $dinfo->{'cylsize'})," | \n";
}
else {
print "",&text('edit_blocks', $pinfo->{'blocks'})," | \n";
}
# Show field for editing filesystem label
print "\n";
if (($has_e2label || $has_xfs_db) && $pinfo->{'type'} eq '83' && !$in{'new'}) {
local $label = $in{'new'} ? undef : &get_label($pinfo->{'device'});
print "| $text{'edit_label'} | \n";
if (@stat) {
print $label ? "$label" : $text{'edit_none'};
}
else {
print "\n";
}
print " | \n";
}
# Show current UUID
if ($has_volid && !$in{'new'}) {
local $volid = &get_volid($pinfo->{'device'});
print "$text{'edit_volid'} | \n";
print "$volid | \n";
}
print " \n";
print " |