Correct whole disk device file system format to cleared preview (#743181)

The preview of clearing a whole disk device file system was previewing
the same as formatting to all other file system types; as a cleared file
system spanning the whole disk device.  However when implemented this
removes all signatures on the disk so it actually becomes an unallocated
and unpartitioned device.  Make the preview match what happens in when
implemented.

GParted previously used mydevice.max_prims = -1 to represent an
unpartitioned device.  It is now represented as:

    mydevice.max_prims = 1
    mydevice.disktype  = _("unrecognized")
    mydevice.partitions[0].type         = TYPE_UNALLOCATED
    mydevice.partitions[0].whole_device = true
    mydevice.partitions[0].filesystem   = FS_UNALLOCATED

and the check for an unpartitioned device in Win_GParted.cc becomes:

    partitions[0].type == TYPE_UNALLOCATED && partitions[0].whole_device

Bug 743181 - Add unpartitioned drive read-write support
This commit is contained in:
Mike Fleetwood 2015-02-17 15:14:23 +00:00 committed by Curtis Gedak
parent 8607717b7b
commit 63f701033e
3 changed files with 21 additions and 6 deletions

View File

@ -385,7 +385,7 @@ void GParted_Core::set_devices_thread( std::vector<Device> * pdevices )
* disk device is unknown or not recognized.
*/
_("unrecognized") ;
temp_device.max_prims = -1;
temp_device.max_prims = 1;
Partition partition_temp;
partition_temp.Set_Unallocated( temp_device .get_path(),

View File

@ -32,7 +32,22 @@ OperationFormat::OperationFormat( const Device & device,
void OperationFormat::apply_to_visual( std::vector<Partition> & partitions )
{
if ( partition_original .inside_extended )
if ( partition_original.whole_device && partition_new.filesystem == FS_CLEARED )
{
// Make format to cleared whole disk device file system preview as
// unallocated device, matching what happens when implemented.
partitions.clear();
Partition temp_partition;
temp_partition.Set_Unallocated( device.get_path(),
true,
0LL,
device.length -1LL,
device.sector_size,
false );
partitions.push_back( temp_partition );
}
else if ( partition_original.inside_extended )
{
index_extended = find_index_extended( partitions ) ;

View File

@ -1718,8 +1718,8 @@ void Win_GParted::activate_copy()
void Win_GParted::activate_paste()
{
//if max_prims == -1 the current device has an unrecognised disklabel (see also GParted_Core::get_devices)
if ( devices [ current_device ] .max_prims == -1 )
// Unrecognised whole disk device (See GParted_Core::get_devices_threads(), "unrecognized")
if ( selected_partition.whole_device && selected_partition.type == TYPE_UNALLOCATED )
{
show_disklabel_unrecognized( devices [current_device ] .get_path() ) ;
return ;
@ -1822,8 +1822,8 @@ void Win_GParted::activate_paste()
void Win_GParted::activate_new()
{
//if max_prims == -1 the current device has an unrecognised disklabel (see also GParted_Core::get_devices)
if ( devices [ current_device ] .max_prims == -1 )
// Unrecognised whole disk device (See GParted_Core::get_devices_threads(), "unrecognized")
if ( selected_partition.whole_device && selected_partition.type == TYPE_UNALLOCATED )
{
show_disklabel_unrecognized( devices [current_device ] .get_path() ) ;
}