Fail if LV, PV or VG no longer exists
authorJamie Cameron <jcameron@webmin.com>
Tue, 9 Aug 2011 07:06:36 +0000 (00:06 -0700)
committerJamie Cameron <jcameron@webmin.com>
Tue, 9 Aug 2011 07:06:36 +0000 (00:06 -0700)
lvm/edit_lv.cgi
lvm/edit_pv.cgi
lvm/edit_vg.cgi
lvm/lang/en
lvm/save_lv.cgi
lvm/save_pv.cgi
lvm/save_vg.cgi

index 3c8d6a8..1f21a98 100755 (executable)
@@ -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'});
index 45c73be..06d2d2b 100755 (executable)
@@ -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 {
index 8d1397b..b8ce9aa 100755 (executable)
@@ -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 {
index 1f070bc..8082ab2 100644 (file)
@@ -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
index 9cb3ee1..5ccb8f9 100755 (executable)
@@ -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("<pre>$err</pre>") if ($err);
                        }
                if ($lv->{'name'} ne $in{'name'}) {
index c3733ab..879eb8c 100755 (executable)
@@ -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
index 39a197d..e7ec45b 100755 (executable)
@@ -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