#!/usr/local/bin/perl # Display a form for editing an existing logical volume require './lvm-lib.pl'; &foreign_require("fdisk", "fdisk-lib.pl"); &ReadParse(); ($vg) = grep { $_->{'name'} eq $in{'vg'} } &list_volume_groups(); @lvs = &list_logical_volumes($in{'vg'}); $vgdesc = &text('lv_vg', $vg->{'name'}); if ($in{'lv'}) { ($lv) = grep { $_->{'name'} eq $in{'lv'} } @lvs; &ui_print_header($vgdesc, $lv->{'is_snap'} ? $text{'lv_edit_snap'} : $text{'lv_edit'}, ""); @stat = &device_status($lv->{'device'}); } else { &ui_print_header($vgdesc, $in{'snap'} ? $text{'lv_create_snap'} : $text{'lv_create'},""); $lv = { 'perm' => 'rw', 'alloc' => 'n', 'is_snap' => $in{'snap'}, 'size' => ($vg->{'pe_total'} - $vg->{'pe_alloc'})* $vg->{'pe_size'} }; } print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
$text{'lv_header'}
\n"; if ($stat[2]) { print "\n"; print "\n"; print "\n"; print "\n"; } else { print "\n"; print "\n"; print "\n"; print "\n"; } print "\n"; print "\n"; print "\n"; print "\n"; if ($in{'lv'}) { print "\n"; print "\n"; print "\n"; } if ($lv->{'is_snap'}) { print "\n"; } elsif ($stat[2]) { # Display current permissons and allocation method print "\n"; print "\n"; print "\n"; print "\n"; } else { # Allow editing of permissons and allocation method print "\n"; printf "\n", $lv->{'perm'} eq 'r' ? 'checked' : '', $text{'lv_permr'}; print "\n"; printf "\n", $lv->{'alloc'} eq 'n' ? 'checked' : '', $text{'lv_allocn'}; } if (!$in{'lv'} && !$lv->{'is_snap'}) { # Allow selection of striping print "\n"; } elsif (!$lv->{'is_snap'}) { # Show current striping print "\n"; } # Show free disk space if (@stat && $stat[2]) { ($total, $free) = &mount::disk_space($stat[1], $stat[0]); print "\n"; print "\n"; } # Show extents on PVs if ($in{'lv'}) { @pvinfo = &get_logical_volume_usage($lv); if (@pvinfo) { @pvs = &list_physical_volumes($in{'vg'}); print "\n"; } } print "
$text{'lv_name'}$lv->{'name'}$text{'lv_size'}",&nice_size($lv->{'size'}*1024),"
$text{'lv_name'}$text{'lv_size'} kB
$text{'lv_petotal'}",&text('lv_petotals', $vg->{'pe_alloc'}, $vg->{'pe_total'}), "$text{'lv_pesize'}$vg->{'pe_size'} kB
$text{'lv_device'}$lv->{'device'}$text{'lv_status'} \n"; if (!@stat) { print $text{'lv_notused'}; } else { $msg = &device_message(@stat); print $msg; } print "
$text{'lv_snapof'} \n"; if ($in{'lv'}) { # Show which LV this is a snapshot of local @snapof = grep { $_->{'size'} == $lv->{'size'} && $_->{'has_snap'} } @lvs; if (@snapof == 1) { print "$snapof[0]->{'name'}"; } else { print "$text{'lv_nosnap'}"; } } else { # Allow selection of snapshot source print "\n"; } print "
$text{'lv_perm'}",$text{"lv_perm".$lv->{'perm'}},"$text{'lv_alloc'}",$text{"lv_alloc".$lv->{'alloc'}},"
$text{'lv_perm'} %s\n", $lv->{'perm'} eq 'rw' ? 'checked' : '', $text{'lv_permrw'}; printf " %s$text{'lv_alloc'} %s\n", $lv->{'alloc'} eq 'y' ? 'checked' : '', $text{'lv_allocy'}; printf " %s
$text{'lv_stripe'} \n"; printf " %s\n", $text{'lv_nostripe'}; print "\n"; print &text('lv_stripes', ""), "
$text{'lv_stripe'} \n"; if ($lv->{'stripes'} > 1) { print &text('lv_stripes', $lv->{'stripes'}); } else { print $text{'lv_nostripe'}; } print "
$text{'lv_freedisk'} \n"; print &nice_size($free*1024),"$text{'lv_free'} \n"; printf "%d %%\n", $total ? 100 * $free / $total : 0; print "
$text{'lv_pvs'} \n"; foreach $p (@pvinfo) { print " , \n" if ($p ne $pvinfo[0]); ($pv) = grep { $_->{'name'} eq $p->[0] } @pvs; print "{'name'}'>$pv->{'name'} "; print &nice_size($p->[1]*$pv->{'pe_size'}*1024),"\n"; } print "
\n"; print "\n"; if ($stat[2]) { print "\n"; } elsif ($in{'lv'}) { print "\n"; print "\n"; } else { print "\n"; } print "
$text{'lv_cannot'}
\n"; if ($in{'lv'} && !$stat[2] && !$lv->{'is_snap'}) { # Show button for creating filesystems print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; if (!@stat) { # Show button for mounting $type = $config{'lasttype_'.$lv->{'device'}} || "ext2"; print "\n"; print "\n"; print "{'device'}>\n"; print "\n"; print "\n"; print "\n"; } print "
\n"; print "$text{'lv_mkfsdesc'}
\n"; print "\n"; print "$text{'lv_mountmsg'}
\n"; } &ui_print_footer("", $text{'index_return'});