From 4d05e35e18898aff5ebbb06c5a9bf391380deb24 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Tue, 9 Aug 2011 00:06:36 -0700 Subject: [PATCH] Fail if LV, PV or VG no longer exists --- lvm/edit_lv.cgi | 2 ++ lvm/edit_pv.cgi | 2 ++ lvm/edit_vg.cgi | 1 + lvm/lang/en | 3 +++ lvm/save_lv.cgi | 11 ++++++++--- lvm/save_pv.cgi | 8 ++++++-- lvm/save_vg.cgi | 6 ++++-- 7 files changed, 26 insertions(+), 7 deletions(-) diff --git a/lvm/edit_lv.cgi b/lvm/edit_lv.cgi index 3c8d6a875..1f21a985c 100755 --- a/lvm/edit_lv.cgi +++ b/lvm/edit_lv.cgi @@ -4,11 +4,13 @@ require './lvm-lib.pl'; &ReadParse(); ($vg) = grep { $_->{'name'} eq $in{'vg'} } &list_volume_groups(); +$vg || &error($text{'vg_egone'}); @lvs = &list_logical_volumes($in{'vg'}); $vgdesc = &text('lv_vg', $vg->{'name'}); if ($in{'lv'}) { ($lv) = grep { $_->{'name'} eq $in{'lv'} } @lvs; + $lv || &error($text{'lv_egone'}); &ui_print_header($vgdesc, $lv->{'is_snap'} ? $text{'lv_edit_snap'} : $text{'lv_edit'}, ""); @stat = &device_status($lv->{'device'}); diff --git a/lvm/edit_pv.cgi b/lvm/edit_pv.cgi index 45c73be2b..06d2d2b4a 100755 --- a/lvm/edit_pv.cgi +++ b/lvm/edit_pv.cgi @@ -5,11 +5,13 @@ require './lvm-lib.pl'; &ReadParse(); ($vg) = grep { $_->{'name'} eq $in{'vg'} } &list_volume_groups(); +$vg || &error($text{'vg_egone'}); $vgdesc = &text('pv_vg', $vg->{'name'}); if ($in{'pv'}) { @pvs = &list_physical_volumes($in{'vg'}); ($pv) = grep { $_->{'name'} eq $in{'pv'} } @pvs; + $pv || &error($text{'pv_egone'}); &ui_print_header($vgdesc, $text{'pv_edit'}, ""); } else { diff --git a/lvm/edit_vg.cgi b/lvm/edit_vg.cgi index 8d1397bf0..b8ce9aa1a 100755 --- a/lvm/edit_vg.cgi +++ b/lvm/edit_vg.cgi @@ -7,6 +7,7 @@ require './lvm-lib.pl'; if ($in{'vg'}) { ($vg) = grep { $_->{'name'} eq $in{'vg'} } &list_volume_groups(); + $vg || &error($text{'vg_egone'}); &ui_print_header(undef, $text{'vg_edit'}, ""); } else { diff --git a/lvm/lang/en b/lvm/lang/en index 1f070bc19..8082ab2b8 100644 --- a/lvm/lang/en +++ b/lvm/lang/en @@ -106,6 +106,7 @@ lv_free=Free percentage lv_freedisk=Free space lv_pvs=Physical volumes allocated lv_snapusage=Snapshot use percentage +lv_egone=Logical volume no longer exists! mkfs_title=Create Filesystem mkfs_desc=This form allows you to build a new $2 ($1) filesystem on logical volume $3. All existing data will be erased. @@ -151,6 +152,7 @@ pv_deleteok=Remove Volume pv_eother=Missing or invalid disk device pv_raid=RAID device $1 pv_lvs=Allocation by logical volumes +pv_egone=Physical volume no longer exists! vg_edit=Edit Volume Group vg_create=Create Volume Group @@ -169,6 +171,7 @@ vg_cannot=This volume group cannot be deleted because it still has $1 logical vo vg_deleteok=Delete Now vg_ename=Missing or invalid volume group name vg_epesize=Missing or invalid allocation block size +vg_egone=Volume group no longer exists! log_create_vg=Created volume group $1 log_modify_vg=Modified volume group $1 diff --git a/lvm/save_lv.cgi b/lvm/save_lv.cgi index 9cb3ee147..5ccb8f9ba 100755 --- a/lvm/save_lv.cgi +++ b/lvm/save_lv.cgi @@ -6,8 +6,13 @@ require './lvm-lib.pl'; &ReadParse(); ($vg) = grep { $_->{'name'} eq $in{'vg'} } &list_volume_groups(); -($lv) = grep { $_->{'name'} eq $in{'lv'} } &list_logical_volumes($in{'vg'}) - if ($in{'lv'}); +$vg || &error($text{'vg_egone'}); +if ($in{'lv'}) { + ($lv) = grep { $_->{'name'} eq $in{'lv'} } + &list_logical_volumes($in{'vg'}); + $lv || &error($text{'lv_egone'}); + $oldlv = { %$lv }; + } if ($in{'confirm'}) { # Delete the logical volume @@ -188,7 +193,7 @@ else { $lv->{'perm'} = $in{'perm'}; $lv->{'alloc'} = $in{'alloc'}; $lv->{'readahead'} = $in{'readahead'}; - $err = &change_logical_volume($lv); + $err = &change_logical_volume($lv, $oldlv); &error("
$err
") if ($err); } if ($lv->{'name'} ne $in{'name'}) { diff --git a/lvm/save_pv.cgi b/lvm/save_pv.cgi index c3733ab7a..879eb8c06 100755 --- a/lvm/save_pv.cgi +++ b/lvm/save_pv.cgi @@ -6,8 +6,12 @@ require './lvm-lib.pl'; &ReadParse(); ($vg) = grep { $_->{'name'} eq $in{'vg'} } &list_volume_groups(); -($pv) = grep { $_->{'name'} eq $in{'pv'} } &list_physical_volumes($in{'vg'}) - if ($in{'pv'}); +$vg || &error($text{'vg_egone'}); +if ($in{'pv'}) { + ($pv) = grep { $_->{'name'} eq $in{'pv'} } + &list_physical_volumes($in{'vg'}); + $pv || &error($text{'pv_egone'}); + } if ($in{'confirm'}) { # Delete the physical volume diff --git a/lvm/save_vg.cgi b/lvm/save_vg.cgi index 39a197da1..e7ec45bdf 100755 --- a/lvm/save_vg.cgi +++ b/lvm/save_vg.cgi @@ -5,8 +5,10 @@ require './lvm-lib.pl'; &ReadParse(); -($vg) = grep { $_->{'name'} eq $in{'vg'} } &list_volume_groups() - if ($in{'vg'}); +if ($in{'vg'}) { + ($vg) = grep { $_->{'name'} eq $in{'vg'} } &list_volume_groups(); + $vg || &error($text{'vg_egone'}); + } if ($in{'confirm'}) { # Delete the volume group