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
This commit is contained in:
Mike Fleetwood 2016-07-03 13:25:57 +01:00 committed by Curtis Gedak
parent abee66484f
commit e4a8530b14
3 changed files with 10 additions and 3 deletions

View File

@ -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() ;

View File

@ -970,7 +970,13 @@ 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 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();
}

View File

@ -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 "" ;
}