[gparted/lucab/btrfs: 3/4] Use Btrfs handlers, if enabled at configure time



commit 5997bebee2c0f9e5cc6d046fe2bf9bf58a8ffaa0
Author: Luca Bruno <lucab debian org>
Date:   Sat Jan 2 12:13:31 2010 +0100

    Use Btrfs handlers, if enabled at configure time
    
    GParted already has basic support only to recognize Btrfs volumes; if
    configured, use our newer methods to handle them.
    Also, put in place interface controls for all supported generic actions.

 src/GParted_Core.cc |   36 ++++++++++++++++++++++++++----------
 src/Utils.cc        |    4 ++++
 src/Win_GParted.cc  |    6 +++++-
 3 files changed, 35 insertions(+), 11 deletions(-)
---
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 1097250..db8d4d0 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -27,6 +27,7 @@
 #include "../include/OperationFormat.h"
 #include "../include/OperationResizeMove.h"
 #include "../include/OperationLabelPartition.h"
+#include "../config.h"
 
 #include "../include/ext2.h"
 #include "../include/ext3.h"
@@ -42,7 +43,9 @@
 #include "../include/hfsplus.h"
 #include "../include/reiser4.h"
 #include "../include/ufs.h"
-
+#ifdef BTRFS_SUPPORT
+#include "../include/btrfs.h"
+#endif
 #include <set>
 #include <cerrno>
 #include <cstring>
@@ -86,6 +89,17 @@ void GParted_Core::find_supported_filesystems()
 {
 	FILESYSTEMS .clear() ;
 	
+	FS *fs ;
+#ifdef BTRFS_SUPPORT
+	btrfs fs_btrfs;
+	FILESYSTEMS .push_back( fs_btrfs .get_filesystem_support() ) ;
+#else
+	//btrfs  FIXME:  Add full support when on-disk-format stabilized
+	fs = new( FS ) ;
+	fs ->filesystem = GParted::FS_BTRFS ;
+	FILESYSTEMS .push_back( * fs ) ;
+#endif
+
 	ext2 fs_ext2;
 	FILESYSTEMS .push_back( fs_ext2 .get_filesystem_support() ) ;
 	
@@ -128,12 +142,6 @@ void GParted_Core::find_supported_filesystems()
 	xfs fs_xfs;
 	FILESYSTEMS .push_back( fs_xfs .get_filesystem_support() ) ;
 
-	FS *fs ;
-	//btrfs  FIXME:  Add full support when on-disk-format stabilized
-	fs = new( FS ) ;
-	fs ->filesystem = GParted::FS_BTRFS ;
-	FILESYSTEMS .push_back( * fs ) ;
-
 	//lvm2 physical volume -- not a file system
 	fs = new( FS ) ;
 	fs ->filesystem = GParted::FS_LVM2 ;
@@ -1164,9 +1172,11 @@ GParted::FILESYSTEM GParted_Core::get_filesystem()
 
 	if ( magic1 == BTRFS_SIGNATURE )
 	{
+#ifndef BTRFS_SUPPORT
 		temp = _( "BTRFS is not yet supported." ) ;
 		temp += "\n" ;
 		partition_temp .messages .push_back( temp ) ;
+#endif
 		return GParted::FS_BTRFS ;
 	}
 
@@ -1269,8 +1279,10 @@ void GParted_Core::set_mountpoints( std::vector<Partition> & partitions )
 		     ) &&
 		     partitions[ t ] .filesystem != GParted::FS_LINUX_SWAP &&
 		     partitions[ t ] .filesystem != GParted::FS_LVM2 &&
-		     partitions[ t ] .filesystem != GParted::FS_LUKS &&
-		     partitions[ t ] .filesystem != GParted::FS_BTRFS
+		     partitions[ t ] .filesystem != GParted::FS_LUKS
+#ifndef BTRFS_SUPPORT
+		     && partitions[ t ] .filesystem != GParted::FS_BTRFS
+#endif
 		   )
 		{
 			if ( partitions[ t ] .busy )
@@ -1331,7 +1343,9 @@ void GParted_Core::set_used_sectors( std::vector<Partition> & partitions )
 	for ( unsigned int t = 0 ; t < partitions .size() ; t++ )
 	{
 		if ( partitions[ t ] .filesystem != GParted::FS_LINUX_SWAP &&
+#ifndef BTRFS_SUPPORT
 		     partitions[ t ] .filesystem != GParted::FS_BTRFS &&
+#endif
 		     partitions[ t ] .filesystem != GParted::FS_LUKS &&
 		     partitions[ t ] .filesystem != GParted::FS_LVM2 &&
 		     partitions[ t ] .filesystem != GParted::FS_UNKNOWN
@@ -2837,7 +2851,9 @@ bool GParted_Core::set_proper_filesystem( const FILESYSTEM & filesystem )
 		case FS_HFS		: p_filesystem = new hfs() ; 		break ;
 		case FS_HFSPLUS		: p_filesystem = new hfsplus() ; 	break ;
 		case FS_UFS		: p_filesystem = new ufs() ;	 	break ;
-
+#ifdef BTRFS_SUPPORT
+		case FS_BTRFS		: p_filesystem = new btrfs() ;	 	break ;
+#endif
 		default			: p_filesystem = NULL ;
 	}
 
diff --git a/src/Utils.cc b/src/Utils.cc
index 504f284..b42b750 100644
--- a/src/Utils.cc
+++ b/src/Utils.cc
@@ -17,6 +17,7 @@
  */
 
 #include "../include/Utils.h"
+#include "../config.h"
 
 #include <sstream>
 #include <iomanip>
@@ -161,6 +162,9 @@ Glib::ustring Utils::get_filesystem_software( FILESYSTEM filesystem )
 		case FS_REISER4     : return "reiser4progs" ;
 		case FS_REISERFS    : return "reiserfsprogs" ;
 		case FS_UFS         : return "" ;
+#ifdef BTRFS_SUPPORT
+		case FS_BTRFS       : return "btrfs-tools" ;
+#endif
 		case FS_XFS         : return "xfsprogs" ;
 
 		default             : return "" ;
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index 3156882..603b557 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -33,6 +33,7 @@
 #include "../include/OperationFormat.h"
 #include "../include/OperationResizeMove.h"
 #include "../include/OperationLabelPartition.h"
+#include "../config.h"
 
 #include <gtkmm/aboutdialog.h>
 #include <gtkmm/messagedialog.h>
@@ -393,7 +394,10 @@ Gtk::Menu * Win_GParted::create_format_menu()
 	for ( unsigned int t =0; t < gparted_core .get_filesystems() .size() ; t++ )
 	{
 		//Skip btrfs, luks, lvm2, and unknown because these are not file systems
-		if ( gparted_core .get_filesystems()[ t ] .filesystem == GParted::FS_BTRFS ||
+		if (
+#ifndef BTRFS_SUPPORT
+		     gparted_core .get_filesystems()[ t ] .filesystem == GParted::FS_BTRFS ||
+#endif
 		     gparted_core .get_filesystems()[ t ] .filesystem == GParted::FS_LUKS ||
 		     gparted_core .get_filesystems()[ t ] .filesystem == GParted::FS_LVM2 ||
 		     gparted_core .get_filesystems()[ t ] .filesystem == GParted::FS_UNKNOWN



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