Enable operations on whole disk device virtual partitions (#743181)

Enable operations on whole disk devices containing any recognised file
system.

The new partition operation on an empty whole disk device continues to
display the "No partition table found on device /dev/DEVICE" information
dialog.

Specifically unsupported operations:

 *  Delete -

    Deletion of a partition only involves removal of the entry in the
    partition table leaving the file system intact on the disk.  However
    this doesn't work for a whole disk device file system.  Instead the
    file system signatures would have to be erased which is much more
    destructive and virtually impossible to undo.  Therefore don't
    implement whole disk device file system deletion.  Alternatives are
    to format the file system to cleared or create a partition table on
    the device.  Both of these imply overwriting the existing data and
    set the expectation that undo is not possible.

 *  Manage flags -

    There's no partition table, so there's no partition, so there's no
    flags.

Resize/Move operation is being supported so that a whole disk device
file system can be resized to handle devices which can be resize, such
as those from SANs or Linux Software RAID arrays.  The start of the file
system must remain fixed so move won't be allowed.

So far only simple operations work if they don't need libparted support
at all [1], or only need libparted support for the calibrate step AND
the file system on the whole disk device is recognised by libparted [2].
(Needs libparted to provide a "loop" partition, hence the recognition
requirement, so that the calibrate step can successfully read the
virtual "loop" partition table.  Doesn't matter whether it's an old
version of libparted and it gets the name of the device wrong as GParted
is already using the whole disk device name anyway).

[1] Operations not needing any libparted support:
    Mount on, Unmount, Swapon, Swapoff, Activate and Deactivate

[2] Operations only needing libparted support for the calibrate step:
    Check, Label, New UUID

Bug 743181 - Add unpartitioned drive read-write support
This commit is contained in:
Mike Fleetwood 2014-12-31 12:41:03 +00:00 committed by Curtis Gedak
parent 5098744f9a
commit 6c333f845c
1 changed files with 8 additions and 8 deletions

View File

@ -991,11 +991,6 @@ void Win_GParted::set_valid_operations()
: CTEXT_ACTIVATE_FILESYSTEM )
) ;
// No manipulation operations are currently supported on file systems using the
// whole disk device.
if ( devices[current_device].disktype == "none" )
return;
//Only permit mount/unmount, swapon/swapoff, activate/deactivate if action is available
if ( selected_partition .status == GParted::STAT_REAL
&& selected_partition .type != GParted::TYPE_EXTENDED
@ -1024,7 +1019,9 @@ void Win_GParted::set_valid_operations()
allow_toggle_busy_state( true ) ;
// Manage flags
if ( selected_partition.type != TYPE_UNALLOCATED && selected_partition.status == STAT_REAL )
if ( selected_partition.type != TYPE_UNALLOCATED &&
selected_partition.status == STAT_REAL &&
! selected_partition.whole_device )
allow_manage_flags( true );
#ifdef ENABLE_ONLINE_RESIZE
@ -1115,9 +1112,12 @@ void Win_GParted::set_valid_operations()
//PRIMARY and LOGICAL
if ( selected_partition .type == GParted::TYPE_PRIMARY || selected_partition .type == GParted::TYPE_LOGICAL )
{
allow_delete( true ) ;
allow_format( true ) ;
// only allow deletion of partitions within a partition table
if ( ! selected_partition.whole_device )
allow_delete( true );
//find out if resizing/moving is possible
if ( (fs .grow || fs .shrink || fs .move ) && ! devices[ current_device ] .readonly )
allow_resize( true ) ;