[gparted/ataraid: 17/17] Stop requesting partition paths of free space and metadata



commit 047a2481bb4da536e68281b9d637961c24e71315
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Mon Nov 25 07:34:11 2019 +0000

    Stop requesting partition paths of free space and metadata
    
    In GParted_Core::set_device_partitions() the partition path is being
    queried from libparted.  However this is done before the switch
    statement on the type of the partition, so is called for all libparted
    partition objects including PED_PARTITION_FREESPACE and
    PED_PARTITION_METADATA ones.  As libparted numbers these partition
    objects as -1, it returns paths like "/dev/sda-1".
    
    Additionally when using GParted, with it's default DMRaid handling, on a
    dmraid started array this results in paths like
    "/dev/mapper/isw_ecccdhhiga_MyArray-1" being passed to
    is_dmraid_device() and make_path_dmraid_compatible().  Fortunately
    make_path_dmraid_compatible() does nothing and returns the same name.
    Call chain looks like:
    
        GParted_Core::set_device_partitions()
          get_partition_path(lp_partition)
            // where:
            // lp_partition->disk->dev->path = "/dev/mapper/isw_ecccdhhiga_MyArray"
            // lp_partition->type == PED_PARTITION_FREESPACE |
            //                       PED_PARTITION_METADATA
            //              ->num == -1
            ped_partition_get_path(lp_partition)
              return "/dev/mapper/isw_ecccdhhiga_MyArray-1"
            dmraid.is_dmraid_supported()
            dmraid.is_dmraid_device("/dev/mapper/isw_ecccdhhiga_MyArray-1")
              return true
            dmraid.make_path_dmraid_compatible("/dev/mapper/isw_ecccdhhiga_MyArray-1")
              return "/dev/mapper/isw_ecccdhhiga_MyArray-1"
    
    Fix by moving the get_partition_path() call inside the switch statement
    so that it is only called for PED_PARTITION_NORMAL,
    PED_PARTITION_LOGICAL and PED_PARTITION_EXTENDED partition types.
    
    Relevant commits:
    *   53c49349f71693873805e87856b4c56f2860e6d8
        Simplify logic in set_device_partitions method
    
    *   81986c0990eef65593ef23397074cf61cdca415f
        Ensure partition path name is compatible with dmraid (#622217)

 src/GParted_Core.cc | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 8b7ed39e..cfaa20eb 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -817,9 +817,7 @@ void GParted_Core::set_device_partitions( Device & device, PedDevice* lp_device,
                bool partition_is_busy = false ;
                FSType filesystem;
                std::vector<Glib::ustring> detect_messages;
-
-               //Retrieve partition path
-               Glib::ustring partition_path = get_partition_path( lp_partition );
+               Glib::ustring partition_path;
 
                // NOTE: lp_partition->type bit field
                // lp_partition->type is a bit field using enumerated names for each bit.
@@ -840,6 +838,8 @@ void GParted_Core::set_device_partitions( Device & device, PedDevice* lp_device,
                        case PED_PARTITION_NORMAL:
                        case PED_PARTITION_LOGICAL:
                                filesystem = detect_filesystem( lp_device, lp_partition, detect_messages );
+                               partition_path = get_partition_path(lp_partition);
+
 #ifndef USE_LIBPARTED_DMRAID
                                //Handle dmraid devices differently because the minor number might not
                                //  match the last number of the partition filename as shown by "ls -l 
/dev/mapper"
@@ -886,6 +886,8 @@ void GParted_Core::set_device_partitions( Device & device, PedDevice* lp_device,
                                break ;
                        
                        case PED_PARTITION_EXTENDED:
+                               partition_path = get_partition_path(lp_partition);
+
                                partition_temp = new Partition();
                                partition_temp->Set( device.get_path(),
                                                     partition_path,


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