Improved read label performance with blkid cached results

svn path=/trunk/; revision=963
This commit is contained in:
Curtis Gedak 2008-11-13 20:06:18 +00:00
parent 67dd9f2c10
commit 5b8c16ba60
5 changed files with 38 additions and 5 deletions

View File

@ -1,3 +1,11 @@
2008-11-13 Curtis Gedak <gedakc@gmail.com>
* include/FS_Info.h,
src/FS_Info.cc,
src/GParted_Core.cc,
README: Improved read label performance with blkid cached results.
- When possible use blkid cached results to determine volume label.
2008-11-12 Curtis Gedak <gedakc@gmail.com> 2008-11-12 Curtis Gedak <gedakc@gmail.com>
* README: Updated directories and dependencies. * README: Updated directories and dependencies.

4
README
View File

@ -121,4 +121,6 @@ Optional packages include:
to read linux-swap, reiser4, hfs, and hfs+ file system to read linux-swap, reiser4, hfs, and hfs+ file system
volume labels. volume labels.
* If the blkid command is in the search path, it will be used * If the blkid command is in the search path, it will be used
to read file system UUIDs. to read file system UUIDs and labels.
blkid is part of the e2fsprogs package.

View File

@ -28,6 +28,7 @@ class FS_Info
public: public:
FS_Info() ; FS_Info() ;
~FS_Info() ; ~FS_Info() ;
Glib::ustring get_label( const Glib::ustring & path, bool & found ) ;
Glib::ustring get_uuid( const Glib::ustring & path ) ; Glib::ustring get_uuid( const Glib::ustring & path ) ;
private: private:
void load_fs_info_cache() ; void load_fs_info_cache() ;

View File

@ -14,7 +14,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "../include/FS_Info.h" #include "../include/FS_Info.h"
namespace GParted namespace GParted
@ -41,6 +41,24 @@ void FS_Info::load_fs_info_cache()
} }
} }
Glib::ustring FS_Info::get_label( const Glib::ustring & path, bool & found )
{
Glib::ustring label = "" ;
found = false ;
//Retrieve the line containing the device path
Glib::ustring regexp = "^" + path + ":([^\n]*)$" ;
Glib::ustring temp = Utils::regexp_label( fs_info_cache, regexp ) ;
//Set indicator if LABEL found
if ( Utils::regexp_label( temp, "(LABEL=\")") != "" )
found = true ;
//Retrieve LABEL
label = Utils::regexp_label( temp, "LABEL=\"([^\"]*)\"" ) ;
return label ;
}
Glib::ustring FS_Info::get_uuid( const Glib::ustring & path ) Glib::ustring FS_Info::get_uuid( const Glib::ustring & path )
{ {
//Retrieve the line containing the device path //Retrieve the line containing the device path

View File

@ -736,9 +736,13 @@ void GParted_Core::set_device_partitions( Device & device )
} }
//Avoid reading additional file system information if there is no path //Avoid reading additional file system information if there is no path
//FIXME: Why is there an empty path for the first primary partition, and an empty path for each logical partition? if ( partition_temp .get_path() != "" )
if ( partition_temp .get_path() != "" ) { {
read_label( partition_temp ) ; bool label_found = false ;
partition_temp .label = fs_info .get_label( partition_temp .get_path(), label_found ) ;
if ( ! label_found )
read_label( partition_temp ) ;
partition_temp .uuid = fs_info .get_uuid( partition_temp .get_path() ) ; partition_temp .uuid = fs_info .get_uuid( partition_temp .get_path() ) ;
} }