Index: include/Utils.h
===================================================================
--- include/Utils.h	(revisione 1057)
+++ include/Utils.h	(copia locale)
@@ -64,11 +64,12 @@
 	FS_HFS		= 15,
 	FS_HFSPLUS	= 16,
 	FS_UFS		= 17,
+	FS_BTRFS	= 18,
 
-	FS_USED		= 18,
-	FS_UNUSED	= 19,
+	FS_USED		= 19,
+	FS_UNUSED	= 20,
 
-	FS_LVM2		= 20   
+	FS_LVM2		= 21   
 } ;
 
 enum SIZE_UNIT
Index: include/btrfs.h
===================================================================
--- include/btrfs.h	(revisione 0)
+++ include/btrfs.h	(revisione 0)
@@ -0,0 +1,42 @@
+/* Copyright (C) 2009 Luca Bruno <lucab@debian.org>
+ *
+ *  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
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+ 
+ 
+#ifndef BTRFS_H_
+#define BTRFS_H_
+
+#include "../include/FileSystem.h"
+
+namespace GParted
+{
+class btrfs : public FileSystem
+{
+public:
+	FS get_filesystem_support() ;
+	void set_used_sectors( Partition & partition ) ;
+	void read_label( Partition & partition ) ;
+	bool write_label( const Partition & partition, OperationDetail & operationdetail ) ;
+	bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
+	bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
+	bool copy( const Glib::ustring & src_part_path,
+		   const Glib::ustring & dest_part_path,
+		   OperationDetail & operationdetail ) ;
+	bool check_repair( const Partition & partition, OperationDetail & operationdetail ) ;
+};
+} //GParted
+
+#endif //BTRFS_H_
Index: include/Makefile.am
===================================================================
--- include/Makefile.am	(revisione 1057)
+++ include/Makefile.am	(copia locale)
@@ -1,5 +1,9 @@
 gparted_includedir = $(pkgincludedir)
 
+if BTRFS_SUPPORT
+btrfs_source = btrfs.h
+endif
+
 EXTRA_DIST = \
 	Device.h 			\
 	Dialog_Base_Partition.h		\
@@ -46,4 +50,5 @@
 	reiser4.h   			\
 	reiserfs.h  			\
 	ufs.h  				\
-	xfs.h
+	xfs.h				\
+	$(btrfs_source)			
Index: configure.in
===================================================================
--- configure.in	(revisione 1057)
+++ configure.in	(copia locale)
@@ -107,7 +107,25 @@
 
 AM_CONDITIONAL(DISABLE_DOC, test ${enable_doc} = no)
 
+dnl ******************************
+dnl Optional btrfs support
+dnl ******************************
 
+with_btrfs="no"
+AC_ARG_ENABLE(	btrfs,
+		AS_HELP_STRING([--enable-btrfs], [enable experimental btrfs support (disabled by default)]),
+       		with_btrfs=$enableval,
+		with_btrfs=no)
+
+if test "x$with_btrfs" = "xyes"; then
+                with_btrfs="yes"
+                AC_DEFINE(BTRFS_SUPPORT,1,[Build in btrfs support])
+else
+        with_btrfs="no"
+fi
+AM_CONDITIONAL(BTRFS_SUPPORT, test "x$with_btrfs" = "xyes")
+
+
 AC_CONFIG_FILES([
 Makefile
 compose/Makefile
@@ -131,6 +149,8 @@
 echo "================ Final configuration ==================="
 echo "          Installing into prefix  :  $prefix"
 echo ""
+echo "           Enable btrfs support?  :  $with_btrfs"
+echo ""
 echo "            Build documentation?  :  $enable_doc"
 echo ""
 echo " If all settings are OK, type make and make install "
Index: src/Utils.cc
===================================================================
--- src/Utils.cc	(revisione 1057)
+++ src/Utils.cc	(copia locale)
@@ -16,6 +16,7 @@
  */
 
 #include "../include/Utils.h"
+#include "../config.h"
 
 #include <sstream>
 #include <iomanip>
@@ -85,6 +86,9 @@
 		case FS_HFS			: return "#E0B6AF" ;	//red hilight
 		case FS_HFSPLUS		: return "#C0A39E" ;	// ~ serene red
 		case FS_UFS			: return "#D1940C" ;	//accent yellow dark
+#ifdef BTRFS_SUPPORT
+		case FS_BTRFS			: return "#FF9955" ;	//orange
+#endif
 		case FS_USED		: return "#F8F8BA" ;	// ~ light tan yellow
 		case FS_UNUSED		: return "#FFFFFF" ;	//white
 		case FS_LVM2		: return "#CC9966" ;	// ~ medium brown
@@ -131,6 +135,9 @@
 		case FS_HFS		: return "hfs" ;
 		case FS_HFSPLUS		: return "hfs+" ;
 		case FS_UFS		: return "ufs" ;
+#ifdef BTRFS_SUPPORT
+		case FS_BTRFS		: return "btrfs" ;
+#endif
 		case FS_USED		: return _("used") ;
 		case FS_UNUSED		: return _("unused") ;
 		case FS_LVM2		: return "lvm2" ;
@@ -156,6 +163,9 @@
 		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 "" ;
Index: src/btrfs.cc
===================================================================
--- src/btrfs.cc	(revisione 0)
+++ src/btrfs.cc	(revisione 0)
@@ -0,0 +1,107 @@
+/* Copyright (C) 2009 Luca Bruno <lucab@debian.org>
+ *
+ *  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
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+ 
+ 
+#include "../include/btrfs.h"
+
+namespace GParted
+{
+
+FS btrfs::get_filesystem_support()
+{
+	FS fs ;
+	fs .filesystem = GParted::FS_BTRFS ;
+	
+	if ( ! Glib::find_program_in_path( "btrfs-show" ) .empty() )
+	{
+		fs .read = GParted::FS::EXTERNAL ;
+		fs .read_label = FS::EXTERNAL ;
+	}
+
+	if ( ! Glib::find_program_in_path( "mkfs.btrfs" ) .empty() )
+		fs .create = GParted::FS::EXTERNAL ;
+	
+	if ( ! Glib::find_program_in_path( "btrfsck" ) .empty() )
+		fs .check = GParted::FS::EXTERNAL ;
+		
+	if ( fs .check )
+	{
+		fs .copy = GParted::FS::GPARTED ;
+		fs .move = GParted::FS::GPARTED ;
+	}
+
+	fs .MIN = 256 * MEBIBYTE ;
+	
+	return fs ;
+}
+
+bool btrfs::create( const Partition & new_partition, OperationDetail & operationdetail )
+{
+	return (! execute_command( "mkfs.btrfs -L \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) );
+}
+
+bool btrfs::check_repair( const Partition & partition, OperationDetail & operationdetail )
+{
+	return (! execute_command( "btrfsck " + partition .get_path(), operationdetail )) ;
+}
+
+void btrfs::set_used_sectors( Partition & partition )
+{
+// TODO
+    return;
+}
+
+bool btrfs::write_label( const Partition & partition, OperationDetail & operationdetail )
+{
+// TODO
+        return true ;
+}
+
+bool btrfs::copy( const Glib::ustring & src_part_path,
+                    const Glib::ustring & dest_part_path,
+                    OperationDetail & operationdetail )
+{
+// TODO
+        return true ;
+}
+
+bool btrfs::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
+{
+// TODO
+        return true ;
+}
+
+void btrfs::read_label( Partition & partition )
+{
+        if ( ! Utils::execute_command( "btrfs-show " + partition .get_path(), output, error, true ) )
+        {
+                partition .label = Utils::regexp_label( output, "^Label ([^\n\t]*)" ) ;
+        }
+        else
+        {
+                if ( ! output .empty() )
+                        partition .messages .push_back( output ) ;
+
+                if ( ! error .empty() )
+                        partition .messages .push_back( error ) ;
+        }
+
+}
+
+} //GParted
+
+
Index: src/GParted_Core.cc
===================================================================
--- src/GParted_Core.cc	(revisione 1057)
+++ src/GParted_Core.cc	(copia locale)
@@ -24,6 +24,7 @@
 #include "../include/OperationFormat.h"
 #include "../include/OperationResizeMove.h"
 #include "../include/OperationLabelPartition.h"
+#include "../config.h"
 
 #include "../include/ext2.h"
 #include "../include/ext3.h"
@@ -39,7 +40,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>
@@ -124,7 +127,11 @@
 
 	xfs fs_xfs;
 	FILESYSTEMS .push_back( fs_xfs .get_filesystem_support() ) ;
-
+	
+#ifdef BTRFS_SUPPORT
+	btrfs fs_btrfs;
+	FILESYSTEMS .push_back( fs_btrfs .get_filesystem_support() ) ;
+#endif
 	FS *fs ;
 	//lvm2 physical volume -- not a file system
 	fs = new( FS ) ;
@@ -779,6 +786,10 @@
 			return GParted::FS_HFSPLUS ;
 		else if ( Glib::ustring( lp_partition ->fs_type ->name ) == "ufs" )
 			return GParted::FS_UFS ;
+#ifdef BTRFS_SUPPORT
+		else if ( Glib::ustring( lp_partition ->fs_type ->name ) == "btrfs" )
+			return GParted::FS_BTRFS ;
+#endif
 	}
 	
 	
@@ -795,6 +806,23 @@
 	if ( Glib::ustring( buf ) == "ReIsEr4" )
 		return GParted::FS_REISER4 ;		
 
+#ifdef BTRFS_SUPPORT
+	//btrfs
+	//extemporaneus hack - patch already sent to parted (detection only, there too)
+	#define BTRFS_SUPER_INFO_SIZE 4096
+	#define BTRFS_SUPER_INFO_OFFSET (64 * 1024)	
+	#define BTRFS_SIGNATURE "_BHRfS_M"
+
+	char    buf_btrfs[BTRFS_SUPER_INFO_SIZE];
+
+	ped_device_open( lp_device );
+        if (ped_geometry_read( & lp_partition ->geom, buf_btrfs, \
+				(BTRFS_SUPER_INFO_OFFSET / 512), \
+				(BTRFS_SUPER_INFO_SIZE / 512)))
+        	if ( Glib::ustring( buf+64, strlen(BTRFS_SIGNATURE) ) == BTRFS_SIGNATURE)
+                	return GParted::FS_BTRFS;
+	ped_device_close( lp_device );
+#endif
 	//lvm2
 	//NOTE: lvm2 is not a file system but we do wish to recognize the Physical Volume
 	char magic1[16] ;
@@ -1139,7 +1167,7 @@
 		return true ;
 	}
 	else
-	{		
+	{	
 		operationdetail .get_last_child() .set_status( STATUS_ERROR ) ;	
 		return false ;
 	} 
@@ -2307,7 +2335,9 @@
 		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 ;
 	}
 
Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revisione 1057)
+++ src/Makefile.am	(copia locale)
@@ -7,6 +7,10 @@
 
 AM_CXXFLAGS = -Wall	
 
+if BTRFS_SUPPORT
+btrfs_source = btrfs.cc
+endif
+
 sbin_PROGRAMS = gpartedbin
 
 gpartedbin_SOURCES = \
@@ -55,7 +59,8 @@
 	reiser4.cc 			\
 	reiserfs.cc			\
 	ufs.cc				\
-	xfs.cc
+	xfs.cc				\
+	$(btrfs_source)			
 	
 gpartedbin_LDFLAGS = -lparted -lgthread-2.0 
 
