#!/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'}); if ($in{'lv'}) { ($lv) = grep { $_->{'name'} eq $in{'lv'} } @lvs; &header($lv->{'is_snap'} ? $text{'lv_edit_snap'} : $text{'lv_edit'}, ""); @stat = &device_status($lv->{'device'}); } else { &header($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 "
",&text('lv_vg', $vg->{'name'}), "
\n"; print "
\n"; 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'}) { print "\n"; } print "
$text{'lv_name'}$lv->{'name'}$text{'lv_size'}$lv->{'size'} kB
$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', ""), "
\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 buttons for creating filesystems print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print "$text{'lv_mkfsdesc'}
\n"; } print "
\n"; &footer("", $text{'index_return'});