Make "loop" table appear as unknown whole device file system (#743181)

Previously GParted displayed a device containing the parted "loop"
partition table signature "GNU Parted Loopback 0" and nothing else, as
an unrecognised device.

Now make GParted display this as a virtual whole disk device partition
with unknown contents, complete with the unable to detect a file system
warning.  This change then allows a whole disk device file system to be
created with the following two steps:
1) Create "loop" partition table on a device;
2) Format to required file system.

GParted represents a whole disk device file system as:

    mydevice.max_prims = 1
    mydevice.disktype  = "none"
    mydevice.partitions[0].type         = TYPE_PRIMARY
    mydevice.partitions[0].whole_device = true
    mydevice.partitions[0].filesystem   = FS_EXT4  (example)

Now represents just Parted's "loop" signature as:

    mydevice.max_prims = 1
    mydevice.disktype  = "loop"
    mydevice.partitions[0].type         = TYPE_PRIMARY
    mydevice.partitions[0].whole_device = true
    mydevice.partitions[0].filesystem   = FS_UNKNOWN

And as before, an unpartitioned device 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

Bug 743181 - Add unpartitioned drive read-write support
This commit is contained in:
Mike Fleetwood 2015-02-06 15:36:31 +00:00 committed by Curtis Gedak
parent c01106c54e
commit 8607717b7b
1 changed files with 26 additions and 0 deletions

View File

@ -351,6 +351,32 @@ void GParted_Core::set_devices_thread( std::vector<Device> * pdevices )
set_mountpoints( temp_device.partitions ); set_mountpoints( temp_device.partitions );
set_used_sectors( temp_device.partitions, NULL ); set_used_sectors( temp_device.partitions, NULL );
} }
// Drive just containing libparted "loop" signature
// "GNU Parted Loopback 0" and nothing else
else if ( lp_disk && lp_disk->type && lp_disk->type->name &&
strcmp( lp_disk->type->name, "loop" ) == 0 )
{
temp_device.disktype = lp_disk->type->name;
temp_device.max_prims = 1;
// Create virtual partition covering the whole
// disk device with unknown contents
Partition partition_temp;
partition_temp.Set( temp_device.get_path(),
lp_device->path,
1,
TYPE_PRIMARY,
true,
FS_UNKNOWN,
0LL,
temp_device.length - 1LL,
temp_device.sector_size,
false,
false );
// Place unknown file system message in this partition
partition_temp.messages = messages;
temp_device.partitions.push_back( partition_temp );
}
else else
{ {
temp_device.disktype = temp_device.disktype =