[gparted/psusi/refactor: 4/7] Remove support for dmraid unaware libparted



commit aff86b9d7b87392aac71b9b4262b1bd52e48dc73
Author: Phillip Susi <psusi ubuntu com>
Date:   Tue Jan 15 20:38:09 2013 -0500

    Remove support for dmraid unaware libparted
    
    Two years ago configure option --enable-libparted-dmraid was added to
    disable gparted dmraid support when working with versions of libparted that
    already handled it properly.  This option has been removed, and support
    for buggy versions of libparted with it.

 NEWS                   |   11 +
 configure.in           |   21 --
 include/DMRaid.h       |   81 --------
 src/DMRaid.cc          |  512 ------------------------------------------------
 src/Dialog_Progress.cc |    3 -
 src/GParted_Core.cc    |  211 +-------------------
 src/Makefile.am        |    1 -
 7 files changed, 18 insertions(+), 822 deletions(-)
---
diff --git a/NEWS b/NEWS
index ad512c7..7061820 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,15 @@
 ============================
+GParted ??.??.??  (????-??-??)
+============================
+
+Release Notes
+-------------
+
+  Support for --enable-libparted-dmraid has been removed along with the
+  code for the old dmraid support.  Libparted dmraid support is now
+  required.
+
+============================
 GParted 0.14.1  (2012-12-12)
 ============================
 
diff --git a/configure.in b/configure.in
index 0455978..2a2fcbf 100644
--- a/configure.in
+++ b/configure.in
@@ -292,25 +292,6 @@ fi
 AM_CONDITIONAL([DISABLE_DOC], [test ${enable_doc} = no])
 
 
-dnl======================
-dnl check whether to use native libparted dmraid support
-dnl======================
-AC_ARG_ENABLE([libparted_dmraid],
-  [  --enable-libparted-dmraid   do use native libparted /dev/mapper dmraid support],,)
-if test "x${enable_libparted_dmraid}" = "x" ; then
-	enable_libparted_dmraid=no
-fi
-
-AC_MSG_CHECKING([whether native libparted /dev/mapper dmraid support should be used])
-if test ${enable_libparted_dmraid} = yes; then
-	AC_MSG_RESULT([yes])
-	dnl Set   #define USE_LIBPARTED_DMRAID 1   to indicate documentation not wanted
-	AC_DEFINE([USE_LIBPARTED_DMRAID], [1], [Define to 1 if --enable-libparted-dmraid specified])
-else
-	AC_MSG_RESULT([no])
-fi
-
-
 AC_CONFIG_FILES([
 Makefile
 compose/Makefile
@@ -336,8 +317,6 @@ echo "                         Installing into prefix  :  $prefix"
 echo ""
 echo "                           Build documentation?  :  $enable_doc"
 echo ""
-echo "           Use native libparted dmraid support?  :  $enable_libparted_dmraid"
-echo ""
 echo "       --- Features Based On Libparted Version ---"
 echo "      Need partition table re-read work around?  :  $need_pt_reread_work_around"
 echo "             Supports sector sizes > 512 bytes?  :  $support_sector_size_gt_512"
diff --git a/src/Dialog_Progress.cc b/src/Dialog_Progress.cc
index 2b4e02e..9ce9c89 100644
--- a/src/Dialog_Progress.cc
+++ b/src/Dialog_Progress.cc
@@ -358,9 +358,6 @@ void Dialog_Progress::on_save()
 			<< "</head>" << std::endl
 			<< "<body>" << std::endl
 			<< "<p>" << _("GParted") << " " << VERSION
-#ifdef USE_LIBPARTED_DMRAID
-			<< " --enable-libparted-dmraid"
-#endif
 			<< "</p>" << std::endl
 			<< "<p>" << _("Libparted") << " " << signal_get_libparted_version .emit() << "</p>" << std::endl ;
 
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 1f0bcc0..7bc6a89 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -18,7 +18,6 @@
  
 #include "../include/Win_GParted.h"
 #include "../include/GParted_Core.h"
-#include "../include/DMRaid.h"
 #include "../include/FS_Info.h"
 #include "../include/LVM2_PV_Info.h"
 #include "../include/OperationCopy.h"
@@ -142,7 +141,6 @@ void GParted_Core::set_devices( std::vector<Device> & devices )
 	Device temp_device ;
 	Proc_Partitions_Info pp_info( true ) ;  //Refresh cache of proc partition information
 	FS_Info fs_info( true ) ;  //Refresh cache of file system information
-	DMRaid dmraid( true ) ;    //Refresh cache of dmraid device information
 	LVM2_PV_Info lvm2_pv_info( true ) ;	//Refresh cache of LVM2 PV information
 	
 	init_maps() ;
@@ -168,20 +166,6 @@ void GParted_Core::set_devices( std::vector<Device> & devices )
 				set_thread_status_message( String::ucompose ( _("Scanning %1"), temp_devices[ k ] ) ) ;
 				ped_device_get( temp_devices[ k ] .c_str() ) ;
 			}
-
-			//Try to find all dmraid devices
-			if (dmraid .is_dmraid_supported() ) {
-				std::vector<Glib::ustring> dmraid_devices ;
-				dmraid .get_devices( dmraid_devices ) ;
-				for ( unsigned int k=0; k < dmraid_devices .size(); k++ ) {
-					set_thread_status_message( String::ucompose ( _("Scanning %1"), dmraid_devices[k] ) ) ;
-#ifndef USE_LIBPARTED_DMRAID
-					dmraid .create_dev_map_entries( dmraid_devices[k] ) ;
-					settle_device( 1 ) ;
-#endif
-					ped_device_get( dmraid_devices[k] .c_str() ) ;
-				}
-			}
 		}
 		else
 		{
@@ -229,23 +213,6 @@ void GParted_Core::set_devices( std::vector<Device> & devices )
 
 		std::sort( device_paths .begin(), device_paths .end() ) ;
 	}
-#ifndef USE_LIBPARTED_DMRAID
-	else
-	{
-		//Device paths were passed in on the command line.
-
-		//Ensure that dmraid device entries are created
-		for ( unsigned int t = 0 ; t < device_paths .size() ; t++ ) 
-		{
-			if ( dmraid .is_dmraid_supported() &&
-			     dmraid .is_dmraid_device( device_paths[t] ) )
-			{
-				dmraid .create_dev_map_entries( dmraid .get_dmraid_name( device_paths [t] ) ) ;
-			}
-		}
-	}
-#endif
-
 	for ( unsigned int t = 0 ; t < device_paths .size() ; t++ ) 
 	{
 		/*TO TRANSLATORS: looks like Searching /dev/sda partitions */ 
@@ -725,16 +692,6 @@ bool GParted_Core::set_disklabel( const Glib::ustring & device_path, const Glib:
 		close_device_and_disk( lp_device, lp_disk ) ;
 	}
 
-#ifndef USE_LIBPARTED_DMRAID
-	//delete and recreate disk entries if dmraid
-	DMRaid dmraid ;
-	if ( return_value && dmraid .is_dmraid_device( device_path ) )
-	{
-		dmraid .purge_dev_map_entries( device_path ) ;
-		dmraid .create_dev_map_entries( device_path ) ;
-	}
-#endif
-
 	return return_value ;	
 }
 	
@@ -955,17 +912,6 @@ Glib::ustring GParted_Core::get_partition_path( PedPartition * lp_partition )
 		free(lp_path);
 	}
 
-#ifndef USE_LIBPARTED_DMRAID
-	//Ensure partition path name is compatible with dmraid
-	DMRaid dmraid;   //Use cache of dmraid device information
-	if (   dmraid .is_dmraid_supported()
-	    && dmraid .is_dmraid_device( partition_path )
-	   )
-	{
-		partition_path = dmraid .make_path_dmraid_compatible(partition_path);
-	}
-#endif
-
 	return partition_path ;
 }
 
@@ -978,9 +924,6 @@ void GParted_Core::set_device_partitions( Device & device, PedDevice* lp_device,
 	int EXT_INDEX = -1 ;
 	Proc_Partitions_Info pp_info ; //Use cache of proc partitions information
 	FS_Info fs_info ;  //Use cache of file system information
-#ifndef USE_LIBPARTED_DMRAID
-	DMRaid dmraid ;    //Use cache of dmraid device information
-#endif
 	LVM2_PV_Info lvm2_pv_info ;
 
 	//clear partitions
@@ -1002,23 +945,6 @@ void GParted_Core::set_device_partitions( Device & device, PedDevice* lp_device,
 			case PED_PARTITION_NORMAL:
 			case PED_PARTITION_LOGICAL:
 				filesystem = get_filesystem( lp_device, lp_partition, partition_temp .messages ) ;
-#ifndef USE_LIBPARTED_DMRAID
-				//Handle dmraid devices differently because the minor number might not
-				//  match the last number of the partition filename as shown by "ls -l /dev/mapper"
-				//  This mismatch causes incorrect identification of busy partitions in ped_partition_is_busy(). 
-				if ( dmraid .is_dmraid_device( device .get_path() ) )
-				{
-					//Try device_name + partition_number
-					iter_mp = mount_info .find( device .get_path() + Utils::num_to_str( lp_partition ->num ) ) ;
-					if ( iter_mp != mount_info .end() )
-						partition_is_busy = true ;
-					//Try device_name + p + partition_number
-					iter_mp = mount_info .find( device .get_path() + "p" + Utils::num_to_str( lp_partition ->num ) ) ;
-					if ( iter_mp != mount_info .end() )
-						partition_is_busy = true ;
-				}
-				else
-#endif
 					partition_is_busy = ped_partition_is_busy( lp_partition ) ||
 					                    ( filesystem == GParted::FS_LVM2_PV && lvm2_pv_info .has_active_lvs( partition_path ) ) ;
 
@@ -1042,26 +968,6 @@ void GParted_Core::set_device_partitions( Device & device, PedDevice* lp_device,
 				break ;
 			
 			case PED_PARTITION_EXTENDED:
-#ifndef USE_LIBPARTED_DMRAID
-				//Handle dmraid devices differently because the minor number might not
-				//  match the last number of the partition filename as shown by "ls -l /dev/mapper"
-				//  This mismatch causes incorrect identification of busy partitions in ped_partition_is_busy(). 
-				if ( dmraid .is_dmraid_device( device .get_path() ) )
-				{
-					for ( unsigned int k = 5; k < 255; k++ )
-					{
-						//Try device_name + [5 to 255]
-						iter_mp = mount_info .find( device .get_path() + Utils::num_to_str( k ) ) ;
-						if ( iter_mp != mount_info .end() )
-							partition_is_busy = true ;
-						//Try device_name + p + [5 to 255]
-						iter_mp = mount_info .find( device .get_path() + "p" + Utils::num_to_str( k ) ) ;
-						if ( iter_mp != mount_info .end() )
-							partition_is_busy = true ;
-					}
-				}
-				else
-#endif
 					partition_is_busy = ped_partition_is_busy( lp_partition ) ;
 
 				partition_temp .Set( device .get_path(),
@@ -1426,9 +1332,6 @@ void GParted_Core::insert_unallocated( const Glib::ustring & device_path,
 	
 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++ )
 	{
@@ -1442,32 +1345,6 @@ void GParted_Core::set_mountpoints( std::vector<Partition> & partitions )
 		{
 			if ( partitions[ t ] .busy )
 			{
-#ifndef USE_LIBPARTED_DMRAID
-				//Handle dmraid devices differently because there may be more
-				//  than one partition name.
-				//  E.g., there might be names with and/or without a 'p' between
-				//        the device name and partition number.
-				if ( dmraid .is_dmraid_device( partitions[ t ] .device_path ) )
-				{
-					//Try device_name + partition_number
-					iter_mp = mount_info .find( partitions[ t ] .device_path + Utils::num_to_str( partitions[ t ] .partition_number ) ) ;
-					if ( iter_mp != mount_info .end() )
-					{
-						partitions[ t ] .add_mountpoints( iter_mp ->second ) ;
-						break ;
-					}
-					//Try device_name + p + partition_number
-					iter_mp = mount_info .find( partitions[ t ] .device_path + "p" + Utils::num_to_str( partitions[ t ] .partition_number ) ) ;
-					if ( iter_mp != mount_info .end() )
-					{
-						partitions[ t ] .add_mountpoints( iter_mp ->second ) ;
-						break ;
-					}
-				}
-				else
-				{
-#endif
-					//Normal device, not DMRaid device
 					for ( unsigned int i = 0 ; i < partitions[ t ] .get_paths() .size() ; i++ )
 					{
 						iter_mp = mount_info .find( partitions[ t ] .get_paths()[ i ] ) ;
@@ -1477,10 +1354,6 @@ void GParted_Core::set_mountpoints( std::vector<Partition> & partitions )
 							break ;
 						}
 					}
-#ifndef USE_LIBPARTED_DMRAID
-				}
-#endif
-
 				if ( partitions[ t ] .get_mountpoints() .empty() )
 					partitions[ t ] .messages .push_back( _("Unable to find mount point") ) ;
 			}
@@ -1775,13 +1648,6 @@ bool GParted_Core::create_partition( Partition & new_partition, OperationDetail
 #endif
 	;
 
-#ifndef USE_LIBPARTED_DMRAID
-	//create dev map entries if dmraid
-	DMRaid dmraid ;
-	if ( succes && dmraid .is_dmraid_device( new_partition .device_path ) )
-		succes = dmraid .create_dev_map_entries( new_partition, operationdetail .get_last_child() ) ;
-#endif
-
 	operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
 
 	return succes ;
@@ -1850,27 +1716,6 @@ bool GParted_Core::Delete( const Partition & partition, OperationDetail & operat
 		close_device_and_disk( lp_device, lp_disk ) ;
 	}
 
-#ifndef USE_LIBPARTED_DMRAID
-	//delete partition dev mapper entry, and delete and recreate all other affected dev mapper entries if dmraid
-	DMRaid dmraid ;
-	if ( succes && dmraid .is_dmraid_device( partition .device_path ) )
-	{
-		PedDevice* lp_device = NULL ;
-		PedDisk* lp_disk = NULL ;
-		//Open disk handle before and close after to prevent application crash.
-		if ( open_device_and_disk( partition .device_path, lp_device, lp_disk ) )
-		{
-			if ( ! dmraid .delete_affected_dev_map_entries( partition, operationdetail .get_last_child() ) )
-				succes = false ;	//comand failed
-
-			if ( ! dmraid .create_dev_map_entries( partition, operationdetail .get_last_child() ) )
-				succes = false ;	//command failed
-
-			close_device_and_disk( lp_device, lp_disk ) ;
-		}
-	}
-#endif
-
 	operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
 	return succes ;
 }
@@ -2415,21 +2260,6 @@ bool GParted_Core::resize_move_partition( const Partition & partition_old,
 			STATUS_NONE, 
 			FONT_ITALIC ) ) ;
 
-#ifndef USE_LIBPARTED_DMRAID
-		//update dev mapper entry if partition is dmraid.
-		DMRaid dmraid ;
-		if ( return_value && dmraid .is_dmraid_device( partition_new .device_path ) )
-		{
-			PedDevice* lp_device = NULL ;
-			PedDisk* lp_disk = NULL ;
-			//Open disk handle before and close after to prevent application crash.
-			if ( open_device_and_disk( partition_new .device_path, lp_device, lp_disk ) )
-			{
-				return_value = dmraid .update_dev_map_entry( partition_new, operationdetail .get_last_child() ) ;
-				close_device_and_disk( lp_device, lp_disk ) ;
-			}
-		}
-#endif
 	}
 	else
 	{
@@ -3243,22 +3073,6 @@ bool GParted_Core::calculate_exact_geom( const Partition & partition_old,
 						Utils::format_size( partition_new .get_sector_length(), partition_new .sector_size ) ),
 			STATUS_NONE,
 			FONT_ITALIC ) ) ;
-
-#ifndef USE_LIBPARTED_DMRAID
-		//Update dev mapper entry if partition is dmraid.
-		DMRaid dmraid ;
-		if ( succes && dmraid .is_dmraid_device( partition_new .device_path ) )
-		{
-			PedDevice* lp_device = NULL ;
-			PedDisk* lp_disk = NULL ;
-			//Open disk handle before and close after to prevent application crash.
-			if ( open_device_and_disk( partition_new .device_path, lp_device, lp_disk ) )
-			{
-				succes = dmraid .update_dev_map_entry( partition_new, operationdetail .get_last_child() ) ;
-				close_device_and_disk( lp_device, lp_disk ) ;
-			}
-		}
-#endif
 	}
 
 	operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
@@ -3465,28 +3279,17 @@ bool GParted_Core::commit( PedDisk* lp_disk )
 bool GParted_Core::commit_to_os( PedDisk* lp_disk, std::time_t timeout )
 {
 	bool succes ;
-#ifndef USE_LIBPARTED_DMRAID
-	DMRaid dmraid ;
-	if ( dmraid .is_dmraid_device( lp_disk ->dev ->path ) )
-		succes = true ;
-	else
+	succes = ped_disk_commit_to_os( lp_disk ) ;
+#ifndef HAVE_LIBPARTED_2_2_0_PLUS
+	//Work around to try to alleviate problems caused by
+	//  bug #604298 - Failure to inform kernel of partition changes
+	//  If not successful the first time, try one more time.
+	if ( ! succes )
 	{
-#endif
+		sleep( 1 ) ;
 		succes = ped_disk_commit_to_os( lp_disk ) ;
-#ifndef HAVE_LIBPARTED_2_2_0_PLUS
-		//Work around to try to alleviate problems caused by
-		//  bug #604298 - Failure to inform kernel of partition changes
-		//  If not successful the first time, try one more time.
-		if ( ! succes )
-		{
-			sleep( 1 ) ;
-			succes = ped_disk_commit_to_os( lp_disk ) ;
-		}
-#endif
-#ifndef USE_LIBPARTED_DMRAID
 	}
 #endif
-
 	settle_device( timeout ) ;
 
 	return succes ;
diff --git a/src/Makefile.am b/src/Makefile.am
index d5ec826..344acc0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -24,7 +24,6 @@ gpartedbin_SOURCES = \
 	DialogFeatures.cc		\
 	DialogManageFlags.cc		\
 	DrawingAreaVisualDisk.cc	\
-	DMRaid.cc				\
 	FileSystem.cc			\
 	Frame_Resizer_Base.cc		\
 	Frame_Resizer_Extended.cc	\



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