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:
parent
8d024d86df
commit
47f0d6bd5d
|
@ -38,6 +38,7 @@ private:
|
|||
Glib::ustring get_device_entry( const Glib::ustring & path ) ;
|
||||
static bool fs_info_cache_initialized ;
|
||||
static bool blkid_found ;
|
||||
static bool vol_id_found ;
|
||||
static Glib::ustring fs_info_cache ;
|
||||
};
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ namespace GParted
|
|||
//initialize static data elements
|
||||
bool FS_Info::fs_info_cache_initialized = false ;
|
||||
bool FS_Info::blkid_found = false ;
|
||||
bool FS_Info::vol_id_found = false ;
|
||||
Glib::ustring FS_Info::fs_info_cache = "";
|
||||
|
||||
FS_Info::FS_Info()
|
||||
|
@ -71,6 +72,7 @@ void FS_Info::set_commands_found()
|
|||
{
|
||||
//Set status of commands found
|
||||
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 )
|
||||
|
@ -117,6 +119,17 @@ Glib::ustring FS_Info::get_uuid( const Glib::ustring & path )
|
|||
|
||||
//Retrieve the 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 ;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue