gparted r1075 - in trunk: . include src



Author: gedakc
Date: Mon Feb 23 20:22:30 2009
New Revision: 1075
URL: http://svn.gnome.org/viewvc/gparted?rev=1075&view=rev

Log:
Added detection of btrfs file system

Modified:
   trunk/AUTHORS
   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/AUTHORS
==============================================================================
--- trunk/AUTHORS	(original)
+++ trunk/AUTHORS	Mon Feb 23 20:22:30 2009
@@ -1,7 +1,7 @@
 This file is part of GParted
-Copyright (C) 2004, 2005, 2006, 2007, 2008
+Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
 	Bart Hakvoort
-Portions Copyright (C) 2008
+Portions Copyright (C) 2008, 2009
 	Curtis Gedak
 
 This file may be modified and/or distributed without restriction.  This is
@@ -26,6 +26,9 @@
 	* Created OperationLabelPartition.h, OperationLabelPartition.cc
 	* Maintained from official 0.3.5 release onward 
 
+Luca Bruno			<lucab debian org>
+	* Wrote patch for initial btrfs support.
+
 Michael Monreal		<michael monreal gmx net>
 	* Wrote small patch to implement themed app icon in hicolor
 

Modified: trunk/include/Utils.h
==============================================================================
--- trunk/include/Utils.h	(original)
+++ trunk/include/Utils.h	Mon Feb 23 20:22:30 2009
@@ -68,8 +68,9 @@
 	FS_USED		= 18,
 	FS_UNUSED	= 19,
 
-	FS_LVM2		= 20,
-	FS_LUKS		= 21
+	FS_BTRFS	= 20,  /* FIXME: Move this higher up list when full support added */
+	FS_LVM2		= 21,
+	FS_LUKS		= 22
 } ;
 
 enum SIZE_UNIT

Modified: trunk/src/DialogFeatures.cc
==============================================================================
--- trunk/src/DialogFeatures.cc	(original)
+++ trunk/src/DialogFeatures.cc	Mon Feb 23 20:22:30 2009
@@ -104,8 +104,9 @@
 	//fill the features chart with valid file systems 
 	for ( unsigned short t = 0; t < FILESYSTEMS .size() ; t++ )
 	{
-		//Skip luks, lvm2, and unknown because these are not file systems
-		if ( FILESYSTEMS[ t ] .filesystem == GParted::FS_LUKS ||
+		//Skip btrfs, luks, lvm2, and unknown because these are not file systems
+		if ( FILESYSTEMS[ t ] .filesystem == GParted::FS_BTRFS ||
+		     FILESYSTEMS[ t ] .filesystem == GParted::FS_LUKS ||
 		     FILESYSTEMS[ t ] .filesystem == GParted::FS_LVM2 ||
 		     FILESYSTEMS[ t ] .filesystem == GParted::FS_UNKNOWN
 		   )

Modified: trunk/src/Dialog_Partition_New.cc
==============================================================================
--- trunk/src/Dialog_Partition_New.cc	(original)
+++ trunk/src/Dialog_Partition_New.cc	Mon Feb 23 20:22:30 2009
@@ -50,7 +50,8 @@
 	{
 		if ( this ->FILESYSTEMS[ t ] .filesystem == GParted::FS_UNKNOWN ||
 		     this ->FILESYSTEMS[ t ] .filesystem == GParted::FS_LVM2 ||
-		     this ->FILESYSTEMS[ t ] .filesystem == GParted::FS_LUKS
+		     this ->FILESYSTEMS[ t ] .filesystem == GParted::FS_LUKS ||
+		     this ->FILESYSTEMS[ t ] .filesystem == GParted::FS_BTRFS
 		   )
 			this ->FILESYSTEMS .erase( this->FILESYSTEMS .begin() + t ) ;
 	}
@@ -289,7 +290,7 @@
 	//fill the file system menu with the file systems (except for extended) 
 	for ( unsigned int t = 0 ; t < FILESYSTEMS .size( ) ; t++ ) 
 	{
-		//skip extended (luks, lvm2, and unknown removed in Set_Data())
+		//skip extended (btrfs, luks, lvm2, and unknown removed in Set_Data())
 		if( FILESYSTEMS[ t ] .filesystem == GParted::FS_EXTENDED )
 			continue ;
 		menu_filesystem .items() .push_back( 

Modified: trunk/src/GParted_Core.cc
==============================================================================
--- trunk/src/GParted_Core.cc	(original)
+++ trunk/src/GParted_Core.cc	Mon Feb 23 20:22:30 2009
@@ -126,6 +126,11 @@
 	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 ;
@@ -746,6 +751,8 @@
 	{
 		if ( Glib::ustring( lp_partition ->fs_type ->name ) == "extended" )
 			return GParted::FS_EXTENDED ;
+		else if ( Glib::ustring( lp_partition ->fs_type ->name ) == "btrfs" )
+			return GParted::FS_BTRFS ;
 		else if ( Glib::ustring( lp_partition ->fs_type ->name ) == "ext2" )
 			return GParted::FS_EXT2 ;
 		else if ( Glib::ustring( lp_partition ->fs_type ->name ) == "ext3" )
@@ -798,7 +805,7 @@
 	ped_device_close( lp_device );
 	
 	if ( Glib::ustring( buf ) == "ReIsEr4" )
-		return GParted::FS_REISER4 ;		
+		return GParted::FS_REISER4 ;
 
 	//lvm2
 	//NOTE: lvm2 is not a file system but we do wish to recognize the Physical Volume
@@ -836,6 +843,29 @@
 		return GParted::FS_LUKS ;
 	}
 
+	//btrfs
+	#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 ) ;
+	ped_geometry_read( & lp_partition ->geom, buf_btrfs, \
+	                   (BTRFS_SUPER_INFO_OFFSET / 512), \
+	                   (BTRFS_SUPER_INFO_SIZE / 512)
+	                 ) ;
+	strncpy(magic, buf_btrfs+64, strlen(BTRFS_SIGNATURE)) ;  magic[strlen(BTRFS_SIGNATURE)] = '\0' ; //set and terminate string
+	ped_device_close( lp_device ) ;
+
+	if ( magic == Glib::ustring(BTRFS_SIGNATURE) )
+	{
+		temp = _( "BTRFS is not yet supported." ) ;
+		temp += "\n" ;
+		partition_temp .messages .push_back( temp ) ;
+		return GParted::FS_BTRFS ;
+	}
+
 	//no file system found....
 	temp = _( "Unable to detect file system! Possible reasons are:" ) ;
 	temp += "\n-"; 
@@ -927,7 +957,8 @@
 		     ) &&
 		     partitions[ t ] .filesystem != GParted::FS_LINUX_SWAP &&
 		     partitions[ t ] .filesystem != GParted::FS_LVM2 &&
-		     partitions[ t ] .filesystem != GParted::FS_LUKS
+		     partitions[ t ] .filesystem != GParted::FS_LUKS &&
+		     partitions[ t ] .filesystem != GParted::FS_BTRFS
 		   )
 		{
 			if ( partitions[ t ] .busy )
@@ -968,6 +999,7 @@
 	for ( unsigned int t = 0 ; t < partitions .size() ; t++ )
 	{
 		if ( partitions[ t ] .filesystem != GParted::FS_LINUX_SWAP &&
+		     partitions[ t ] .filesystem != GParted::FS_BTRFS &&
 		     partitions[ t ] .filesystem != GParted::FS_LUKS &&
 		     partitions[ t ] .filesystem != GParted::FS_LVM2 &&
 		     partitions[ t ] .filesystem != GParted::FS_UNKNOWN

Modified: trunk/src/Utils.cc
==============================================================================
--- trunk/src/Utils.cc	(original)
+++ trunk/src/Utils.cc	Mon Feb 23 20:22:30 2009
@@ -71,6 +71,7 @@
 		case FS_UNKNOWN		: return "#000000" ;	//black
 		case FS_UNFORMATTED	: return "#000000" ;	//black
 		case FS_EXTENDED	: return "#7DFCFE" ;	// ~ light blue
+		case FS_BTRFS		: return "#FF9955" ;	//orange
 		case FS_EXT2		: return "#9DB8D2" ;	//blue hilight
 		case FS_EXT3		: return "#7590AE" ;	//blue medium
 		case FS_EXT4		: return "#4B6983" ;	//blue dark
@@ -118,6 +119,7 @@
 		case FS_UNKNOWN		: return _("unknown") ;
 		case FS_UNFORMATTED	: return _("unformatted") ;
 		case FS_EXTENDED	: return "extended" ;
+		case FS_BTRFS		: return "btrfs" ;
 		case FS_EXT2		: return "ext2" ;
 		case FS_EXT3		: return "ext3" ;
 		case FS_EXT4		: return "ext4" ;

Modified: trunk/src/Win_GParted.cc
==============================================================================
--- trunk/src/Win_GParted.cc	(original)
+++ trunk/src/Win_GParted.cc	Mon Feb 23 20:22:30 2009
@@ -385,8 +385,9 @@
 
 	for ( unsigned int t =0; t < gparted_core .get_filesystems() .size() ; t++ )
 	{
-		//Skip luks, lvm2, and unknown because these are not file systems
-		if ( gparted_core .get_filesystems()[ t ] .filesystem == GParted::FS_LUKS ||
+		//Skip btrfs, luks, lvm2, and unknown because these are not file systems
+		if ( gparted_core .get_filesystems()[ t ] .filesystem == GParted::FS_BTRFS ||
+		     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]