[gparted] Add new "cleared" file system format (#688882)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Add new "cleared" file system format (#688882)
- Date: Mon, 25 Mar 2013 16:58:29 +0000 (UTC)
commit d4f68eb730ae2d2046c23b733c8ff44ceb7c9f0a
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Sat Dec 8 19:41:00 2012 +0000
Add new "cleared" file system format (#688882)
Add "cleared" to the bottom of list of file system formats available in
the Create new Partition dialog and in the Format to --> (file system
list) menu. This clears existing file system signatures in the newly
created partitions and existing partitions respectively.
Bug #688882 - Improve clearing of file system signatures
include/Utils.h | 53 ++++++++++++++++++++++---------------------
src/DialogFeatures.cc | 8 +++---
src/Dialog_Partition_New.cc | 22 ++++++++++++-----
src/GParted_Core.cc | 19 ++++++++++++---
src/Utils.cc | 7 +++++
src/Win_GParted.cc | 9 +++++--
6 files changed, 74 insertions(+), 44 deletions(-)
---
diff --git a/include/Utils.h b/include/Utils.h
index 57a7014..877327d 100644
--- a/include/Utils.h
+++ b/include/Utils.h
@@ -59,32 +59,33 @@ enum FILESYSTEM
FS_UNALLOCATED = 0,
FS_UNKNOWN = 1,
FS_UNFORMATTED = 2,
- FS_EXTENDED = 3,
-
- FS_BTRFS = 4,
- FS_EXFAT = 5, /* Also known as fat64 */
- FS_EXT2 = 6,
- FS_EXT3 = 7,
- FS_EXT4 = 8,
- FS_F2FS = 9,
- FS_FAT16 = 10,
- FS_FAT32 = 11,
- FS_HFS = 12,
- FS_HFSPLUS = 13,
- FS_JFS = 14,
- FS_LINUX_SWAP = 15,
- FS_LVM2_PV = 16,
- FS_NILFS2 = 17,
- FS_NTFS = 18,
- FS_REISER4 = 19,
- FS_REISERFS = 20,
- FS_UFS = 21,
- FS_XFS = 22,
-
- FS_USED = 23,
- FS_UNUSED = 24,
-
- FS_LUKS = 25
+ FS_CLEARED = 3, //Clear existing file system signatures
+ FS_EXTENDED = 4,
+
+ FS_BTRFS = 5,
+ FS_EXFAT = 6, /* Also known as fat64 */
+ FS_EXT2 = 7,
+ FS_EXT3 = 8,
+ FS_EXT4 = 9,
+ FS_F2FS = 10,
+ FS_FAT16 = 11,
+ FS_FAT32 = 12,
+ FS_HFS = 13,
+ FS_HFSPLUS = 14,
+ FS_JFS = 15,
+ FS_LINUX_SWAP = 16,
+ FS_LVM2_PV = 17,
+ FS_NILFS2 = 18,
+ FS_NTFS = 19,
+ FS_REISER4 = 20,
+ FS_REISERFS = 21,
+ FS_UFS = 22,
+ FS_XFS = 23,
+
+ FS_USED = 24,
+ FS_UNUSED = 25,
+
+ FS_LUKS = 26
} ;
enum SIZE_UNIT
diff --git a/src/DialogFeatures.cc b/src/DialogFeatures.cc
index cc51f44..92d8f6f 100644
--- a/src/DialogFeatures.cc
+++ b/src/DialogFeatures.cc
@@ -123,10 +123,10 @@ void DialogFeatures::load_filesystems( const std::vector<FS> & FILESYSTEMS )
//fill the features chart with valid file systems
for ( unsigned short t = 0; t < FILESYSTEMS .size() ; t++ )
{
- //Skip luks and unknown because these are not file systems
- if (
- FILESYSTEMS[ t ] .filesystem == GParted::FS_LUKS ||
- FILESYSTEMS[ t ] .filesystem == GParted::FS_UNKNOWN
+ //Skip unknown, cleared and luks because these are not file systems
+ if ( FILESYSTEMS[ t ] .filesystem == FS_UNKNOWN
+ || FILESYSTEMS[ t ] .filesystem == FS_CLEARED
+ || FILESYSTEMS[ t ] .filesystem == FS_LUKS
)
continue ;
show_filesystem( FILESYSTEMS[ t ] ) ;
diff --git a/src/Dialog_Partition_New.cc b/src/Dialog_Partition_New.cc
index 43368a9..69dbfb0 100644
--- a/src/Dialog_Partition_New.cc
+++ b/src/Dialog_Partition_New.cc
@@ -42,27 +42,35 @@ void Dialog_Partition_New::Set_Data( const Partition & partition,
this ->new_count = new_count;
this ->selected_partition = partition;
- //copy GParted FILESYSTEMS
+ //Copy GParted FILESYSTEMS vector and re-order it to all real file systems first
+ // followed by FS_CLEARED, FS_UNFORMATTED and finally FS_EXTENDED. This decides
+ // the order of items in the file system menu, built by Build_Filesystems_Menu().
this ->FILESYSTEMS = FILESYSTEMS ;
- //remove all non-valid file systems
+ //... remove all non-valid file systems
std::vector< FS >::iterator f ;
for ( f = this->FILESYSTEMS .begin(); f != this->FILESYSTEMS .end(); f++ )
{
- if ( f ->filesystem == GParted::FS_UNKNOWN
- || f ->filesystem == GParted::FS_LUKS
+ if ( f ->filesystem == FS_UNKNOWN
+ || f ->filesystem == FS_CLEARED
+ || f ->filesystem == FS_LUKS
)
//Compensate for subsequent 'f++' ...
f = this ->FILESYSTEMS .erase( f ) - 1 ;
}
FS fs_tmp ;
- //add FS_UNFORMATTED
+ //... add FS_CLEARED
+ fs_tmp .filesystem = FS_CLEARED ;
+ fs_tmp .create = FS::GPARTED ;
+ this ->FILESYSTEMS .push_back( fs_tmp ) ;
+
+ //... add FS_UNFORMATTED
fs_tmp .filesystem = GParted::FS_UNFORMATTED ;
fs_tmp .create = FS::GPARTED ;
this ->FILESYSTEMS .push_back( fs_tmp ) ;
- //add FS_EXTENDED
+ //... finally add FS_EXTENDED
fs_tmp = FS();
fs_tmp .filesystem = GParted::FS_EXTENDED ;
fs_tmp .create = GParted::FS::NONE ;
@@ -327,7 +335,7 @@ void Dialog_Partition_New::Build_Filesystems_Menu( bool only_unformatted )
//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
if( FILESYSTEMS[ t ] .filesystem == GParted::FS_EXTENDED )
continue ;
menu_filesystem .items() .push_back(
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index cc48a91..fe5bd5a 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -97,6 +97,8 @@ void GParted_Core::find_supported_filesystems()
FILESYSTEM_MAP .clear() ;
+ FILESYSTEM_MAP[ FS_UNKNOWN ] = NULL ;
+ FILESYSTEM_MAP[ FS_CLEARED ] = NULL ;
FILESYSTEM_MAP[ FS_BTRFS ] = new btrfs() ;
FILESYSTEM_MAP[ FS_EXFAT ] = new exfat() ;
FILESYSTEM_MAP[ FS_EXT2 ] = new ext2( FS_EXT2 ) ;
@@ -117,8 +119,12 @@ void GParted_Core::find_supported_filesystems()
FILESYSTEM_MAP[ FS_UFS ] = new ufs() ;
FILESYSTEM_MAP[ FS_XFS ] = new xfs() ;
FILESYSTEM_MAP[ FS_LUKS ] = NULL ;
- FILESYSTEM_MAP[ FS_UNKNOWN ] = NULL ;
+ //Iteration of std::map is ordered according to operator< of the key.
+ // Hence the FILESYSTEMS vector is constructed in FILESYSTEM enum
+ // order: FS_UNKNOWN, FS_CLEARED, FS_BTRFS, ..., FS_XFS, FS_LUKS
+ // which ultimately controls the default order of file systems in menus
+ // and dialogs.
FILESYSTEMS .clear() ;
FS fs_notsupp;
@@ -1699,6 +1705,8 @@ bool GParted_Core::create( const Device & device, Partition & new_partition, Ope
{
if ( new_partition .filesystem == GParted::FS_UNFORMATTED )
return true ;
+ else if ( new_partition .filesystem == FS_CLEARED )
+ return erase_filesystem_signatures( new_partition, operationdetail ) ;
else
return erase_filesystem_signatures( new_partition, operationdetail )
&& set_partition_type( new_partition, operationdetail )
@@ -1846,9 +1854,12 @@ bool GParted_Core::create_filesystem( const Partition & partition, OperationDeta
bool GParted_Core::format( const Partition & partition, OperationDetail & operationdetail )
{
- return erase_filesystem_signatures( partition, operationdetail )
- && set_partition_type( partition, operationdetail )
- && create_filesystem( partition, operationdetail ) ;
+ if ( partition .filesystem == FS_CLEARED )
+ return erase_filesystem_signatures( partition, operationdetail ) ;
+ else
+ return erase_filesystem_signatures( partition, operationdetail )
+ && set_partition_type( partition, operationdetail )
+ && create_filesystem( partition, operationdetail ) ;
}
bool GParted_Core::Delete( const Partition & partition, OperationDetail & operationdetail )
diff --git a/src/Utils.cc b/src/Utils.cc
index 545df82..cc8545b 100644
--- a/src/Utils.cc
+++ b/src/Utils.cc
@@ -82,6 +82,7 @@ Glib::ustring Utils::get_color( FILESYSTEM filesystem )
case FS_UNALLOCATED : return "#A9A9A9" ; // ~ medium grey
case FS_UNKNOWN : return "#000000" ; //black
case FS_UNFORMATTED : return "#000000" ; //black
+ case FS_CLEARED : return "#000000" ; //black
case FS_EXTENDED : return "#7DFCFE" ; // ~ light blue
case FS_BTRFS : return "#FF9955" ; //orange
case FS_EXT2 : return "#9DB8D2" ; //blue hilight
@@ -203,6 +204,12 @@ Glib::ustring Utils::get_filesystem_string( FILESYSTEM filesystem )
* be formatted with a known file system by GParted.
*/
_("unformatted") ;
+ case FS_CLEARED : return
+ /* TO TRANSLATORS: cleared
+ * means that all file system signatures in the partition
+ * will be cleared by GParted.
+ */
+ _("cleared") ;
case FS_EXTENDED : return "extended" ;
case FS_BTRFS : return "btrfs" ;
case FS_EXT2 : return "ext2" ;
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index cd44b8e..f8a3418 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -414,14 +414,17 @@ Gtk::Menu * Win_GParted::create_format_menu()
for ( unsigned int t = 0 ; t < fss .size() ; t++ )
{
- //Skip luks and unknown because these are not file systems
- if ( fss[ t ] .filesystem == FS_LUKS
- || fss[ t ] .filesystem == FS_UNKNOWN
+ //Skip unknown, cleared and luks because these are not file systems
+ if ( fss[ t ] .filesystem == FS_UNKNOWN
+ || fss[ t ] .filesystem == FS_CLEARED
+ || fss[ t ] .filesystem == FS_LUKS
)
continue ;
create_format_menu_add_item( fss[ t ] .filesystem, fss[ t ] .create ) ;
}
+ //Add cleared at the end of the list
+ create_format_menu_add_item( FS_CLEARED, true ) ;
return menu ;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]