[gparted] Warn when an LVM2 PV is a member of a damaged VG (#160878)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Warn when an LVM2 PV is a member of a damaged VG (#160878)
- Date: Sun, 12 Feb 2012 18:25:45 +0000 (UTC)
commit ea1c0c023e4a9c10605a74c7e756453c0e2e16fd
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Sun Feb 12 14:44:50 2012 +0000
Warn when an LVM2 PV is a member of a damaged VG (#160878)
Generate a warning for each LVM2 Physical Volume which is a member of a
Volume Group which has other members missing.
Bug #160787 - lvm support
include/LVM2_PV_Info.h | 2 +-
src/LVM2_PV_Info.cc | 27 ++++++++++++++++++++++++---
src/lvm2_pv.cc | 2 +-
3 files changed, 26 insertions(+), 5 deletions(-)
---
diff --git a/include/LVM2_PV_Info.h b/include/LVM2_PV_Info.h
index f3edb23..aa89b8c 100644
--- a/include/LVM2_PV_Info.h
+++ b/include/LVM2_PV_Info.h
@@ -42,7 +42,7 @@ public:
Byte_Value get_free_bytes( const Glib::ustring & path ) ;
bool has_active_lvs( const Glib::ustring & path ) ;
bool is_vg_exported( const Glib::ustring & vgname ) ;
- std::vector<Glib::ustring> get_error_messages() ;
+ std::vector<Glib::ustring> get_error_messages( const Glib::ustring & path ) ;
private:
void initialize_if_required() ;
void set_command_found() ;
diff --git a/src/LVM2_PV_Info.cc b/src/LVM2_PV_Info.cc
index a882fb5..76ef257 100644
--- a/src/LVM2_PV_Info.cc
+++ b/src/LVM2_PV_Info.cc
@@ -50,7 +50,8 @@ enum PV_ATTRIBUTE
// "/dev/sda13,830472192,GParted_VG3,wz--n-,,",
// "/dev/sda14,1828716544,GParted-VG4,wzx-n-,lvol0,-wi---",
// "/dev/sda14,1828716544,GParted-VG4,wzx-n-,,"]
-// error_messages - String vector storing error messsages.
+// error_messages - String vector storing whole cache error
+// messsages.
//Initialize static data elements
@@ -157,10 +158,30 @@ bool LVM2_PV_Info::is_vg_exported( const Glib::ustring & vgname )
return false ;
}
-std::vector<Glib::ustring> LVM2_PV_Info::get_error_messages()
+std::vector<Glib::ustring> LVM2_PV_Info::get_error_messages( const Glib::ustring & path )
{
initialize_if_required() ;
- return error_messages ;
+ if ( ! error_messages .empty() )
+ //Return whole cache error messages as first choice
+ return error_messages ;
+
+ std::vector<Glib::ustring> partition_specific_messages ;
+ partition_specific_messages .clear() ;
+ Glib::ustring temp ;
+
+ //Check for partition specific message: partial VG
+ Glib::ustring vg_bits = get_pv_attr_by_path( path, PVATTR_VG_BITS ) ;
+ //4rd "bit" is partial flag. E.g.
+ // "wz--n-" all PVs exist, "wz-pn-" one or move PVs missing.
+ // Treat any non-hyphen character as damaged.
+ if ( vg_bits .length() >= 4 && vg_bits [3] != '-' )
+ {
+ temp = _("One or more Physical Volumes belonging to the Volume Group is missing.") ;
+ temp += "\n" ;
+ partition_specific_messages .push_back ( temp ) ;
+ }
+
+ return partition_specific_messages ;
}
//Private methods
diff --git a/src/lvm2_pv.cc b/src/lvm2_pv.cc
index f168497..d085a8e 100644
--- a/src/lvm2_pv.cc
+++ b/src/lvm2_pv.cc
@@ -43,7 +43,7 @@ void lvm2_pv::set_used_sectors( Partition & partition )
if ( free_bytes >= 0 )
partition .Set_Unused( Utils::round( double(free_bytes) / double(partition .sector_size) ) ) ;
- std::vector<Glib::ustring> error_messages = lvm2_pv_info .get_error_messages() ;
+ std::vector<Glib::ustring> error_messages = lvm2_pv_info .get_error_messages( partition .get_path() ) ;
if ( ! error_messages .empty() )
{
for ( unsigned int i = 0 ; i < error_messages .size() ; i ++ )
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]