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



commit 8607717b7b756d38f6e6716c71f8973306217081
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Fri Feb 6 15:36:31 2015 +0000

    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

 src/GParted_Core.cc |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 9b333d2..f3963af 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -351,6 +351,32 @@ void GParted_Core::set_devices_thread( std::vector<Device> * pdevices )
                                        set_mountpoints( temp_device.partitions );
                                        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
                                {
                                        temp_device.disktype =


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]