[gparted] Add a partition warning for LVM2 PVs which can't be resized (#670171)



commit 60d772817706e305a3b6c97c6b08752228b6f906
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Sat Aug 25 22:25:23 2012 +0100

    Add a partition warning for LVM2 PVs which can't be resized (#670171)
    
    As LVM2 Physical Volumes can't be resized when they are members of
    exported Volume Groups add a warning message to explain this fact.
    Display the message as a partition specific warning and as additional
    text when growing the file system to fill the partition is skipped for
    the check operation and when pasting into an existing larger partition.
    
    Bug #670171 - Add LVM PV read-write support

 include/Utils.h     |    1 +
 src/GParted_Core.cc |   21 +++++++++++++++++----
 src/lvm2_pv.cc      |    6 ++++++
 3 files changed, 24 insertions(+), 4 deletions(-)
---
diff --git a/include/Utils.h b/include/Utils.h
index d91aae2..7cb98a5 100644
--- a/include/Utils.h
+++ b/include/Utils.h
@@ -100,6 +100,7 @@ enum CUSTOM_TEXT
 	CTEXT_ACTIVATE_FILESYSTEM,		// Activate text ('Mount', 'Swapon', VG 'Activate', ...)
 	CTEXT_DEACTIVATE_FILESYSTEM,		// Deactivate text ('Unmount', 'Swapoff', VG 'Deactivate', ...)
 	CTEXT_CHANGE_UUID_WARNING,		// Warning to print when changing UUIDs
+	CTEXT_RESIZE_DISALLOWED_WARNING		// File system resizing currently disallowed reason
 } ;
 
 //struct to store file system information
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index f076efd..dc54b9d 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -1588,6 +1588,14 @@ void GParted_Core::set_used_sectors( std::vector<Partition> & partitions )
 					}
 					partitions[ t ] .messages .push_back( temp ) ;
 				}
+
+				if ( filesystem_resize_disallowed( partitions[ t ] ) )
+				{
+					temp = get_filesystem_object( partitions[ t ] .filesystem )
+					       ->get_custom_text( CTEXT_RESIZE_DISALLOWED_WARNING ) ;
+					if ( ! temp .empty() )
+						partitions[ t ] .messages .push_back( temp ) ;
+				}
 			}
 			else if ( partitions[ t ] .type == GParted::TYPE_EXTENDED )
 				set_used_sectors( partitions[ t ] .logicals ) ;
@@ -2486,10 +2494,15 @@ bool GParted_Core::maximize_filesystem( const Partition & partition, OperationDe
 	}
 	else if ( filesystem_resize_disallowed( partition ) )
 	{
-
-		operationdetail .get_last_child() .add_child(
-			OperationDetail( _("growing the file system is currently disallowed"),
-			                 STATUS_NONE, FONT_ITALIC ) ) ;
+		Glib::ustring msg        = _("growing the file system is currently disallowed") ;
+		Glib::ustring custom_msg = get_filesystem_object( partition .filesystem )
+		                           ->get_custom_text( CTEXT_RESIZE_DISALLOWED_WARNING ) ;
+		if ( ! custom_msg .empty() )
+		{
+			msg += "\n" ;
+			msg += custom_msg ;
+		}
+		operationdetail .get_last_child() .add_child( OperationDetail( msg, STATUS_NONE, FONT_ITALIC ) ) ;
 		operationdetail .get_last_child() .set_status( STATUS_N_A ) ;
 		return true ;
 	}
diff --git a/src/lvm2_pv.cc b/src/lvm2_pv.cc
index c7cd1ee..4023aba 100644
--- a/src/lvm2_pv.cc
+++ b/src/lvm2_pv.cc
@@ -28,12 +28,18 @@ const Glib::ustring lvm2_pv::get_custom_text( CUSTOM_TEXT ttype, int index )
 	static const Glib::ustring activate_text = _( "Ac_tivate" ) ;
 	static const Glib::ustring deactivate_text = _( "Deac_tivate" ) ;
 
+	static const Glib::ustring resize_warning =
+		_( "The LVM2 Physical Volume can not currently be resized because it is a member of an exported "
+		   "Volume Group." ) ;
+
 	switch ( ttype )
 	{
 		case CTEXT_ACTIVATE_FILESYSTEM:
 			return index == 0 ? activate_text : "" ;
 		case CTEXT_DEACTIVATE_FILESYSTEM:
 			return index == 0 ? deactivate_text : "" ;
+		case CTEXT_RESIZE_DISALLOWED_WARNING:
+			return index == 0 ? resize_warning : "" ;
 		default:
 			return "" ;
 	}



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