Remember result of searching the PATH for udevadm and udevsettle cmds

GParted was also searching the PATH for the availability of the udevadm
and udevsettle commands for every device with a busy partition during a
refresh and for every applied operation effecting a partition table.  As
with hdparm previously this was wasteful.

Again, remember the result of searching the PATH at startup and refresh
when clicking on the [Rescan For Supported Actions] button in the File
System Support dialog.
This commit is contained in:
Mike Fleetwood 2015-06-30 18:48:39 +01:00 committed by Curtis Gedak
parent 54d0e3d056
commit 038209a9cf
1 changed files with 6 additions and 2 deletions

View File

@ -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> > fstab_info ;
static bool udevadm_found = false;
static bool udevsettle_found = false;
static bool hdparm_found = false;
GParted_Core::GParted_Core()
@ -105,6 +107,8 @@ GParted_Core::GParted_Core()
void GParted_Core::find_supported_core()
{
udevadm_found = ! Glib::find_program_in_path( "udevadm" ).empty();
udevsettle_found = ! Glib::find_program_in_path( "udevsettle" ).empty();
hdparm_found = ! Glib::find_program_in_path( "hdparm" ).empty();
}
@ -3967,9 +3971,9 @@ bool GParted_Core::commit_to_os( PedDisk* lp_disk, std::time_t timeout )
void GParted_Core::settle_device( std::time_t timeout )
{
if ( ! Glib::find_program_in_path( "udevsettle" ) .empty() )
if ( udevsettle_found )
Utils::execute_command( "udevsettle --timeout=" + Utils::num_to_str( timeout ) ) ;
else if ( ! Glib::find_program_in_path( "udevadm" ) .empty() )
else if ( udevadm_found )
Utils::execute_command( "udevadm settle --timeout=" + Utils::num_to_str( timeout ) ) ;
else
sleep( timeout ) ;