From 47f0d6bd5dc840ef060eda73d21740bf99b373e5 Mon Sep 17 00:00:00 2001 From: Curtis Gedak Date: Fri, 24 Apr 2009 17:46:05 -0600 Subject: [PATCH] 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. --- include/FS_Info.h | 1 + src/FS_Info.cc | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/FS_Info.h b/include/FS_Info.h index 49b7218c..43da2258 100644 --- a/include/FS_Info.h +++ b/include/FS_Info.h @@ -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 ; }; diff --git a/src/FS_Info.cc b/src/FS_Info.cc index 16df40a5..14b761dc 100644 --- a/src/FS_Info.cc +++ b/src/FS_Info.cc @@ -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 ; }