[gparted] Enable compile and link with libparted 3.0 (#651559)



commit 8a58b5b53e67bb7c9ac1b8d4fbef0e2b50139acf
Author: Curtis Gedak <gedakc gmail com>
Date:   Thu Jun 9 09:59:41 2011 -0600

    Enable compile and link with libparted 3.0 (#651559)
    
    The release of (lib)parted 3.0 includes a change to the Application
    Programing Interface - API.  Most importantly, libparted 3.0 removes
    many file system specific function calls, and hence the capabilities
    provided by these functions.  In order for GParted to compile and link
    with libparted 3.0, this libparted functionality is lost.
    
    Specifically, the functionality that is lost when GParted is compiled
    and linked with libparted 3.0 is as follows:
    
      - Loss of ability to grow and shrink FAT16 and FAT32 file systems
      - Loss of ability to shrink HFS and HFS+ file systems
      - Loss of ability to determine used and unused sectors in HFS and
          HFS+ file systems
      - Loss of ability to erase file system signatures on partition
          create and format
    
    It is hoped that other free software projects will include some or all
    of the above lost functionality, which can then be added back to
    GParted.
    
    This commit includes a change in how FAT16 and FAT32 file systems are
    moved.  Specifically the move is now performed internally by GParted
    when linked with libparted 3.0.  The move functionality is provided by
    libparted for prior libparted versions (e.g. less than 3.0).
    
    This is the final enhancement in a series of commits that enable
    GParted to compile with libparted version 3.0.
    
    Closes Bug #651559 - Doesn't compile against parted 3.0

 include/GParted_Core.h      |    8 +++++++-
 include/Utils.h             |    4 +++-
 src/Dialog_Partition_New.cc |    4 ++--
 src/GParted_Core.cc         |   38 +++++++++++++++++++++++++++++++++-----
 src/fat16.cc                |    8 ++++++--
 src/fat32.cc                |   10 +++++++---
 src/hfs.cc                  |    6 ++++--
 src/hfsplus.cc              |    8 +++++---
 8 files changed, 67 insertions(+), 19 deletions(-)
---
diff --git a/include/GParted_Core.h b/include/GParted_Core.h
index 55bd6f5..03ad852 100644
--- a/include/GParted_Core.h
+++ b/include/GParted_Core.h
@@ -1,5 +1,5 @@
 /* Copyright (C) 2004 Bart
- * Copyright (C) 2008, 2009, 2010 Curtis Gedak
+ * Copyright (C) 2008, 2009, 2010, 2011 Curtis Gedak
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -78,7 +78,9 @@ private:
 				 bool inside_extended ) ;
 	void set_mountpoints( std::vector<Partition> & partitions ) ;
 	void set_used_sectors( std::vector<Partition> & partitions ) ;
+#ifndef HAVE_LIBPARTED_3_0_0_PLUS
 	void LP_set_used_sectors( Partition & partition );
+#endif
 	void set_flags( Partition & partition ) ;
 	
 	//operationstuff...
@@ -103,9 +105,11 @@ private:
 	bool move_filesystem( const Partition & partition_old,
 			      const Partition & partition_new,
 			      OperationDetail & operationdetail ) ;
+#ifndef HAVE_LIBPARTED_3_0_0_PLUS
 	bool resize_move_filesystem_using_libparted( const Partition & partition_old,
 				      		     const Partition & partition_new,
 					      	     OperationDetail & operationdetail ) ;
+#endif
 	bool resize( const Partition & partition_old,
 		     const Partition & partition_new,
 		     OperationDetail & operationdetail ) ;
@@ -176,7 +180,9 @@ private:
 			           Partition & partition_new,
 				   OperationDetail & operationdetail ) ;
 	bool set_proper_filesystem( const FILESYSTEM & filesystem ) ;
+#ifndef HAVE_LIBPARTED_3_0_0_PLUS
 	bool erase_filesystem_signatures( const Partition & partition ) ;
+#endif
 	bool update_bootsector( const Partition & partition, OperationDetail & operationdetail ) ;
 
 	//general..	
diff --git a/include/Utils.h b/include/Utils.h
index 180416b..e154d6f 100644
--- a/include/Utils.h
+++ b/include/Utils.h
@@ -1,5 +1,5 @@
 /* Copyright (C) 2004 Bart
- * Copyright (C) 2008, 2009, 2010 Curtis Gedak
+ * Copyright (C) 2008, 2009, 2010, 2011 Curtis Gedak
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -94,7 +94,9 @@ struct FS
 	{
 		NONE		= 0,
 		GPARTED		= 1,
+#ifndef HAVE_LIBPARTED_3_0_0_PLUS
 		LIBPARTED	= 2,
+#endif
 		EXTERNAL	= 3
 	};
 
diff --git a/src/Dialog_Partition_New.cc b/src/Dialog_Partition_New.cc
index 7ecb2e5..7be8ef4 100644
--- a/src/Dialog_Partition_New.cc
+++ b/src/Dialog_Partition_New.cc
@@ -1,5 +1,5 @@
 /* Copyright (C) 2004 Bart
- * Copyright (C) 2008, 2009, 2010 Curtis Gedak
+ * Copyright (C) 2008, 2009, 2010, 2011 Curtis Gedak
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -61,7 +61,7 @@ void Dialog_Partition_New::Set_Data( const Partition & partition,
 	FS fs_tmp ;
 	//add FS_UNFORMATTED
 	fs_tmp .filesystem = GParted::FS_UNFORMATTED ;
-	fs_tmp .create = GParted::FS::LIBPARTED ;
+	fs_tmp .create = FS::GPARTED ;
 	this ->FILESYSTEMS .push_back( fs_tmp ) ;
 
 	//add FS_EXTENDED
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 847ca74..a39b88f 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -1223,8 +1223,10 @@ void GParted_Core::read_label( Partition & partition )
 				if ( set_proper_filesystem( partition .filesystem ) )
 					p_filesystem ->read_label( partition ) ;
 				break ;
+#ifndef HAVE_LIBPARTED_3_0_0_PLUS
 			case FS::LIBPARTED:
 				break ;
+#endif
 
 			default:
 				break ;
@@ -1396,9 +1398,11 @@ void GParted_Core::set_used_sectors( std::vector<Partition> & partitions )
 							if ( set_proper_filesystem( partitions[ t ] .filesystem ) )
 								p_filesystem ->set_used_sectors( partitions[ t ] ) ;
 							break ;
+#ifndef HAVE_LIBPARTED_3_0_0_PLUS
 						case GParted::FS::LIBPARTED	:
 							LP_set_used_sectors( partitions[ t ] ) ;
 							break ;
+#endif
 
 						default:
 							break ;
@@ -1430,6 +1434,7 @@ void GParted_Core::set_used_sectors( std::vector<Partition> & partitions )
 	}
 }
 
+#ifndef HAVE_LIBPARTED_3_0_0_PLUS
 void GParted_Core::LP_set_used_sectors( Partition & partition )
 {
 	PedFileSystem *fs = NULL;
@@ -1458,6 +1463,7 @@ void GParted_Core::LP_set_used_sectors( Partition & partition )
 		}
 	}
 }
+#endif
 
 void GParted_Core::set_flags( Partition & partition )
 {
@@ -1572,7 +1578,11 @@ bool GParted_Core::create_partition( Partition & new_partition, OperationDetail
 		close_device_and_disk() ;
 	}
 
-	bool succes = new_partition .partition_number > 0 && erase_filesystem_signatures( new_partition ) ;
+	bool succes = new_partition .partition_number > 0
+#ifndef HAVE_LIBPARTED_3_0_0_PLUS
+	              && erase_filesystem_signatures( new_partition )
+#endif
+	;
 
 #ifndef USE_LIBPARTED_DMRAID
 	//create dev map entries if dmraid
@@ -1600,8 +1610,10 @@ bool GParted_Core::create_filesystem( const Partition & partition, OperationDeta
 			break ;
 		case GParted::FS::GPARTED:
 			break ;
+#ifndef HAVE_LIBPARTED_3_0_0_PLUS
 		case GParted::FS::LIBPARTED:
 			break ;
+#endif
 		case GParted::FS::EXTERNAL:
 			succes = set_proper_filesystem( partition .filesystem ) &&
 				 p_filesystem ->create( partition, operationdetail .get_last_child() ) ;
@@ -1614,9 +1626,11 @@ bool GParted_Core::create_filesystem( const Partition & partition, OperationDeta
 }
 
 bool GParted_Core::format( const Partition & partition, OperationDetail & operationdetail )
-{	
+{
+#ifndef HAVE_LIBPARTED_3_0_0_PLUS
 	//remove all file system signatures...
 	erase_filesystem_signatures( partition ) ;
+#endif
 
 	return set_partition_type( partition, operationdetail ) && create_filesystem( partition, operationdetail ) ;
 }
@@ -1684,8 +1698,10 @@ bool GParted_Core::label_partition( const Partition & partition, OperationDetail
 				succes = set_proper_filesystem( partition .filesystem ) &&
 					 p_filesystem ->write_label( partition, operationdetail .get_last_child() ) ;
 				break ;
+#ifndef HAVE_LIBPARTED_3_0_0_PLUS
 			case FS::LIBPARTED:
 				break ;
+#endif
 
 			default:
 				break ;
@@ -1867,11 +1883,13 @@ bool GParted_Core::move_filesystem( const Partition & partition_old,
 				succes = copy_filesystem( partition_old, partition_new, operationdetail .get_last_child() ) ;
 
 			break ;
+#ifndef HAVE_LIBPARTED_3_0_0_PLUS
 		case GParted::FS::LIBPARTED:
 			succes = resize_move_filesystem_using_libparted( partition_old,
 									 partition_new,
 								  	 operationdetail .get_last_child() ) ;
 			break ;
+#endif
 		case GParted::FS::EXTERNAL:
 			succes = set_proper_filesystem( partition_new .filesystem ) &&
 			         p_filesystem ->move( partition_old
@@ -1885,6 +1903,7 @@ bool GParted_Core::move_filesystem( const Partition & partition_old,
 	return succes ;
 }
 
+#ifndef HAVE_LIBPARTED_3_0_0_PLUS
 bool GParted_Core::resize_move_filesystem_using_libparted( const Partition & partition_old,
 		  	      		            	   const Partition & partition_new,
 						    	   OperationDetail & operationdetail ) 
@@ -1921,6 +1940,7 @@ bool GParted_Core::resize_move_filesystem_using_libparted( const Partition & par
 
 	return return_value ;
 }
+#endif
 
 bool GParted_Core::resize( const Partition & partition_old, 
 			   const Partition & partition_new,
@@ -2173,11 +2193,13 @@ bool GParted_Core::resize_filesystem( const Partition & partition_old,
 			break ;
 		case GParted::FS::GPARTED:
 			break ;
+#ifndef HAVE_LIBPARTED_3_0_0_PLUS
 		case GParted::FS::LIBPARTED:
 			succes = resize_move_filesystem_using_libparted( partition_old,
 									 partition_new,
 								  	 operationdetail .get_last_child() ) ;
 			break ;
+#endif
 		case GParted::FS::EXTERNAL:
 			succes = set_proper_filesystem( partition_new .filesystem ) && 
 				 p_filesystem ->resize( partition_new,
@@ -2244,10 +2266,12 @@ bool GParted_Core::copy( const Partition & partition_src,
 									  partition_dst,
 									  operationdetail .get_last_child() ) ;
 						break ;
-				
+
+#ifndef HAVE_LIBPARTED_3_0_0_PLUS
 				case GParted::FS::LIBPARTED :
 						//FIXME: see if copying through libparted has any advantages
 						break ;
+#endif
 
 				case GParted::FS::EXTERNAL :
 						succes = set_proper_filesystem( partition_dst .filesystem ) &&
@@ -2479,8 +2503,10 @@ bool GParted_Core::check_repair_filesystem( const Partition & partition, Operati
 			break ;
 		case GParted::FS::GPARTED:
 			break ;
+#ifndef HAVE_LIBPARTED_3_0_0_PLUS
 		case GParted::FS::LIBPARTED:
 			break ;
+#endif
 		case GParted::FS::EXTERNAL:
 			succes = set_proper_filesystem( partition .filesystem ) &&
 				 p_filesystem ->check_repair( partition, operationdetail .get_last_child() ) ;
@@ -2908,7 +2934,8 @@ bool GParted_Core::set_proper_filesystem( const FILESYSTEM & filesystem )
 
 	return p_filesystem ;
 }
-	
+
+#ifndef HAVE_LIBPARTED_3_0_0_PLUS
 bool GParted_Core::erase_filesystem_signatures( const Partition & partition ) 
 {
 	bool return_value = false ;
@@ -2935,7 +2962,8 @@ bool GParted_Core::erase_filesystem_signatures( const Partition & partition )
 
 	return return_value ;
 }
-	
+#endif
+
 bool GParted_Core::update_bootsector( const Partition & partition, OperationDetail & operationdetail ) 
 {
 	//only for ntfs atm...
diff --git a/src/fat16.cc b/src/fat16.cc
index a9d418a..2fe73c9 100644
--- a/src/fat16.cc
+++ b/src/fat16.cc
@@ -1,5 +1,5 @@
 /* Copyright (C) 2004 Bart
- * Copyright (C) 2008, 2009, 2010 Curtis Gedak
+ * Copyright (C) 2008, 2009, 2010, 2011 Curtis Gedak
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -49,11 +49,15 @@ FS fat16::get_filesystem_support()
 		fs .write_label = FS::EXTERNAL ;
 	}
 
+#ifndef HAVE_LIBPARTED_3_0_0_PLUS
 	//resizing of start and endpoint are provided by libparted
 	fs .grow = GParted::FS::LIBPARTED ;
 	fs .shrink = GParted::FS::LIBPARTED ;
 	fs .move = GParted::FS::LIBPARTED ;
-		
+#else
+	fs.move = FS::GPARTED ;
+#endif
+
 	fs .copy = GParted::FS::GPARTED ;
 	
 	fs .MIN = 16 * MEBIBYTE ;
diff --git a/src/fat32.cc b/src/fat32.cc
index f7990dd..8860a5e 100644
--- a/src/fat32.cc
+++ b/src/fat32.cc
@@ -1,5 +1,5 @@
 /* Copyright (C) 2004 Bart
- * Copyright (C) 2008, 2009, 2010 Curtis Gedak
+ * Copyright (C) 2008, 2009, 2010, 2011 Curtis Gedak
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -48,12 +48,16 @@ FS fat32::get_filesystem_support()
 		fs .read_label = FS::EXTERNAL ;
 		fs .write_label = FS::EXTERNAL ;
 	}
-	
+
+#ifndef HAVE_LIBPARTED_3_0_0_PLUS
 	//resizing of start and endpoint are provided by libparted
 	fs .grow = GParted::FS::LIBPARTED ;
 	fs .shrink = GParted::FS::LIBPARTED ;
 	fs .move = GParted::FS::LIBPARTED ;
-		
+#else
+	fs .move = FS::GPARTED ;
+#endif
+
 	fs .copy = GParted::FS::GPARTED ;
 	
 	fs .MIN = 32 * MEBIBYTE ; //smaller fs'es will cause windows scandisk to fail..
diff --git a/src/hfs.cc b/src/hfs.cc
index aa6fed7..0856aaa 100644
--- a/src/hfs.cc
+++ b/src/hfs.cc
@@ -1,5 +1,5 @@
 /* Copyright (C) 2004 Bart
- * Copyright (C) 2008, 2009, 2010 Curtis Gedak
+ * Copyright (C) 2008, 2009, 2010, 2011 Curtis Gedak
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -27,9 +27,11 @@ FS hfs::get_filesystem_support()
 	FS fs ;
 		
 	fs .filesystem = GParted::FS_HFS ;
-	
+
+#ifndef HAVE_LIBPARTED_3_0_0_PLUS
 	fs .read = GParted::FS::LIBPARTED ; 
 	fs .shrink = GParted::FS::LIBPARTED ; 
+#endif
 
 	if ( ! Glib::find_program_in_path( "hformat" ) .empty() )
 		fs .create = GParted::FS::EXTERNAL ;
diff --git a/src/hfsplus.cc b/src/hfsplus.cc
index bb5126d..31925a0 100644
--- a/src/hfsplus.cc
+++ b/src/hfsplus.cc
@@ -1,5 +1,5 @@
 /* Copyright (C) 2004 Bart
- * Copyright (C) 2008, 2009, 2010 Curtis Gedak
+ * Copyright (C) 2008, 2009, 2010, 2011 Curtis Gedak
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -27,10 +27,12 @@ FS hfsplus::get_filesystem_support()
 	FS fs ;
 	
 	fs .filesystem = GParted::FS_HFSPLUS ;
-	
+
+#ifndef HAVE_LIBPARTED_3_0_0_PLUS
 	fs .read = GParted::FS::LIBPARTED ; 
 	fs .shrink = GParted::FS::LIBPARTED ; 
-	
+#endif
+
 	if ( ! Glib::find_program_in_path( "mkfs.hfsplus" ) .empty() )
 		fs .create = GParted::FS::EXTERNAL ;
 	



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