[gparted] Create helper function set_partition_label_and_uuid() (#741430)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Create helper function set_partition_label_and_uuid() (#741430)
- Date: Mon, 9 Mar 2015 16:36:35 +0000 (UTC)
commit ed827cf59ad1bc83a31063945b778126951a3a34
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Sat Dec 27 13:46:38 2014 +0000
Create helper function set_partition_label_and_uuid() (#741430)
Move code which queries the file system label and UUID of a partition
into a separate helper function.
Bug 741430 - GParted cannot recognise LVM signature on unpartitioned
drive
include/GParted_Core.h | 1 +
src/GParted_Core.cc | 45 +++++++++++++++++++++++++--------------------
2 files changed, 26 insertions(+), 20 deletions(-)
---
diff --git a/include/GParted_Core.h b/include/GParted_Core.h
index 1f497c3..5755e13 100644
--- a/include/GParted_Core.h
+++ b/include/GParted_Core.h
@@ -78,6 +78,7 @@ private:
static void read_mountpoints_from_mount_command( std::map< Glib::ustring, std::vector<Glib::ustring>
& map ) ;
Glib::ustring get_partition_path( PedPartition * lp_partition ) ;
void set_device_partitions( Device & device, PedDevice* lp_device, PedDisk* lp_disk ) ;
+ void set_partition_label_and_uuid( Partition & partition );
static FILESYSTEM recognise_filesystem_signature( PedDevice * lp_device, PedPartition * lp_partition
);
GParted::FILESYSTEM get_filesystem( PedDevice* lp_device, PedPartition* lp_partition,
std::vector<Glib::ustring>& messages ) ;
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index de87510..ce76a8a 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -1097,7 +1097,6 @@ void GParted_Core::set_device_partitions( Device & device, PedDevice* lp_device,
{
int EXT_INDEX = -1 ;
Proc_Partitions_Info pp_info ; //Use cache of proc partitions information
- FS_Info fs_info ; //Use cache of file system information
#ifndef USE_LIBPARTED_DMRAID
DMRaid dmraid ; //Use cache of dmraid device information
#endif
@@ -1184,25 +1183,7 @@ void GParted_Core::set_device_partitions( Device & device, PedDevice* lp_device,
//Avoid reading additional file system information if there is no path
if ( partition_temp .get_path() != "" )
{
- //Retrieve file system label
- // Use file system specific method first in an effort to ensure multi-byte
- // character sets are properly displayed.
- read_label( partition_temp ) ;
- if ( ! partition_temp.filesystem_label_known() )
- {
- bool label_found = false ;
- Glib::ustring label = fs_info .get_label( partition_temp .get_path(),
label_found ) ;
- if ( label_found )
- partition_temp.set_filesystem_label( label );
- }
-
- //Retrieve file system UUID
- // Use cached method first in an effort to speed up device scanning.
- partition_temp .uuid = fs_info .get_uuid( partition_temp .get_path() ) ;
- if ( partition_temp .uuid .empty() )
- {
- read_uuid( partition_temp ) ;
- }
+ set_partition_label_and_uuid( partition_temp );
// Retrieve partition name
if ( device.partition_naming )
@@ -1250,6 +1231,30 @@ void GParted_Core::set_device_partitions( Device & device, PedDevice* lp_device,
insert_unallocated( device .get_path(), device .partitions, 0, device .length -1, device
.sector_size, false ) ;
}
+void GParted_Core::set_partition_label_and_uuid( Partition & partition )
+{
+ FS_Info fs_info; // Use cache of file system information
+
+ // Retrieve file system label. Use file system specific method first in an effort
+ // to ensure multi-byte character sets are properly displayed.
+ read_label( partition );
+ if ( ! partition.filesystem_label_known() )
+ {
+ bool label_found = false;
+ Glib::ustring label = fs_info.get_label( partition.get_path(), label_found );
+ if ( label_found )
+ partition.set_filesystem_label( label );
+ }
+
+ // Retrieve file system UUID. Use cached method first in an effort to speed up
+ // device scanning.
+ partition.uuid = fs_info.get_uuid( partition.get_path() );
+ if ( partition.uuid.empty() )
+ {
+ read_uuid( partition );
+ }
+}
+
// GParted simple internal file system signature detection. Use sparingly. Only when
// (old versions of) blkid and libparted don't recognise a signature.
FILESYSTEM GParted_Core::recognise_filesystem_signature( PedDevice * lp_device, PedPartition * lp_partition )
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]