[gparted] Display LVM2 VGNAME as the PV's mount point (#160787)



commit 8083f11d84dbd4f186271a3cdbf5170db259f8b8
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Fri Dec 16 21:32:54 2011 +0000

    Display LVM2 VGNAME as the PV's mount point (#160787)
    
    As the Mount Point column is being borrowed to display the PV's VGNAME,
    also suppress generation of the "Mount on" submenu for LVM2 PVs.
    
    Bug #160787 - lvm support

 include/Partition.h |    1 +
 src/GParted_Core.cc |    7 +++++++
 src/Partition.cc    |    8 ++++++++
 src/Win_GParted.cc  |    6 +++++-
 4 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/include/Partition.h b/include/Partition.h
index c7eaed3..45f6432 100644
--- a/include/Partition.h
+++ b/include/Partition.h
@@ -93,6 +93,7 @@ public:
 	Sector get_sector_length() const ; 
 	Glib::ustring get_path() const ;
 	std::vector<Glib::ustring> get_paths() const ;
+	void add_mountpoint( const Glib::ustring & mountpoint, bool clear_mountpoints = false ) ;
 	void add_mountpoints( const std::vector<Glib::ustring> & mountpoints, bool clear_mountpoints = false ) ;
 	Glib::ustring get_mountpoint() const ; 
 	void clear_mountpoints() ;
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 8b3ebfe..e870210 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -1346,6 +1346,7 @@ void GParted_Core::set_mountpoints( std::vector<Partition> & partitions )
 #ifndef USE_LIBPARTED_DMRAID
 	DMRaid dmraid ;	//Use cache of dmraid device information
 #endif
+	LVM2_PV_Info lvm2_pv_info ;
 	for ( unsigned int t = 0 ; t < partitions .size() ; t++ )
 	{
 		if ( ( partitions[ t ] .type == GParted::TYPE_PRIMARY ||
@@ -1409,6 +1410,12 @@ void GParted_Core::set_mountpoints( std::vector<Partition> & partitions )
 		}
 		else if ( partitions[ t ] .type == GParted::TYPE_EXTENDED )
 			set_mountpoints( partitions[ t ] .logicals ) ;
+		else if ( partitions[ t ] .filesystem == GParted::FS_LVM2_PV )
+		{
+			Glib::ustring vgname = lvm2_pv_info. get_vg_name( partitions[t].get_path() ) ;
+			if ( ! vgname .empty() )
+				partitions[ t ] .add_mountpoint( vgname ) ;
+		}
 	}
 }
 	
diff --git a/src/Partition.cc b/src/Partition.cc
index 952b9b6..452e487 100644
--- a/src/Partition.cc
+++ b/src/Partition.cc
@@ -207,6 +207,14 @@ void Partition::sort_paths_and_remove_duplicates()
 	std::sort( paths .begin(), paths .end(), compare_paths ) ;
 }
 
+void Partition::add_mountpoint( const Glib::ustring & mountpoint, bool clear_mountpoints )
+{
+	if ( clear_mountpoints )
+		this ->mountpoints .clear() ;
+
+	this ->mountpoints .push_back( mountpoint ) ;
+}
+
 void Partition::add_mountpoints( const std::vector<Glib::ustring> & mountpoints, bool clear_mountpoints ) 
 {
 	if ( clear_mountpoints )
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index c4cc096..eb621bc 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -1043,7 +1043,11 @@ void Win_GParted::set_valid_operations()
 		if ( selected_partition .status == GParted::STAT_REAL && fs .write_uuid )
 			allow_change_uuid( true ) ;
 
-		if ( selected_partition .get_mountpoints() .size() )
+		//Generate Mount on submenu, except for LVM2 PVs
+		//  borrowing mount point to display the VGNAME
+		if (   selected_partition .filesystem != GParted::FS_LVM2_PV
+		    && selected_partition .get_mountpoints() .size()
+		   )
 		{
 			allow_toggle_swap_mount_state( true ) ;
 			



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]