[gparted] Enhance UUID detection to fallback to vol_id if available
- From: Curtis Gedak <gedakc src gnome org>
- To: svn-commits-list gnome org
- Subject: [gparted] Enhance UUID detection to fallback to vol_id if available
- Date: Fri, 24 Apr 2009 19:49:04 -0400 (EDT)
commit 47f0d6bd5dc840ef060eda73d21740bf99b373e5
Author: Curtis Gedak <gedakc gmail com>
Date: Fri Apr 24 17:46:05 2009 -0600
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(+), 0 deletions(-)
diff --git a/include/FS_Info.h b/include/FS_Info.h
index 49b7218..43da225 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 16df40a..14b761d 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 ;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]