Remember result of searching the PATH for the hdparm command (#751251)
Previously on every refresh for every device, GParted was searching the PATH to discover if the hdparm command existed. Stracing GParted showed that calling Glib::find_program_in_path("hdparm") made the following OS calls: access("/usr/lib64/qt-3.3/bin/hdparm", X_OK) = -1 ENOENT (No such file or directory) access("/usr/local/sbin/hdparm", X_OK) = -1 ENOENT (No such file or directory) access("/usr/local/bin/hdparm", X_OK) = -1 ENOENT (No such file or directory) access("/sbin/hdparm", X_OK) = 0 getuid() = 0 stat("/sbin/hdparm", {st_mode=S_IFREG|0755, st_size=137, ...}) = 0 stat("/sbin/hdparm", {st_mode=S_IFREG|0755, st_size=137, ...}) = 0 The Linux VFS is very fast but repeatedly doing this is wasteful. Remember the result of searching the PATH for the hdparm command at startup and refresh this when the [Rescan For Supported Actions] button is pressed in the File System Support dialog. This is the same as GParted already does for file system specific commands and their capabilities. Bug 751251 - Show serial number in device information
This commit is contained in:
parent
4fce7cd5ee
commit
54d0e3d056
|
@ -35,6 +35,7 @@ public:
|
||||||
GParted_Core() ;
|
GParted_Core() ;
|
||||||
~GParted_Core() ;
|
~GParted_Core() ;
|
||||||
|
|
||||||
|
static void find_supported_core();
|
||||||
void find_supported_filesystems() ;
|
void find_supported_filesystems() ;
|
||||||
void set_user_devices( const std::vector<Glib::ustring> & user_devices ) ;
|
void set_user_devices( const std::vector<Glib::ustring> & user_devices ) ;
|
||||||
void set_devices( std::vector<Device> & devices ) ;
|
void set_devices( std::vector<Device> & devices ) ;
|
||||||
|
|
|
@ -75,6 +75,8 @@ namespace GParted
|
||||||
static std::map< Glib::ustring, std::vector<Glib::ustring> > mount_info ;
|
static std::map< Glib::ustring, std::vector<Glib::ustring> > mount_info ;
|
||||||
static std::map< Glib::ustring, std::vector<Glib::ustring> > fstab_info ;
|
static std::map< Glib::ustring, std::vector<Glib::ustring> > fstab_info ;
|
||||||
|
|
||||||
|
static bool hdparm_found = false;
|
||||||
|
|
||||||
GParted_Core::GParted_Core()
|
GParted_Core::GParted_Core()
|
||||||
{
|
{
|
||||||
thread_status_message = "" ;
|
thread_status_message = "" ;
|
||||||
|
@ -92,6 +94,8 @@ GParted_Core::GParted_Core()
|
||||||
std::cout << "libparted : " << ped_get_version() << std::endl ;
|
std::cout << "libparted : " << ped_get_version() << std::endl ;
|
||||||
std::cout << "======================" << std::endl ;
|
std::cout << "======================" << std::endl ;
|
||||||
|
|
||||||
|
find_supported_core();
|
||||||
|
|
||||||
//initialize file system list
|
//initialize file system list
|
||||||
init_filesystems() ;
|
init_filesystems() ;
|
||||||
|
|
||||||
|
@ -99,6 +103,11 @@ GParted_Core::GParted_Core()
|
||||||
find_supported_filesystems() ;
|
find_supported_filesystems() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GParted_Core::find_supported_core()
|
||||||
|
{
|
||||||
|
hdparm_found = ! Glib::find_program_in_path( "hdparm" ).empty();
|
||||||
|
}
|
||||||
|
|
||||||
void GParted_Core::find_supported_filesystems()
|
void GParted_Core::find_supported_filesystems()
|
||||||
{
|
{
|
||||||
std::map< FILESYSTEM, FileSystem * >::iterator f ;
|
std::map< FILESYSTEM, FileSystem * >::iterator f ;
|
||||||
|
@ -1182,7 +1191,7 @@ Glib::ustring GParted_Core::get_partition_path( PedPartition * lp_partition )
|
||||||
|
|
||||||
void GParted_Core::set_device_serial_number( Device & device )
|
void GParted_Core::set_device_serial_number( Device & device )
|
||||||
{
|
{
|
||||||
if ( Glib::find_program_in_path( "hdparm" ).empty() )
|
if ( ! hdparm_found )
|
||||||
// Serial number left blank when the hdparm command is not installed.
|
// Serial number left blank when the hdparm command is not installed.
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -1474,6 +1474,10 @@ void Win_GParted::menu_gparted_features()
|
||||||
dialog .load_filesystems( gparted_core .get_filesystems() ) ;
|
dialog .load_filesystems( gparted_core .get_filesystems() ) ;
|
||||||
while ( dialog .run() == Gtk::RESPONSE_OK )
|
while ( dialog .run() == Gtk::RESPONSE_OK )
|
||||||
{
|
{
|
||||||
|
// Button [Rescan For Supported Actions] pressed in the dialog. Rescan
|
||||||
|
// for available core and file system specific commands and update the
|
||||||
|
// view accordingly in the dialog.
|
||||||
|
GParted_Core::find_supported_core();
|
||||||
gparted_core .find_supported_filesystems() ;
|
gparted_core .find_supported_filesystems() ;
|
||||||
dialog .load_filesystems( gparted_core .get_filesystems() ) ;
|
dialog .load_filesystems( gparted_core .get_filesystems() ) ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue