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
This commit is contained in:
parent
bc5b57ab35
commit
d4f68eb730
|
@ -59,32 +59,33 @@ enum FILESYSTEM
|
||||||
FS_UNALLOCATED = 0,
|
FS_UNALLOCATED = 0,
|
||||||
FS_UNKNOWN = 1,
|
FS_UNKNOWN = 1,
|
||||||
FS_UNFORMATTED = 2,
|
FS_UNFORMATTED = 2,
|
||||||
FS_EXTENDED = 3,
|
FS_CLEARED = 3, //Clear existing file system signatures
|
||||||
|
FS_EXTENDED = 4,
|
||||||
|
|
||||||
FS_BTRFS = 4,
|
FS_BTRFS = 5,
|
||||||
FS_EXFAT = 5, /* Also known as fat64 */
|
FS_EXFAT = 6, /* Also known as fat64 */
|
||||||
FS_EXT2 = 6,
|
FS_EXT2 = 7,
|
||||||
FS_EXT3 = 7,
|
FS_EXT3 = 8,
|
||||||
FS_EXT4 = 8,
|
FS_EXT4 = 9,
|
||||||
FS_F2FS = 9,
|
FS_F2FS = 10,
|
||||||
FS_FAT16 = 10,
|
FS_FAT16 = 11,
|
||||||
FS_FAT32 = 11,
|
FS_FAT32 = 12,
|
||||||
FS_HFS = 12,
|
FS_HFS = 13,
|
||||||
FS_HFSPLUS = 13,
|
FS_HFSPLUS = 14,
|
||||||
FS_JFS = 14,
|
FS_JFS = 15,
|
||||||
FS_LINUX_SWAP = 15,
|
FS_LINUX_SWAP = 16,
|
||||||
FS_LVM2_PV = 16,
|
FS_LVM2_PV = 17,
|
||||||
FS_NILFS2 = 17,
|
FS_NILFS2 = 18,
|
||||||
FS_NTFS = 18,
|
FS_NTFS = 19,
|
||||||
FS_REISER4 = 19,
|
FS_REISER4 = 20,
|
||||||
FS_REISERFS = 20,
|
FS_REISERFS = 21,
|
||||||
FS_UFS = 21,
|
FS_UFS = 22,
|
||||||
FS_XFS = 22,
|
FS_XFS = 23,
|
||||||
|
|
||||||
FS_USED = 23,
|
FS_USED = 24,
|
||||||
FS_UNUSED = 24,
|
FS_UNUSED = 25,
|
||||||
|
|
||||||
FS_LUKS = 25
|
FS_LUKS = 26
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
enum SIZE_UNIT
|
enum SIZE_UNIT
|
||||||
|
|
|
@ -123,10 +123,10 @@ void DialogFeatures::load_filesystems( const std::vector<FS> & FILESYSTEMS )
|
||||||
//fill the features chart with valid file systems
|
//fill the features chart with valid file systems
|
||||||
for ( unsigned short t = 0; t < FILESYSTEMS .size() ; t++ )
|
for ( unsigned short t = 0; t < FILESYSTEMS .size() ; t++ )
|
||||||
{
|
{
|
||||||
//Skip luks and unknown because these are not file systems
|
//Skip unknown, cleared and luks because these are not file systems
|
||||||
if (
|
if ( FILESYSTEMS[ t ] .filesystem == FS_UNKNOWN
|
||||||
FILESYSTEMS[ t ] .filesystem == GParted::FS_LUKS ||
|
|| FILESYSTEMS[ t ] .filesystem == FS_CLEARED
|
||||||
FILESYSTEMS[ t ] .filesystem == GParted::FS_UNKNOWN
|
|| FILESYSTEMS[ t ] .filesystem == FS_LUKS
|
||||||
)
|
)
|
||||||
continue ;
|
continue ;
|
||||||
show_filesystem( FILESYSTEMS[ t ] ) ;
|
show_filesystem( FILESYSTEMS[ t ] ) ;
|
||||||
|
|
|
@ -42,27 +42,35 @@ void Dialog_Partition_New::Set_Data( const Partition & partition,
|
||||||
this ->new_count = new_count;
|
this ->new_count = new_count;
|
||||||
this ->selected_partition = partition;
|
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 ;
|
this ->FILESYSTEMS = FILESYSTEMS ;
|
||||||
|
|
||||||
//remove all non-valid file systems
|
//... remove all non-valid file systems
|
||||||
std::vector< FS >::iterator f ;
|
std::vector< FS >::iterator f ;
|
||||||
for ( f = this->FILESYSTEMS .begin(); f != this->FILESYSTEMS .end(); f++ )
|
for ( f = this->FILESYSTEMS .begin(); f != this->FILESYSTEMS .end(); f++ )
|
||||||
{
|
{
|
||||||
if ( f ->filesystem == GParted::FS_UNKNOWN
|
if ( f ->filesystem == FS_UNKNOWN
|
||||||
|| f ->filesystem == GParted::FS_LUKS
|
|| f ->filesystem == FS_CLEARED
|
||||||
|
|| f ->filesystem == FS_LUKS
|
||||||
)
|
)
|
||||||
//Compensate for subsequent 'f++' ...
|
//Compensate for subsequent 'f++' ...
|
||||||
f = this ->FILESYSTEMS .erase( f ) - 1 ;
|
f = this ->FILESYSTEMS .erase( f ) - 1 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
FS fs_tmp ;
|
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 .filesystem = GParted::FS_UNFORMATTED ;
|
||||||
fs_tmp .create = FS::GPARTED ;
|
fs_tmp .create = FS::GPARTED ;
|
||||||
this ->FILESYSTEMS .push_back( fs_tmp ) ;
|
this ->FILESYSTEMS .push_back( fs_tmp ) ;
|
||||||
|
|
||||||
//add FS_EXTENDED
|
//... finally add FS_EXTENDED
|
||||||
fs_tmp = FS();
|
fs_tmp = FS();
|
||||||
fs_tmp .filesystem = GParted::FS_EXTENDED ;
|
fs_tmp .filesystem = GParted::FS_EXTENDED ;
|
||||||
fs_tmp .create = GParted::FS::NONE ;
|
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)
|
//fill the file system menu with the file systems (except for extended)
|
||||||
for ( unsigned int t = 0 ; t < FILESYSTEMS .size( ) ; t++ )
|
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 )
|
if( FILESYSTEMS[ t ] .filesystem == GParted::FS_EXTENDED )
|
||||||
continue ;
|
continue ;
|
||||||
menu_filesystem .items() .push_back(
|
menu_filesystem .items() .push_back(
|
||||||
|
|
|
@ -97,6 +97,8 @@ void GParted_Core::find_supported_filesystems()
|
||||||
|
|
||||||
FILESYSTEM_MAP .clear() ;
|
FILESYSTEM_MAP .clear() ;
|
||||||
|
|
||||||
|
FILESYSTEM_MAP[ FS_UNKNOWN ] = NULL ;
|
||||||
|
FILESYSTEM_MAP[ FS_CLEARED ] = NULL ;
|
||||||
FILESYSTEM_MAP[ FS_BTRFS ] = new btrfs() ;
|
FILESYSTEM_MAP[ FS_BTRFS ] = new btrfs() ;
|
||||||
FILESYSTEM_MAP[ FS_EXFAT ] = new exfat() ;
|
FILESYSTEM_MAP[ FS_EXFAT ] = new exfat() ;
|
||||||
FILESYSTEM_MAP[ FS_EXT2 ] = new ext2( FS_EXT2 ) ;
|
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_UFS ] = new ufs() ;
|
||||||
FILESYSTEM_MAP[ FS_XFS ] = new xfs() ;
|
FILESYSTEM_MAP[ FS_XFS ] = new xfs() ;
|
||||||
FILESYSTEM_MAP[ FS_LUKS ] = NULL ;
|
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() ;
|
FILESYSTEMS .clear() ;
|
||||||
|
|
||||||
FS fs_notsupp;
|
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 )
|
if ( new_partition .filesystem == GParted::FS_UNFORMATTED )
|
||||||
return true ;
|
return true ;
|
||||||
|
else if ( new_partition .filesystem == FS_CLEARED )
|
||||||
|
return erase_filesystem_signatures( new_partition, operationdetail ) ;
|
||||||
else
|
else
|
||||||
return erase_filesystem_signatures( new_partition, operationdetail )
|
return erase_filesystem_signatures( new_partition, operationdetail )
|
||||||
&& set_partition_type( new_partition, operationdetail )
|
&& set_partition_type( new_partition, operationdetail )
|
||||||
|
@ -1846,6 +1854,9 @@ bool GParted_Core::create_filesystem( const Partition & partition, OperationDeta
|
||||||
|
|
||||||
bool GParted_Core::format( const Partition & partition, OperationDetail & operationdetail )
|
bool GParted_Core::format( const Partition & partition, OperationDetail & operationdetail )
|
||||||
{
|
{
|
||||||
|
if ( partition .filesystem == FS_CLEARED )
|
||||||
|
return erase_filesystem_signatures( partition, operationdetail ) ;
|
||||||
|
else
|
||||||
return erase_filesystem_signatures( partition, operationdetail )
|
return erase_filesystem_signatures( partition, operationdetail )
|
||||||
&& set_partition_type( partition, operationdetail )
|
&& set_partition_type( partition, operationdetail )
|
||||||
&& create_filesystem( partition, operationdetail ) ;
|
&& create_filesystem( partition, operationdetail ) ;
|
||||||
|
|
|
@ -82,6 +82,7 @@ Glib::ustring Utils::get_color( FILESYSTEM filesystem )
|
||||||
case FS_UNALLOCATED : return "#A9A9A9" ; // ~ medium grey
|
case FS_UNALLOCATED : return "#A9A9A9" ; // ~ medium grey
|
||||||
case FS_UNKNOWN : return "#000000" ; //black
|
case FS_UNKNOWN : return "#000000" ; //black
|
||||||
case FS_UNFORMATTED : return "#000000" ; //black
|
case FS_UNFORMATTED : return "#000000" ; //black
|
||||||
|
case FS_CLEARED : return "#000000" ; //black
|
||||||
case FS_EXTENDED : return "#7DFCFE" ; // ~ light blue
|
case FS_EXTENDED : return "#7DFCFE" ; // ~ light blue
|
||||||
case FS_BTRFS : return "#FF9955" ; //orange
|
case FS_BTRFS : return "#FF9955" ; //orange
|
||||||
case FS_EXT2 : return "#9DB8D2" ; //blue hilight
|
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.
|
* be formatted with a known file system by GParted.
|
||||||
*/
|
*/
|
||||||
_("unformatted") ;
|
_("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_EXTENDED : return "extended" ;
|
||||||
case FS_BTRFS : return "btrfs" ;
|
case FS_BTRFS : return "btrfs" ;
|
||||||
case FS_EXT2 : return "ext2" ;
|
case FS_EXT2 : return "ext2" ;
|
||||||
|
|
|
@ -414,14 +414,17 @@ Gtk::Menu * Win_GParted::create_format_menu()
|
||||||
|
|
||||||
for ( unsigned int t = 0 ; t < fss .size() ; t++ )
|
for ( unsigned int t = 0 ; t < fss .size() ; t++ )
|
||||||
{
|
{
|
||||||
//Skip luks and unknown because these are not file systems
|
//Skip unknown, cleared and luks because these are not file systems
|
||||||
if ( fss[ t ] .filesystem == FS_LUKS
|
if ( fss[ t ] .filesystem == FS_UNKNOWN
|
||||||
|| fss[ t ] .filesystem == FS_UNKNOWN
|
|| fss[ t ] .filesystem == FS_CLEARED
|
||||||
|
|| fss[ t ] .filesystem == FS_LUKS
|
||||||
)
|
)
|
||||||
continue ;
|
continue ;
|
||||||
|
|
||||||
create_format_menu_add_item( fss[ t ] .filesystem, fss[ t ] .create ) ;
|
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 ;
|
return menu ;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue