[gparted] Overload is_dev_mounted() function (#767842)



commit e4a8530b1428bbd991d4e5b626377efc287e12b3
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Sun Jul 3 13:25:57 2016 +0100

    Overload is_dev_mounted() function (#767842)
    
    Small optimisation which avoids constructing an extra BlockSpecial
    object when determining if a btrfs member is mounted.  Rather than
    extracting the name from the BlockSpecial object in
    btrfs::get_mount_device() and re-constructing another BlockSpecial
    object from that name in GParted_Core::is_dev_mounted(), pass the
    BlockSpecial object directly.
    
    Bug 767842 - File system usage missing when tools report alternate block
                 device names

 include/GParted_Core.h |    1 +
 src/GParted_Core.cc    |   10 ++++++++--
 src/btrfs.cc           |    2 +-
 3 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/include/GParted_Core.h b/include/GParted_Core.h
index 61a65bd..ce6490d 100644
--- a/include/GParted_Core.h
+++ b/include/GParted_Core.h
@@ -61,6 +61,7 @@ public:
        const FS & get_fs( GParted::FILESYSTEM filesystem ) const ;
        static std::vector<Glib::ustring> get_disklabeltypes() ;
        static bool is_dev_mounted( const Glib::ustring & path ) ;
+       static bool is_dev_mounted( const BlockSpecial & bs );
        static std::vector<Glib::ustring> get_all_mountpoints() ;
        std::map<Glib::ustring, bool> get_available_flags( const Partition & partition ) ;
        Glib::ustring get_libparted_version() ;
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index ed035f2..6d7bc9d 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -970,8 +970,14 @@ std::vector<Glib::ustring> GParted_Core::get_disklabeltypes()
 //Return whether the device path, such as /dev/sda3, is mounted or not
 bool GParted_Core::is_dev_mounted( const Glib::ustring & path )
 {
-       MountMapping::iterator iter_mp = mount_info.find( BlockSpecial( path ) );
-       return iter_mp != mount_info .end() ;
+       return is_dev_mounted( BlockSpecial( path ) );
+}
+
+// Return whether the BlockSpecial object, such as {"/dev/sda3", 8, 3}, is mounted or not
+bool GParted_Core::is_dev_mounted( const BlockSpecial & bs )
+{
+       MountMapping::const_iterator iter_mp = mount_info.find( bs );
+       return iter_mp != mount_info.end();
 }
 
 std::vector<Glib::ustring> GParted_Core::get_all_mountpoints() 
diff --git a/src/btrfs.cc b/src/btrfs.cc
index 60e6551..abee7f0 100644
--- a/src/btrfs.cc
+++ b/src/btrfs.cc
@@ -462,7 +462,7 @@ Glib::ustring btrfs::get_mount_device( const Glib::ustring & path )
        }
 
        for ( unsigned int i = 0 ; i < btrfs_dev .members .size() ; i ++ )
-               if ( GParted_Core::is_dev_mounted( btrfs_dev.members[i].m_name ) )
+               if ( GParted_Core::is_dev_mounted( btrfs_dev.members[i] ) )
                        return btrfs_dev.members[i].m_name;
        return "" ;
 }


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