gparted r1000 - in trunk: . include src



Author: gedakc
Date: Sun Dec  7 18:43:35 2008
New Revision: 1000
URL: http://svn.gnome.org/viewvc/gparted?rev=1000&view=rev

Log:
Added lvm2 physical volume detection

Modified:
   trunk/ChangeLog
   trunk/include/Utils.h
   trunk/src/DialogFeatures.cc
   trunk/src/Dialog_Partition_New.cc
   trunk/src/GParted_Core.cc
   trunk/src/Utils.cc
   trunk/src/Win_GParted.cc

Modified: trunk/include/Utils.h
==============================================================================
--- trunk/include/Utils.h	(original)
+++ trunk/include/Utils.h	Sun Dec  7 18:43:35 2008
@@ -65,7 +65,9 @@
 	FS_UFS		= 16,
 
 	FS_USED		= 17,
-	FS_UNUSED	= 18
+	FS_UNUSED	= 18,
+
+	FS_LVM2		= 19   
 } ;
 
 enum SIZE_UNIT

Modified: trunk/src/DialogFeatures.cc
==============================================================================
--- trunk/src/DialogFeatures.cc	(original)
+++ trunk/src/DialogFeatures.cc	Sun Dec  7 18:43:35 2008
@@ -100,9 +100,16 @@
 void DialogFeatures::load_filesystems( const std::vector<FS> & FILESYSTEMS )
 {
 	liststore_filesystems ->clear() ;
-	
-	for ( unsigned short t = 0; t < FILESYSTEMS .size() -1 ; t++ )
+
+	//fill the features chart with valid file systems 
+	for ( unsigned short t = 0; t < FILESYSTEMS .size() ; t++ )
+	{
+		//Skip lvm2 and unknown because these are not file systems
+		if( FILESYSTEMS[ t ] .filesystem == GParted::FS_LVM2 ||
+			FILESYSTEMS[ t ] .filesystem == GParted::FS_UNKNOWN )
+			continue ;
 		show_filesystem( FILESYSTEMS[ t ] ) ;
+	}
 }
 		
 void DialogFeatures::show_filesystem( const FS & fs )

Modified: trunk/src/Dialog_Partition_New.cc
==============================================================================
--- trunk/src/Dialog_Partition_New.cc	(original)
+++ trunk/src/Dialog_Partition_New.cc	Sun Dec  7 18:43:35 2008
@@ -41,13 +41,29 @@
 	this ->new_count = new_count;
 	this ->selected_partition = partition;
 	this ->cylinder_size = cylinder_size ;
+
+	//copy GParted FILESYSTEMS
 	this ->FILESYSTEMS = FILESYSTEMS ;
-	this ->FILESYSTEMS .back() .filesystem = GParted::FS_UNFORMATTED ;
-	this ->FILESYSTEMS .back() .create = GParted::FS::LIBPARTED ;
-		
-	FS fs_tmp ;
-	fs_tmp .filesystem = GParted::FS_EXTENDED ;
-	this ->FILESYSTEMS .push_back( fs_tmp ) ;
+
+	//remove all non-valid file systems
+	for ( unsigned int t = this ->FILESYSTEMS .size( ) ; t > 0 ; t-- )
+	{
+		if ( this ->FILESYSTEMS[ t ] .filesystem == GParted::FS_UNKNOWN ||
+			 this ->FILESYSTEMS[ t ] .filesystem == GParted::FS_LVM2 )
+			this ->FILESYSTEMS .erase( this->FILESYSTEMS .begin() + t ) ;
+	}
+
+	FS *fs_tmp ;
+	//add FS_UNFORMATTED
+	fs_tmp = new( FS ) ;
+	fs_tmp ->filesystem = GParted::FS_UNFORMATTED ;
+	fs_tmp ->create = GParted::FS::LIBPARTED ;
+	this ->FILESYSTEMS .push_back( * fs_tmp ) ;
+
+	//add FS_EXTENDED
+	fs_tmp = new( FS ) ;
+	fs_tmp ->filesystem = GParted::FS_EXTENDED ;
+	this ->FILESYSTEMS .push_back( * fs_tmp ) ;
 	
 	//add table with selection menu's...
 	table_create .set_border_width( 10 ) ;
@@ -269,13 +285,16 @@
 void Dialog_Partition_New::Build_Filesystems_Menu( bool only_unformatted ) 
 {
 	//fill the file system menu with the file systems (except for extended) 
-	for ( unsigned int t = 0 ; t < FILESYSTEMS .size( ) -1 ; t++ ) 
+	for ( unsigned int t = 0 ; t < FILESYSTEMS .size( ) ; t++ ) 
 	{
+		//skip extended (lvm2 and unknown removed in Set_Data())
+		if( FILESYSTEMS[ t ] .filesystem == GParted::FS_EXTENDED )
+			continue ;
 		menu_filesystem .items() .push_back( 
 			Gtk::Menu_Helpers::MenuElem( Utils::get_filesystem_string( FILESYSTEMS[ t ] .filesystem ) ) ) ;
-		menu_filesystem .items()[ t ] .set_sensitive(
+		menu_filesystem .items() .back() .set_sensitive(
 			! only_unformatted && FILESYSTEMS[ t ] .create &&
-			this ->selected_partition .get_length() >= FILESYSTEMS[ t ] .MIN ) ;	
+			this ->selected_partition .get_length() >= FILESYSTEMS[ t ] .MIN ) ;
 	}
 	
 	//unformatted is always available

Modified: trunk/src/GParted_Core.cc
==============================================================================
--- trunk/src/GParted_Core.cc	(original)
+++ trunk/src/GParted_Core.cc	Sun Dec  7 18:43:35 2008
@@ -105,7 +105,7 @@
 	
 	linux_swap fs_linux_swap;
 	FILESYSTEMS .push_back( fs_linux_swap .get_filesystem_support() ) ;
-	
+
 	ntfs fs_ntfs;
 	FILESYSTEMS .push_back( fs_ntfs .get_filesystem_support() ) ;
 	
@@ -120,12 +120,19 @@
 
 	xfs fs_xfs;
 	FILESYSTEMS .push_back( fs_xfs .get_filesystem_support() ) ;
-	
+
+	FS *fs ;
+	//lvm2 physical volume -- not a file system
+	fs = new( FS ) ;
+	fs ->filesystem = GParted::FS_LVM2 ;
+	FILESYSTEMS .push_back( * fs ) ;
+
 	//unknown file system (default when no match is found)
-	FS fs ; fs .filesystem = GParted::FS_UNKNOWN ;
-	FILESYSTEMS .push_back( fs ) ;
+	fs = new( FS ) ;
+	fs ->filesystem = GParted::FS_UNKNOWN ;
+	FILESYSTEMS .push_back( * fs ) ;
 }
-	
+
 void GParted_Core::set_user_devices( const std::vector<Glib::ustring> & user_devices ) 
 {
 	this ->device_paths = user_devices ;
@@ -757,6 +764,7 @@
 	
 	
 	//other file systems libparted couldn't detect (i've send patches for these file systems to the parted guys)
+	// - no patches sent to parted for lvm2
 	char buf[512] ;
 
 	ped_device_open( lp_device );
@@ -767,7 +775,27 @@
 	
 	if ( Glib::ustring( buf ) == "ReIsEr4" )
 		return GParted::FS_REISER4 ;		
-		
+
+	//lvm2
+	//NOTE: lvm2 is not a file system but we do wish to recognize the Physical Volume
+	char magic1[16] ;
+	char magic2[16] ;
+
+	ped_device_open( lp_device );
+	ped_geometry_read( & lp_partition ->geom, buf, 1, 1 ) ;
+	strncpy(magic1, buf+0, 8) ;  magic1[8] = '\0' ; //set and terminate string
+	strncpy(magic2, buf+24, 4) ; magic2[4] = '\0' ; //set and terminate string
+	ped_device_close( lp_device );
+
+	if (    Glib::ustring( magic1 ) == "LABELONE"
+		 && Glib::ustring( magic2 ) == "LVM2" )
+	{
+		temp = _( "Logical Volume Management is not yet supported." ) ;
+		temp += "\n" ;
+		partition_temp .messages .push_back( temp ) ;
+		return GParted::FS_LVM2 ;
+	}
+
 	//no file system found....
 	temp = _( "Unable to detect file system! Possible reasons are:" ) ;
 	temp += "\n-"; 
@@ -856,7 +884,8 @@
 	{
 		if ( ( partitions[ t ] .type == GParted::TYPE_PRIMARY ||
 		       partitions[ t ] .type == GParted::TYPE_LOGICAL ) &&
-		     partitions[ t ] .filesystem != GParted::FS_LINUX_SWAP )
+		     partitions[ t ] .filesystem != GParted::FS_LINUX_SWAP &&
+		     partitions[ t ] .filesystem != GParted::FS_LVM2 )
 		{
 			if ( partitions[ t ] .busy )
 			{
@@ -896,6 +925,7 @@
 	for ( unsigned int t = 0 ; t < partitions .size() ; t++ )
 	{
 		if ( partitions[ t ] .filesystem != GParted::FS_LINUX_SWAP &&
+		     partitions[ t ] .filesystem != GParted::FS_LVM2 &&
 		     partitions[ t ] .filesystem != GParted::FS_UNKNOWN )
 		{
 			if ( partitions[ t ] .type == GParted::TYPE_PRIMARY ||

Modified: trunk/src/Utils.cc
==============================================================================
--- trunk/src/Utils.cc	(original)
+++ trunk/src/Utils.cc	Sun Dec  7 18:43:35 2008
@@ -67,27 +67,28 @@
 { 
 	switch( filesystem )
 	{
-		case FS_UNALLOCATED	: return "#A9A9A9" ;
-		case FS_UNKNOWN		: return "#000000" ;
-		case FS_UNFORMATTED	: return "#000000" ;
-		case FS_EXTENDED	: return "#7DFCFE" ;
-		case FS_EXT2		: return "#9DB8D2" ;
-		case FS_EXT3		: return "#7590AE" ;
-		case FS_LINUX_SWAP	: return "#C1665A" ;
-		case FS_FAT16		: return "#00FF00" ;
-		case FS_FAT32		: return "#18D918" ;
-		case FS_NTFS		: return "#42E5AC" ;
-		case FS_REISERFS	: return "#ADA7C8" ;
-		case FS_REISER4		: return "#887FA3" ;
-		case FS_XFS		: return "#EED680" ;
-		case FS_JFS		: return "#E0C39E" ;
-		case FS_HFS		: return "#E0B6AF" ;
-		case FS_HFSPLUS		: return "#C0A39E" ;
-		case FS_UFS		: return "#D1940C" ;
-		case FS_USED		: return "#F8F8BA" ;
-		case FS_UNUSED		: return "#FFFFFF" ;
+		case FS_UNALLOCATED	: return "#A9A9A9" ;	// ~ medium grey
+		case FS_UNKNOWN		: return "#000000" ;	//black
+		case FS_UNFORMATTED	: return "#000000" ;	//black
+		case FS_EXTENDED	: return "#7DFCFE" ;	// ~ light blue
+		case FS_EXT2		: return "#9DB8D2" ;	//blue hilight
+		case FS_EXT3		: return "#7590AE" ;	//blue medium
+		case FS_LINUX_SWAP	: return "#C1665A" ;	//red medium
+		case FS_FAT16		: return "#00FF00" ;	//green
+		case FS_FAT32		: return "#18D918" ;	// ~ medium green
+		case FS_NTFS		: return "#42E5AC" ;	// ~ light turquoise
+		case FS_REISERFS	: return "#ADA7C8" ;	//purple hilight
+		case FS_REISER4		: return "#887FA3" ;	//purple medium
+		case FS_XFS			: return "#EED680" ;	//accent yellow
+		case FS_JFS			: return "#E0C39E" ;	//face skin medium
+		case FS_HFS			: return "#E0B6AF" ;	//red hilight
+		case FS_HFSPLUS		: return "#C0A39E" ;	// ~ serene red
+		case FS_UFS			: return "#D1940C" ;	//accent yellow dark
+		case FS_USED		: return "#F8F8BA" ;	// ~ light tan yellow
+		case FS_UNUSED		: return "#FFFFFF" ;	//white
+		case FS_LVM2		: return "#CC9966" ;	// ~ medium brown
 
-		default			: return "#000000" ;
+		default				: return "#000000" ;
 	}
 }
 
@@ -130,6 +131,7 @@
 		case FS_UFS		: return "ufs" ;
 		case FS_USED		: return _("used") ;
 		case FS_UNUSED		: return _("unused") ;
+		case FS_LVM2		: return "lvm2" ;
 					  
 		default			: return "" ;
 	}

Modified: trunk/src/Win_GParted.cc
==============================================================================
--- trunk/src/Win_GParted.cc	(original)
+++ trunk/src/Win_GParted.cc	Sun Dec  7 18:43:35 2008
@@ -380,8 +380,13 @@
 {
 	menu = manage( new Gtk::Menu() ) ;
 
-	for ( unsigned int t =0; t < gparted_core .get_filesystems() .size() -1 ; t++ )
+	for ( unsigned int t =0; t < gparted_core .get_filesystems() .size() ; t++ )
 	{
+		//Skip lvm2 and unknown because these are not file systems
+		if( gparted_core .get_filesystems()[ t ] .filesystem == GParted::FS_LVM2 ||
+			gparted_core .get_filesystems()[ t ] .filesystem == GParted::FS_UNKNOWN )
+			continue ;
+
 		hbox = manage( new Gtk::HBox() );
 			
 		//the colored square



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