[gparted] Fix detection of busy status of extended partitions (#712533)



commit ad63ede421ab97c3cc4b4c8f74f2dcdc04e77785
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Fri Nov 22 13:36:02 2013 +0000

    Fix detection of busy status of extended partitions (#712533)
    
    GParted doesn't report extended partitions as busy if it contains only
    busy LVM2 PV or SWRAID logical partitions.  Libparted's
    ped_partition_is_busy() only detects mounted file systems and swap space
    as busy, not active LVM2 PVs or SWRAID members.  This is as of libparted
    3.1 and earlier.
    
    Fix by determining the busy status of an extended partition based solely
    on the busy status of the logical partitions it contains.  This makes it
    unnecessary to check for mounted DMRAID logical partitions or call
    ped_partition_is_busy() for extended partitions.
    
    Bug #712533 - Partitions not detected as busy inside Software RAID on
                  some distros

 src/GParted_Core.cc |   40 ++++++++++++++--------------------------
 1 files changed, 14 insertions(+), 26 deletions(-)
---
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 67d076a..83609c1 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -1083,31 +1083,6 @@ void GParted_Core::set_device_partitions( Device & device, PedDevice* lp_device,
                                break ;
                        
                        case PED_PARTITION_EXTENDED:
-#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"
-                               //  This mismatch causes incorrect identification of busy partitions in 
ped_partition_is_busy(). 
-                               if ( dmraid .is_dmraid_device( device .get_path() ) )
-                               {
-                                       for ( unsigned int k = 5; k < 255; k++ )
-                                       {
-                                               //Try device_name + [5 to 255]
-                                               iter_mp = mount_info .find( device .get_path() + 
Utils::num_to_str( k ) ) ;
-                                               if ( iter_mp != mount_info .end() )
-                                                       partition_is_busy = true ;
-                                               //Try device_name + p + [5 to 255]
-                                               iter_mp = mount_info .find( device .get_path() + "p" + 
Utils::num_to_str( k ) ) ;
-                                               if ( iter_mp != mount_info .end() )
-                                                       partition_is_busy = true ;
-                                       }
-                               }
-                               else
-#endif
-                               {
-                                       //For extended partitions only use libparted to determine if it's 
busy.
-                                       partition_is_busy = ped_partition_is_busy( lp_partition ) ;
-                               }
-
                                partition_temp .Set( device .get_path(),
                                                     partition_path, 
                                                     lp_partition ->num,
@@ -1117,7 +1092,7 @@ void GParted_Core::set_device_partitions( Device & device, PedDevice* lp_device,
                                                     lp_partition ->geom .end,
                                                     device .sector_size,
                                                     false,
-                                                    partition_is_busy ) ;
+                                                    false ) ;
 
                                partition_temp .add_paths( pp_info .get_alternate_paths( partition_temp 
.get_path() ) ) ;
                                set_flags( partition_temp, lp_partition ) ;
@@ -1171,6 +1146,7 @@ void GParted_Core::set_device_partitions( Device & device, PedDevice* lp_device,
        }
 
        if ( EXT_INDEX > -1 )
+       {
                insert_unallocated( device .get_path(),
                                    device .partitions[ EXT_INDEX ] .logicals,
                                    device .partitions[ EXT_INDEX ] .sector_start,
@@ -1178,6 +1154,18 @@ void GParted_Core::set_device_partitions( Device & device, PedDevice* lp_device,
                                    device .sector_size,
                                    true ) ;
 
+               //Set busy status of extended partition if and only if
+               //  there is at least one busy logical partition.
+               for ( unsigned int t = 0 ; t < device .partitions[ EXT_INDEX ] .logicals .size() ; t ++ )
+               {
+                       if ( device .partitions[ EXT_INDEX ] .logicals[ t ] .busy )
+                       {
+                               device .partitions[ EXT_INDEX ] .busy = true ;
+                               break ;
+                       }
+               }
+       }
+
        insert_unallocated( device .get_path(), device .partitions, 0, device .length -1, device 
.sector_size, false ) ; 
 }
 


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