[gparted] Also pass device_path into GParted_Core::is_busy() (#183)



commit f1920e306b10915120e6a6d0c1b0e557132a6787
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Fri Jan 7 08:53:52 2022 +0000

    Also pass device_path into GParted_Core::is_busy() (#183)
    
    Will use this extra parameter when determining if a device or partition
    containing bcache is busy or not.
    
    Closes #183 - Basic support for bcache

 include/GParted_Core.h |  2 +-
 src/GParted_Core.cc    | 27 ++++++++++++++-------------
 2 files changed, 15 insertions(+), 14 deletions(-)
---
diff --git a/include/GParted_Core.h b/include/GParted_Core.h
index 904b0923..484e8b18 100644
--- a/include/GParted_Core.h
+++ b/include/GParted_Core.h
@@ -99,7 +99,7 @@ private:
        void read_uuid( Partition & partition ) ;
        void set_mountpoints( Partition & partition );
        bool set_mountpoints_helper( Partition & partition, const Glib::ustring & path );
-       bool is_busy( FSType fstype, const Glib::ustring & path );
+       bool is_busy(const Glib::ustring& device_path, FSType fstype, const Glib::ustring& partition_path);
        void set_used_sectors( Partition & partition, PedDisk* lp_disk );
        void mounted_fs_set_used_sectors(Partition& partition);
 #ifdef HAVE_LIBPARTED_FS_RESIZE
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 343e7709..c881f062 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -860,16 +860,16 @@ void GParted_Core::set_device_partitions( Device & device, PedDevice* lp_device,
                                {
                                        //Try device_name + partition_number
                                        Glib::ustring dmraid_path = device .get_path() + Utils::num_to_str( 
lp_partition ->num ) ;
-                                       partition_is_busy = is_busy(fstype, dmraid_path);
+                                       partition_is_busy = is_busy(device.get_path(), fstype, dmraid_path);
 
                                        //Try device_name + p + partition_number
                                        dmraid_path = device .get_path() + "p" + Utils::num_to_str( 
lp_partition ->num ) ;
-                                       partition_is_busy |= is_busy(fstype, dmraid_path);
+                                       partition_is_busy |= is_busy(device.get_path(), fstype, dmraid_path);
                                }
                                else
 #endif
                                {
-                                       partition_is_busy = is_busy(fstype, partition_path);
+                                       partition_is_busy = is_busy(device.get_path(), fstype, 
partition_path);
                                }
 
                                if (fstype == FS_LUKS)
@@ -980,7 +980,7 @@ void GParted_Core::set_device_one_partition( Device & device, PedDevice * lp_dev
        device.partitions.clear();
 
        Glib::ustring path = lp_device->path;
-       bool partition_is_busy = is_busy( fstype, path );
+       bool partition_is_busy = is_busy(device.get_path(), fstype, path);
 
        Partition * partition_temp = NULL;
        if ( fstype == FS_LUKS )
@@ -1021,7 +1021,7 @@ void GParted_Core::set_luks_partition( PartitionLUKS & partition )
        Glib::ustring mapping_path = DEV_MAPPER_PATH + mapping.name;
        std::vector<Glib::ustring> detect_messages;
        FSType fstype = detect_filesystem_in_encryption_mapping(mapping_path, detect_messages);
-       bool fs_busy = is_busy( fstype, mapping_path );
+       bool fs_busy = is_busy(mapping_path, fstype, mapping_path);
 
        partition.set_luks( mapping_path,
                            fstype,
@@ -1556,8 +1556,9 @@ bool GParted_Core::set_mountpoints_helper( Partition & partition, const Glib::us
        return false;
 }
 
-//Report whether the partition is busy (mounted/active)
-bool GParted_Core::is_busy( FSType fstype, const Glib::ustring & path )
+
+// Report whether the partition is busy (mounted/active)
+bool GParted_Core::is_busy(const Glib::ustring& device_path, FSType fstype, const Glib::ustring& 
partition_path)
 {
        FileSystem * p_filesystem = NULL ;
        bool busy = false ;
@@ -1568,14 +1569,14 @@ bool GParted_Core::is_busy( FSType fstype, const Glib::ustring & path )
                {
                        case FS::GPARTED:
                                //Search GParted internal mounted partitions map
-                               busy = Mount_Info::is_dev_mounted( path );
+                               busy = Mount_Info::is_dev_mounted(partition_path);
                                break ;
 
                        case FS::EXTERNAL:
                                //Call file system specific method
                                p_filesystem = get_filesystem_object( fstype ) ;
                                if ( p_filesystem )
-                                       busy = p_filesystem -> is_busy( path ) ;
+                                       busy = p_filesystem -> is_busy(partition_path) ;
                                break;
 
                        default:
@@ -1588,12 +1589,12 @@ bool GParted_Core::is_busy( FSType fstype, const Glib::ustring & path )
 
                //Still search GParted internal mounted partitions map in case an
                //  unknown file system is mounted
-               busy = Mount_Info::is_dev_mounted( path );
+               busy = Mount_Info::is_dev_mounted(partition_path);
 
                // Custom checks for recognised but other not-supported file system types.
-               busy |= (fstype == FS_LINUX_SWRAID && SWRaid_Info::is_member_active(path));
-               busy |= (fstype == FS_ATARAID      && (SWRaid_Info::is_member_active(path) ||
-                                                      dmraid.is_member_active(path)         ));
+               busy |= (fstype == FS_LINUX_SWRAID && SWRaid_Info::is_member_active(partition_path));
+               busy |= (fstype == FS_ATARAID      && (SWRaid_Info::is_member_active(partition_path) ||
+                                                      dmraid.is_member_active(partition_path)         ));
        }
 
        return busy ;


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