Enhance UUID detection to fallback to vol_id if available

Normally, the blkid command will detect the UUID for a file system.
In cases where blkid fails to detect the UUID and the vol_id command
is available, then try using the vol_id command.
This commit is contained in:
Curtis Gedak 2009-04-24 17:46:05 -06:00
parent 8d024d86df
commit 47f0d6bd5d
2 changed files with 14 additions and 0 deletions

View File

@ -38,6 +38,7 @@ private:
Glib::ustring get_device_entry( const Glib::ustring & path ) ; Glib::ustring get_device_entry( const Glib::ustring & path ) ;
static bool fs_info_cache_initialized ; static bool fs_info_cache_initialized ;
static bool blkid_found ; static bool blkid_found ;
static bool vol_id_found ;
static Glib::ustring fs_info_cache ; static Glib::ustring fs_info_cache ;
}; };

View File

@ -23,6 +23,7 @@ namespace GParted
//initialize static data elements //initialize static data elements
bool FS_Info::fs_info_cache_initialized = false ; bool FS_Info::fs_info_cache_initialized = false ;
bool FS_Info::blkid_found = false ; bool FS_Info::blkid_found = false ;
bool FS_Info::vol_id_found = false ;
Glib::ustring FS_Info::fs_info_cache = ""; Glib::ustring FS_Info::fs_info_cache = "";
FS_Info::FS_Info() FS_Info::FS_Info()
@ -71,6 +72,7 @@ void FS_Info::set_commands_found()
{ {
//Set status of commands found //Set status of commands found
blkid_found = (! Glib::find_program_in_path( "blkid" ) .empty() ) ; blkid_found = (! Glib::find_program_in_path( "blkid" ) .empty() ) ;
vol_id_found = (! Glib::find_program_in_path( "vol_id" ) .empty() ) ;
} }
Glib::ustring FS_Info::get_device_entry( const Glib::ustring & path ) Glib::ustring FS_Info::get_device_entry( const Glib::ustring & path )
@ -117,6 +119,17 @@ Glib::ustring FS_Info::get_uuid( const Glib::ustring & path )
//Retrieve the UUID //Retrieve the UUID
Glib::ustring uuid = Utils::regexp_label( temp, "UUID=\"([^\"]*)\"" ) ; Glib::ustring uuid = Utils::regexp_label( temp, "UUID=\"([^\"]*)\"" ) ;
if ( uuid .empty() && vol_id_found )
{
//Retrieve UUID using vol_id command
Glib::ustring output, error ;
if ( ! Utils::execute_command( "vol_id " + path, output, error, true ) )
{
uuid = Utils::regexp_label( output, "ID_FS_UUID=([^\n]*)" ) ;
}
}
return uuid ; return uuid ;
} }