[gparted] Make GParted recognise reading blank file system labels (#685656)



commit 686ec8f713d67c71a3a372e98141b86e38860679
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Mon Oct 8 14:23:17 2012 +0100

    Make GParted recognise reading blank file system labels (#685656)
    
    GParted doesn't notice when a file system label is changed to blank.
    GParted first calls the file system specific read_label() method.  When
    the label is blank read_label() correctly sets partition.label to the
    zero length string.  Second GParted_Core::set_device_partitions() treats
    the zero length string to mean that the label is unset and calls
    FS_Info::get_label() to retrieve it from the cache of blkid output.
    Blkid also doesn't notice when the file system label has been changed to
    blank so reports the previous label.  Hence GParted displays the
    previous file system label.
    
    Fix by making label a private member variable of the class Partition and
    providing access methods set_label(), get_label() and label_known()
    which track whether the label has been set or not.  This only fixes the
    fault for file systems which use file system specific commands to read
    the label and when these tools are installed.  Otherwise GParted uses,
    or has to fall back on using, the buggy blkid command to read the file
    system label.
    
    NOTE:
    Many of the file system specific read_label() methods use a tool which
    outputs more than just the label and use Utils::regexp_label() to match
    leading text and the label itself.  If the surrounding text changes or
    disappears altogether to indicated a blank label, regexp_label() doesn't
    match anything and returns the zero length string.  This  is exactly
    what is required and is passed to set_label() to set the label to blank.
    
    Bug 685656 - GParted doesn't notice when file system label is changed to
                 blank

 include/Partition.h            |    6 +++++-
 src/Dialog_Partition_Info.cc   |    2 +-
 src/Dialog_Partition_Label.cc  |    2 +-
 src/Dialog_Partition_New.cc    |    4 ++--
 src/GParted_Core.cc            |   10 ++++++----
 src/OperationLabelPartition.cc |    4 ++--
 src/Partition.cc               |   21 ++++++++++++++++++++-
 src/TreeView_Detail.cc         |    4 ++--
 src/Win_GParted.cc             |    8 ++++----
 src/btrfs.cc                   |   16 ++++++++++------
 src/ext2.cc                    |    6 +++---
 src/ext3.cc                    |    6 +++---
 src/ext4.cc                    |    6 +++---
 src/fat16.cc                   |   10 ++++++----
 src/fat32.cc                   |   10 ++++++----
 src/hfs.cc                     |   10 ++++++----
 src/hfsplus.cc                 |   10 ++++++----
 src/jfs.cc                     |    6 +++---
 src/linux_swap.cc              |    8 ++++----
 src/nilfs2.cc                  |    8 +++++---
 src/ntfs.cc                    |    6 +++---
 src/reiser4.cc                 |    4 ++--
 src/reiserfs.cc                |    6 +++---
 src/xfs.cc                     |    8 ++++----
 24 files changed, 110 insertions(+), 71 deletions(-)
---
diff --git a/include/Partition.h b/include/Partition.h
index 7081286..29f4993 100644
--- a/include/Partition.h
+++ b/include/Partition.h
@@ -102,6 +102,9 @@ public:
 	std::vector<Glib::ustring> get_mountpoints() const ;
 	Sector get_sector() const ;
 	bool test_overlap( const Partition & partition ) const ;
+	bool label_known() const ;
+	Glib::ustring get_label() const ;
+	void set_label( const Glib::ustring & label ) ;
 
 	bool operator==( const Partition & partition ) const ;
 	bool operator!=( const Partition & partition ) const ;
@@ -113,7 +116,6 @@ public:
 	PartitionStatus status; //STAT_REAL, STAT_NEW, etc..
 	PartitionAlignment alignment;   //ALIGN_CYLINDER, ALIGN_STRICT, etc
 	FILESYSTEM filesystem ;
-	Glib::ustring label ;
 	Glib::ustring uuid ;
 	Sector sector_start;
 	Sector sector_end;
@@ -144,6 +146,8 @@ private:
 	
 	std::vector<Glib::ustring> paths ;
 	std::vector<Glib::ustring> mountpoints ;
+	bool have_label ;
+	Glib::ustring label ;
 };
 
 }//GParted
diff --git a/src/Dialog_Partition_Info.cc b/src/Dialog_Partition_Info.cc
index 7713331..919a456 100644
--- a/src/Dialog_Partition_Info.cc
+++ b/src/Dialog_Partition_Info.cc
@@ -387,7 +387,7 @@ void Dialog_Partition_Info::Display_Info()
 				0, 1,
 				top, bottom,
 				Gtk::FILL) ;
-		table ->attach( * Utils::mk_label( partition .label, true, Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false, true ),
+		table ->attach( * Utils::mk_label( partition .get_label(), true, Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false, true ),
 				1, 2,
 				top++, bottom++,
 				Gtk::FILL) ;
diff --git a/src/Dialog_Partition_Label.cc b/src/Dialog_Partition_Label.cc
index e9d1f4a..fa719a2 100644
--- a/src/Dialog_Partition_Label.cc
+++ b/src/Dialog_Partition_Label.cc
@@ -47,7 +47,7 @@ Dialog_Partition_Label::Dialog_Partition_Label( const Partition & partition )
 		entry->set_max_length(30);
 		entry->set_width_chars(20);
 		entry->set_activates_default(true);
-		entry->set_text(partition.label);
+		entry->set_text(partition.get_label());
 		entry->select_region(0, entry ->get_text_length());
 		//Add entry box to table
 		table->attach(*entry,
diff --git a/src/Dialog_Partition_New.cc b/src/Dialog_Partition_New.cc
index 4121154..f713cde 100644
--- a/src/Dialog_Partition_New.cc
+++ b/src/Dialog_Partition_New.cc
@@ -132,7 +132,7 @@ void Dialog_Partition_New::Set_Data( const Partition & partition,
 	entry .set_max_length( 30 );
 	entry .set_width_chars( 20 );
 	entry .set_activates_default( true );
-	entry .set_text( partition.label );
+	entry .set_text( partition .get_label() );
 	entry .select_region( 0, entry .get_text_length() );
 	//Add entry box to table
 	table_create .attach( entry, 1, 2, 3, 4, Gtk::FILL ) ;
@@ -201,7 +201,7 @@ Partition Dialog_Partition_New::Get_New_Partition( Byte_Value sector_size )
 			selected_partition .inside_extended, false ) ;
 
 	//Retrieve Label info
-	part_temp .label = Utils::trim( entry .get_text() );
+	part_temp .set_label( Utils::trim( entry .get_text() ) ) ;
 	
 	//grow new partition a bit if freespaces are < 1 MiB
 	if ( (part_temp.sector_start - selected_partition.sector_start) < (MEBIBYTE / sector_size) ) 
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 88f7be8..77eb0f5 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -1091,10 +1091,12 @@ void GParted_Core::set_device_partitions( Device & device )
 			//  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 .label .empty() )
+			if ( ! partition_temp .label_known() )
 			{
 				bool label_found = false ;
-				partition_temp .label = fs_info .get_label( partition_temp .get_path(), label_found ) ;
+				Glib::ustring label = fs_info .get_label( partition_temp .get_path(), label_found ) ;
+				if ( label_found )
+					partition_temp .set_label( label ) ;
 			}
 
 			//Retrieve file system UUID
@@ -1883,7 +1885,7 @@ bool GParted_Core::remove_filesystem( const Partition & partition, OperationDeta
 
 bool GParted_Core::label_partition( const Partition & partition, OperationDetail & operationdetail )	
 {
-	if( partition .label .empty() ) {
+	if( partition .get_label() .empty() ) {
 		operationdetail .add_child( OperationDetail( String::ucompose(
 														_("Clear partition label on %1"),
 														partition .get_path()
@@ -1891,7 +1893,7 @@ bool GParted_Core::label_partition( const Partition & partition, OperationDetail
 	} else {
 		operationdetail .add_child( OperationDetail( String::ucompose(
 														_("Set partition label to \"%1\" on %2"),
-														partition .label, partition .get_path()
+														partition .get_label(), partition .get_path()
 													 ) ) ) ;
 	}
 
diff --git a/src/OperationLabelPartition.cc b/src/OperationLabelPartition.cc
index 31649b4..66887ef 100644
--- a/src/OperationLabelPartition.cc
+++ b/src/OperationLabelPartition.cc
@@ -54,14 +54,14 @@ void OperationLabelPartition::apply_to_visual( std::vector<Partition> & partitio
 
 void OperationLabelPartition::create_description() 
 {
-	if( partition_new .label .empty() ) {
+	if( partition_new .get_label() .empty() ) {
 		/*TO TRANSLATORS: looks like   Clear Partition Label on /dev/hda3 */
 		description = String::ucompose( _("Clear Partition Label on %1"),
 						partition_new .get_path() ) ;
 	} else {
 		/*TO TRANSLATORS: looks like   Set Partition Label "My Label" on /dev/hda3 */
 		description = String::ucompose( _("Set Partition Label \"%1\" on %2"),
-					 	partition_new .label,
+						partition_new .get_label(),
 						partition_new .get_path() ) ;
 	}
 }
diff --git a/src/Partition.cc b/src/Partition.cc
index e245efa..02200ab 100644
--- a/src/Partition.cc
+++ b/src/Partition.cc
@@ -41,7 +41,7 @@ void Partition::Reset()
 	type = GParted::TYPE_UNALLOCATED ;
 	alignment = ALIGN_STRICT ;
 	filesystem = GParted::FS_UNALLOCATED ;
-	label .clear() ;
+	have_label = false ;
 	uuid .clear() ;
 	partition_number = sector_start = sector_end = sectors_used = sectors_unused = -1;
 	sectors_unallocated = 0 ;
@@ -249,6 +249,25 @@ std::vector<Glib::ustring> Partition::get_paths() const
 	return paths ;
 }
 
+bool Partition::label_known() const
+{
+	return have_label ;
+}
+
+//Return the label or "" if label is unknown.
+Glib::ustring Partition::get_label() const
+{
+	if ( have_label )
+		return label ;
+	return "" ;
+}
+
+void Partition::set_label( const Glib::ustring & label )
+{
+	this ->label = label ;
+	have_label = true ;
+}
+
 bool Partition::operator==( const Partition & partition ) const
 {
 	return device_path == partition .device_path &&
diff --git a/src/TreeView_Detail.cc b/src/TreeView_Detail.cc
index a47bc7b..3240152 100644
--- a/src/TreeView_Detail.cc
+++ b/src/TreeView_Detail.cc
@@ -127,7 +127,7 @@ void TreeView_Detail::load_partitions( const std::vector<Partition> & partitions
 		if ( partitions[ i ] .get_mountpoints() .size() )
 			mountpoints = true ;
 					
-		if ( ! partitions[ i ] .label .empty() )
+		if ( ! partitions[ i ] .get_label() .empty() )
 			labels = true ;
 	}
 }
@@ -184,7 +184,7 @@ void TreeView_Detail::create_row( const Gtk::TreeRow & treerow, const Partition
 	treerow[ treeview_detail_columns .mountpoint ] = Glib::build_path( ", ", partition .get_mountpoints() ) ;
 
 	//label
-	treerow[ treeview_detail_columns .label ] = partition .label ;
+	treerow[ treeview_detail_columns .label ] = partition .get_label() ;
 		
 	//size
 	treerow[ treeview_detail_columns .size ] = Utils::format_size( partition .get_sector_length(), partition .sector_size ) ;
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index f3bb8ff..3a87d17 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -759,7 +759,7 @@ bool Win_GParted::Merge_Operations( unsigned int first, unsigned int second )
 	          operations[ first ]->partition_new == operations[ second ]->partition_original
 	        )
 	{
-		operations[ first ]->partition_new.label = operations[ second ]->partition_new.label;
+		operations[ first ]->partition_new.set_label( operations[ second ]->partition_new .get_label() ) ;
 		operations[ first ]->create_description() ;
 		remove_operation( second );
 
@@ -1673,7 +1673,7 @@ void Win_GParted::activate_paste()
 		Partition partition_new = selected_partition ;
 		partition_new .alignment = ALIGN_STRICT ;
 		partition_new .filesystem = copied_partition .filesystem ;
-		partition_new .label = copied_partition .label ;
+		partition_new .set_label( copied_partition .get_label() ) ;
 		partition_new .uuid = copied_partition .uuid ;
 		partition_new .color = copied_partition .color ;
 		Sector new_size = partition_new .get_sector_length() ;
@@ -2462,13 +2462,13 @@ void Win_GParted::activate_label_partition()
 	dialog .set_transient_for( *this );
 
 	if (	( dialog .run() == Gtk::RESPONSE_OK )
-		&&	( dialog .get_new_label() != selected_partition .label ) ) 
+	     && ( dialog .get_new_label() != selected_partition .get_label() ) )
 	{
 		dialog .hide() ;
 		//Make a duplicate of the selected partition (used in UNDO)
 		Partition part_temp = selected_partition ;
 
-		part_temp .label = dialog .get_new_label();
+		part_temp .set_label( dialog .get_new_label() ) ;
 
 		Operation * operation = new OperationLabelPartition( devices[ current_device ],
 									selected_partition, part_temp ) ;
diff --git a/src/btrfs.cc b/src/btrfs.cc
index 2db4b25..e7b5c11 100644
--- a/src/btrfs.cc
+++ b/src/btrfs.cc
@@ -111,7 +111,7 @@ FS btrfs::get_filesystem_support()
 
 bool btrfs::create( const Partition & new_partition, OperationDetail & operationdetail )
 {
-	return (! execute_command( "mkfs.btrfs -L \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) );
+	return (! execute_command( "mkfs.btrfs -L \"" + new_partition .get_label() + "\" " + new_partition .get_path(), operationdetail ) );
 }
 
 bool btrfs::check_repair( const Partition & partition, OperationDetail & operationdetail )
@@ -163,7 +163,7 @@ void btrfs::set_used_sectors( Partition & partition )
 
 bool btrfs::write_label( const Partition & partition, OperationDetail & operationdetail )
 {
-	return ! execute_command( "btrfs filesystem label " + partition .get_path() + " \"" + partition .label + "\"", operationdetail ) ;
+	return ! execute_command( "btrfs filesystem label " + partition .get_path() + " \"" + partition .get_label() + "\"", operationdetail ) ;
 }
 
 bool btrfs::write_uuid( const Partition & partition, OperationDetail & operationdetail )
@@ -250,11 +250,13 @@ void btrfs::read_label( Partition & partition )
 		exit_status = Utils::execute_command( "btrfs filesystem show " + partition .get_path(), output, error, true ) ;
 		if ( ! exit_status )
 		{
-			partition .label = Utils::regexp_label( output, "^Label: '(.*)'  uuid:" );
+			partition .set_label( Utils::regexp_label( output, "^Label: '(.*)'  uuid:" ) ) ;
 			//Btrfs filesystem show encloses the label in single
 			//  quotes or reports "none" without single quotes, so
-			//  the cases are disginguishable and this regexp won't
-			//  match the no label case.
+			//  the cases are distinguishable and this regexp won't
+			//  match the no label case.  In the no match case
+			//  regexp_label() returns "" and this is used to set
+			//  the set the blank label.
 		}
 	}
 	else
@@ -267,7 +269,9 @@ void btrfs::read_label( Partition & partition )
 			//  this is indistinguishable from the label actually
 			//  being "none".  Assume no label case.
 			if ( label != "none" )
-				partition .label = label ;
+				partition .set_label( label ) ;
+			else
+				partition .set_label( "" ) ;
 		}
 	}
 	if ( exit_status )
diff --git a/src/ext2.cc b/src/ext2.cc
index ad62208..56e38eb 100644
--- a/src/ext2.cc
+++ b/src/ext2.cc
@@ -127,7 +127,7 @@ void ext2::read_label( Partition & partition )
 {
 	if ( ! Utils::execute_command( "e2label " + partition .get_path(), output, error, true ) )
 	{
-		partition .label = Utils::trim( output ) ;
+		partition .set_label( Utils::trim( output ) ) ;
 	}
 	else
 	{
@@ -141,7 +141,7 @@ void ext2::read_label( Partition & partition )
 
 bool ext2::write_label( const Partition & partition, OperationDetail & operationdetail )
 {
-	return ! execute_command( "e2label " + partition .get_path() + " \"" + partition .label + "\"", operationdetail ) ;
+	return ! execute_command( "e2label " + partition .get_path() + " \"" + partition .get_label() + "\"", operationdetail ) ;
 }
 
 void ext2::read_uuid( Partition & partition )
@@ -167,7 +167,7 @@ bool ext2::write_uuid( const Partition & partition, OperationDetail & operationd
 
 bool ext2::create( const Partition & new_partition, OperationDetail & operationdetail )
 {
-	return ! execute_command( "mkfs.ext2 -L \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) ;
+	return ! execute_command( "mkfs.ext2 -L \"" + new_partition .get_label() + "\" " + new_partition .get_path(), operationdetail ) ;
 }
 
 bool ext2::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
diff --git a/src/ext3.cc b/src/ext3.cc
index a6d6d42..51ef51a 100644
--- a/src/ext3.cc
+++ b/src/ext3.cc
@@ -128,7 +128,7 @@ void ext3::read_label( Partition & partition )
 {
 	if ( ! Utils::execute_command( "e2label " + partition .get_path(), output, error, true ) )
 	{
-		partition .label = Utils::trim( output ) ;
+		partition .set_label( Utils::trim( output ) ) ;
 	}
 	else
 	{
@@ -142,7 +142,7 @@ void ext3::read_label( Partition & partition )
 
 bool ext3::write_label( const Partition & partition, OperationDetail & operationdetail )
 {
-	return ! execute_command( "e2label " + partition .get_path() + " \"" + partition .label + "\"", operationdetail ) ;
+	return ! execute_command( "e2label " + partition .get_path() + " \"" + partition .get_label() + "\"", operationdetail ) ;
 }
 
 void ext3::read_uuid( Partition & partition )
@@ -168,7 +168,7 @@ bool ext3::write_uuid( const Partition & partition, OperationDetail & operationd
 
 bool ext3::create( const Partition & new_partition, OperationDetail & operationdetail )
 {
-	return ! execute_command( "mkfs.ext3 -L \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) ;
+	return ! execute_command( "mkfs.ext3 -L \"" + new_partition .get_label() + "\" " + new_partition .get_path(), operationdetail ) ;
 }
 
 bool ext3::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
diff --git a/src/ext4.cc b/src/ext4.cc
index 674903a..99f3d58 100644
--- a/src/ext4.cc
+++ b/src/ext4.cc
@@ -131,7 +131,7 @@ void ext4::read_label( Partition & partition )
 {
 	if ( ! Utils::execute_command( "e2label " + partition .get_path(), output, error, true ) )
 	{
-		partition .label = Utils::trim( output ) ;
+		partition .set_label( Utils::trim( output ) ) ;
 	}
 	else
 	{
@@ -145,7 +145,7 @@ void ext4::read_label( Partition & partition )
 
 bool ext4::write_label( const Partition & partition, OperationDetail & operationdetail )
 {
-	return ! execute_command( "e2label " + partition .get_path() + " \"" + partition .label + "\"", operationdetail ) ;
+	return ! execute_command( "e2label " + partition .get_path() + " \"" + partition .get_label() + "\"", operationdetail ) ;
 }
 
 void ext4::read_uuid( Partition & partition )
@@ -171,7 +171,7 @@ bool ext4::write_uuid( const Partition & partition, OperationDetail & operationd
 
 bool ext4::create( const Partition & new_partition, OperationDetail & operationdetail )
 {
-	return ! execute_command( "mkfs.ext4 -j -O extent -L \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) ;
+	return ! execute_command( "mkfs.ext4 -j -O extent -L \"" + new_partition .get_label() + "\" " + new_partition .get_path(), operationdetail ) ;
 }
 
 bool ext4::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
diff --git a/src/fat16.cc b/src/fat16.cc
index 47e2737..e50096a 100644
--- a/src/fat16.cc
+++ b/src/fat16.cc
@@ -162,7 +162,7 @@ void fat16::read_label( Partition & partition )
 
 	if ( ! Utils::execute_command( cmd, output, error, true ) )
 	{
-		partition .label = Utils::trim( Utils::regexp_label( output, "Volume label is ([^(]*)" ) ) ;
+		partition .set_label( Utils::trim( Utils::regexp_label( output, "Volume label is ([^(]*)" ) ) ) ;
 	}
 	else
 	{
@@ -186,10 +186,11 @@ bool fat16::write_label( const Partition & partition, OperationDetail & operatio
 	err_msg = Utils::create_mtoolsrc_file( fname, dletter, partition.get_path() ) ;
 
 	Glib::ustring cmd = "" ;
-	if( partition .label .empty() )
+	if ( partition .get_label() .empty() )
 		cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel -c %2:", fname, dletter ) ;
 	else
-		cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel %2:\"%3\"", fname, dletter, Utils::fat_compliant_label( partition .label ) ) ;
+		cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel %2:\"%3\"",
+		                        fname, dletter, Utils::fat_compliant_label( partition .get_label() ) ) ;
 	
 	operationdetail .add_child( OperationDetail( cmd, STATUS_NONE, FONT_BOLD_ITALIC ) ) ;
 	
@@ -267,7 +268,8 @@ bool fat16::write_uuid( const Partition & partition, OperationDetail & operation
 
 bool fat16::create( const Partition & new_partition, OperationDetail & operationdetail )
 {
-	return ! execute_command( "mkdosfs -F16 -v -n \"" + Utils::fat_compliant_label( new_partition .label ) + "\" " + new_partition .get_path(), operationdetail ) ;
+	return ! execute_command( "mkdosfs -F16 -v -n \"" + Utils::fat_compliant_label( new_partition .get_label() ) +
+	                          "\" " + new_partition .get_path(), operationdetail ) ;
 }
 
 bool fat16::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
diff --git a/src/fat32.cc b/src/fat32.cc
index 686446e..e58bef4 100644
--- a/src/fat32.cc
+++ b/src/fat32.cc
@@ -150,7 +150,7 @@ void fat32::read_label( Partition & partition )
 
 	if ( ! Utils::execute_command( cmd, output, error, true ) )
 	{
-		partition .label = Utils::trim( Utils::regexp_label( output, "Volume label is ([^(]*)" ) ) ;
+		partition .set_label( Utils::trim( Utils::regexp_label( output, "Volume label is ([^(]*)" ) ) ) ;
 	}
 	else
 	{
@@ -174,10 +174,11 @@ bool fat32::write_label( const Partition & partition, OperationDetail & operatio
 	err_msg = Utils::create_mtoolsrc_file( fname, dletter, partition.get_path() ) ;
 
 	Glib::ustring cmd = "" ;
-	if( partition .label .empty() )
+	if ( partition .get_label() .empty() )
 		cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel -c %2:", fname, dletter ) ;
 	else
-		cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel %2:\"%3\"", fname, dletter, Utils::fat_compliant_label( partition .label ) ) ;
+		cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel %2:\"%3\"",
+		                        fname, dletter, Utils::fat_compliant_label( partition .get_label() ) ) ;
 	operationdetail .add_child( OperationDetail( cmd, STATUS_NONE, FONT_BOLD_ITALIC ) ) ;
 	
 	int exit_status = Utils::execute_command( cmd, output, error ) ;
@@ -255,7 +256,8 @@ bool fat32::write_uuid( const Partition & partition, OperationDetail & operation
 
 bool fat32::create( const Partition & new_partition, OperationDetail & operationdetail )
 {
-	return ! execute_command( "mkdosfs -F32 -v -n \"" + Utils::fat_compliant_label( new_partition .label ) + "\" " + new_partition .get_path(), operationdetail ) ;
+	return ! execute_command( "mkdosfs -F32 -v -n \"" + Utils::fat_compliant_label( new_partition .get_label() ) +
+	                          "\" " + new_partition .get_path(), operationdetail ) ;
 }
 
 bool fat32::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
diff --git a/src/hfs.cc b/src/hfs.cc
index 6a2b953..c30e13c 100644
--- a/src/hfs.cc
+++ b/src/hfs.cc
@@ -61,8 +61,10 @@ void hfs::read_label( Partition & partition )
 	{
 		Glib::ustring label = Utils::regexp_label( output, "ID_FS_LABEL=([^\n]*)" ) ;
 		//FIXME: find a better way to see if label is empty.. imagine someone uses 'untitled' as label.... ;)
-		if( label != "untitled" ) 
-			partition .label = label ; 
+		if ( label != "untitled" )
+			partition .set_label( label ) ;
+		else
+			partition .set_label( "" ) ;
 	}
 	else
 	{
@@ -91,10 +93,10 @@ bool hfs::write_uuid( const Partition & partition, OperationDetail & operationde
 bool hfs::create( const Partition & new_partition, OperationDetail & operationdetail )
 {
 	Glib::ustring cmd = "";
-	if( new_partition .label .empty() )
+	if( new_partition .get_label() .empty() )
 		cmd = "hformat " + new_partition .get_path() ;
 	else
-		cmd = "hformat -l \"" + new_partition .label + "\" " + new_partition .get_path() ;
+		cmd = "hformat -l \"" + new_partition .get_label() + "\" " + new_partition .get_path() ;
 	return ! execute_command( cmd , operationdetail ) ;
 }
 
diff --git a/src/hfsplus.cc b/src/hfsplus.cc
index 24104e7..f662315 100644
--- a/src/hfsplus.cc
+++ b/src/hfsplus.cc
@@ -59,8 +59,10 @@ void hfsplus::read_label( Partition & partition )
 	{
 		Glib::ustring label = Utils::regexp_label( output, "ID_FS_LABEL=([^\n]*)" ) ;
 		//FIXME: find a better way to see if label is empty.. imagine someone uses 'untitled' as label.... ;)
-		if( label != "untitled" ) 
-			partition .label = label ; 
+		if ( label != "untitled" )
+			partition .set_label( label ) ;
+		else
+			partition .set_label( "" ) ;
 	}
 	else
 	{
@@ -89,10 +91,10 @@ bool hfsplus::write_uuid( const Partition & partition, OperationDetail & operati
 bool hfsplus::create( const Partition & new_partition, OperationDetail & operationdetail )
 {
 	Glib::ustring cmd = "";
-	if( new_partition .label .empty() )
+	if( new_partition .get_label() .empty() )
 		cmd = "mkfs.hfsplus " + new_partition .get_path() ;
 	else
-		cmd = "mkfs.hfsplus -v \"" + new_partition .label + "\" " + new_partition .get_path() ;
+		cmd = "mkfs.hfsplus -v \"" + new_partition .get_label() + "\" " + new_partition .get_path() ;
 	return ! execute_command( cmd , operationdetail ) ;
 }
 
diff --git a/src/jfs.cc b/src/jfs.cc
index 2d92201..d938903 100644
--- a/src/jfs.cc
+++ b/src/jfs.cc
@@ -109,7 +109,7 @@ void jfs::read_label( Partition & partition )
 {
 	if ( ! Utils::execute_command( "jfs_tune -l " + partition .get_path(), output, error, true ) )
 	{
-		partition .label = Utils::regexp_label( output, "^Volume label:[\t ]*'(.*)'" ) ;
+		partition .set_label( Utils::regexp_label( output, "^Volume label:[\t ]*'(.*)'" ) ) ;
 	}
 	else
 	{
@@ -123,7 +123,7 @@ void jfs::read_label( Partition & partition )
 
 bool jfs::write_label( const Partition & partition, OperationDetail & operationdetail )
 {
-	return ! execute_command( "jfs_tune -L \"" + partition .label + "\" " + partition .get_path(), operationdetail ) ;
+	return ! execute_command( "jfs_tune -L \"" + partition .get_label() + "\" " + partition .get_path(), operationdetail ) ;
 }
 
 void jfs::read_uuid( Partition & partition )
@@ -149,7 +149,7 @@ bool jfs::write_uuid( const Partition & partition, OperationDetail & operationde
 
 bool jfs::create( const Partition & new_partition, OperationDetail & operationdetail )
 {
-	return ! execute_command( "mkfs.jfs -q -L \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) ;
+	return ! execute_command( "mkfs.jfs -q -L \"" + new_partition .get_label() + "\" " + new_partition .get_path(), operationdetail ) ;
 }
 
 bool jfs::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
diff --git a/src/linux_swap.cc b/src/linux_swap.cc
index a617e5a..73c68dc 100644
--- a/src/linux_swap.cc
+++ b/src/linux_swap.cc
@@ -74,7 +74,7 @@ void linux_swap::read_label( Partition & partition )
 {
 	if ( ! Utils::execute_command( "vol_id " + partition .get_path(), output, error, true ) )
 	{
-		partition .label = Utils::regexp_label( output, "ID_FS_LABEL=([^\n]*)" ) ;
+		partition .set_label( Utils::regexp_label( output, "ID_FS_LABEL=([^\n]*)" ) ) ;
 	}
 	else
 	{
@@ -88,7 +88,7 @@ void linux_swap::read_label( Partition & partition )
 
 bool linux_swap::write_label( const Partition & partition, OperationDetail & operationdetail )
 {
-	return ! execute_command( "swaplabel -L \"" + partition .label + "\" " + partition .get_path(), operationdetail ) ;
+	return ! execute_command( "swaplabel -L \"" + partition .get_label() + "\" " + partition .get_path(), operationdetail ) ;
 }
 
 void linux_swap::read_uuid( Partition & partition )
@@ -115,7 +115,7 @@ bool linux_swap::write_uuid( const Partition & partition, OperationDetail & oper
 
 bool linux_swap::create( const Partition & new_partition, OperationDetail & operationdetail )
 {
-	return ! execute_command( "mkswap -L \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) ;
+	return ! execute_command( "mkswap -L \"" + new_partition .get_label() + "\" " + new_partition .get_path(), operationdetail ) ;
 }
 
 bool linux_swap::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
@@ -125,7 +125,7 @@ bool linux_swap::resize( const Partition & partition_new, OperationDetail & oper
 		String::ucompose( _("create new %1 file system"), Utils::get_filesystem_string( FS_LINUX_SWAP ) ) ) ) ;
 
 	//Maintain label and uuid when recreating swap
-	Glib::ustring command = "mkswap -L \"" + partition_new .label + "\" " ;
+	Glib::ustring command = "mkswap -L \"" + partition_new .get_label() + "\" " ;
 	if ( ! partition_new .uuid .empty() )
 		command +=  " -U \"" + partition_new .uuid + "\" " ;
 	command += partition_new .get_path() ;
diff --git a/src/nilfs2.cc b/src/nilfs2.cc
index d9bdb46..250fb17 100644
--- a/src/nilfs2.cc
+++ b/src/nilfs2.cc
@@ -110,7 +110,9 @@ void nilfs2::read_label( Partition & partition )
 	{
 		Glib::ustring label = Utils::regexp_label( output, "^Filesystem volume name:[\t ]*(.*)$" ) ;
 		if ( label != "(none)" )
-			partition .label = label;
+			partition .set_label( label ) ;
+		else
+			partition .set_label( "" ) ;
 	}
 	else
 	{
@@ -124,7 +126,7 @@ void nilfs2::read_label( Partition & partition )
 
 bool nilfs2::write_label( const Partition & partition, OperationDetail & operationdetail )
 {
-	return ! execute_command( "nilfs-tune -L \"" + partition .label + "\" " + partition .get_path(), operationdetail ) ;
+	return ! execute_command( "nilfs-tune -L \"" + partition .get_label() + "\" " + partition .get_path(), operationdetail ) ;
 }
 
 void nilfs2::read_uuid( Partition & partition )
@@ -150,7 +152,7 @@ bool nilfs2::write_uuid( const Partition & partition, OperationDetail & operatio
 
 bool nilfs2::create( const Partition & new_partition, OperationDetail & operationdetail )
 {
-	return ! execute_command( "mkfs.nilfs2 -L \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) ;
+	return ! execute_command( "mkfs.nilfs2 -L \"" + new_partition .get_label() + "\" " + new_partition .get_path(), operationdetail ) ;
 }
 
 bool nilfs2::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
diff --git a/src/ntfs.cc b/src/ntfs.cc
index 1f6e228..2365fe5 100644
--- a/src/ntfs.cc
+++ b/src/ntfs.cc
@@ -144,7 +144,7 @@ void ntfs::read_label( Partition & partition )
 {
 	if ( ! Utils::execute_command( "ntfslabel --force " + partition .get_path(), output, error, false ) )
 	{
-		partition .label = Utils::trim( output ) ;
+		partition .set_label( Utils::trim( output ) ) ;
 	}
 	else
 	{
@@ -158,7 +158,7 @@ void ntfs::read_label( Partition & partition )
 
 bool ntfs::write_label( const Partition & partition, OperationDetail & operationdetail )
 {
-	return ! execute_command( "ntfslabel --force " + partition .get_path() + " \"" + partition .label + "\"", operationdetail ) ;
+	return ! execute_command( "ntfslabel --force " + partition .get_path() + " \"" + partition .get_label() + "\"", operationdetail ) ;
 }
 
 void ntfs::read_uuid( Partition & partition )
@@ -177,7 +177,7 @@ bool ntfs::write_uuid( const Partition & partition, OperationDetail & operationd
 
 bool ntfs::create( const Partition & new_partition, OperationDetail & operationdetail )
 {
-	return ! execute_command( "mkntfs -Q -v -L \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) ;
+	return ! execute_command( "mkntfs -Q -v -L \"" + new_partition .get_label() + "\" " + new_partition .get_path(), operationdetail ) ;
 }
 
 bool ntfs::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
diff --git a/src/reiser4.cc b/src/reiser4.cc
index 459d664..ed31061 100644
--- a/src/reiser4.cc
+++ b/src/reiser4.cc
@@ -96,7 +96,7 @@ void reiser4::read_label( Partition & partition )
 {
 	if ( ! Utils::execute_command( "debugfs.reiser4 " + partition .get_path(), output, error, true ) )
 	{
-		partition .label = Utils::regexp_label( output, "^label:[[:blank:]]*(.*)$" ) ;
+		partition .set_label( Utils::regexp_label( output, "^label:[[:blank:]]*(.*)$" ) ) ;
 	}
 	else
 	{
@@ -136,7 +136,7 @@ bool reiser4::write_uuid( const Partition & partition, OperationDetail & operati
 
 bool reiser4::create( const Partition & new_partition, OperationDetail & operationdetail )
 {
-	return ! execute_command( "mkfs.reiser4 --yes --label \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) ; 
+	return ! execute_command( "mkfs.reiser4 --yes --label \"" + new_partition .get_label() + "\" " + new_partition .get_path(), operationdetail ) ;
 }
 
 bool reiser4::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
diff --git a/src/reiserfs.cc b/src/reiserfs.cc
index 5e54f50..9a9a264 100644
--- a/src/reiserfs.cc
+++ b/src/reiserfs.cc
@@ -109,7 +109,7 @@ void reiserfs::read_label( Partition & partition )
 {
 	if ( ! Utils::execute_command( "debugreiserfs " + partition .get_path(), output, error, true ) )
 	{
-		partition .label = Utils::regexp_label( output, "^label:[\t ]*(.*)$" ) ;
+		partition .set_label( Utils::regexp_label( output, "^label:[\t ]*(.*)$" ) ) ;
 	}
 	else
 	{
@@ -123,7 +123,7 @@ void reiserfs::read_label( Partition & partition )
 	
 bool reiserfs::write_label( const Partition & partition, OperationDetail & operationdetail )
 {
-	return ! execute_command( "reiserfstune --label \"" + partition .label + "\" " + partition .get_path(), operationdetail ) ;
+	return ! execute_command( "reiserfstune --label \"" + partition .get_label() + "\" " + partition .get_path(), operationdetail ) ;
 }
 
 void reiserfs::read_uuid( Partition & partition )
@@ -149,7 +149,7 @@ bool reiserfs::write_uuid( const Partition & partition, OperationDetail & operat
 
 bool reiserfs::create( const Partition & new_partition, OperationDetail & operationdetail )
 {
-	return ! execute_command( "mkreiserfs -f --label \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) ;
+	return ! execute_command( "mkreiserfs -f --label \"" + new_partition .get_label() + "\" " + new_partition .get_path(), operationdetail ) ;
 }
 
 bool reiserfs::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
diff --git a/src/xfs.cc b/src/xfs.cc
index 252c0f8..dcaa20e 100644
--- a/src/xfs.cc
+++ b/src/xfs.cc
@@ -119,7 +119,7 @@ void xfs::read_label( Partition & partition )
 {
 	if ( ! Utils::execute_command( "xfs_db -r -c 'label' " + partition .get_path(), output, error, true ) )
 	{
-		partition .label = Utils::regexp_label( output, "^label = \"(.*)\"" ) ;
+		partition .set_label( Utils::regexp_label( output, "^label = \"(.*)\"" ) ) ;
 	}
 	else
 	{
@@ -134,10 +134,10 @@ void xfs::read_label( Partition & partition )
 bool xfs::write_label( const Partition & partition, OperationDetail & operationdetail )
 {
 	Glib::ustring cmd = "" ;
-	if( partition .label .empty() )
+	if( partition .get_label() .empty() )
 		cmd = String::ucompose( "xfs_admin -L -- %1", partition .get_path() ) ;
 	else
-		cmd = String::ucompose( "xfs_admin -L \"%1\" %2", partition .label, partition .get_path() ) ;
+		cmd = String::ucompose( "xfs_admin -L \"%1\" %2", partition .get_label(), partition .get_path() ) ;
 	return ! execute_command( cmd, operationdetail ) ;
 }
 
@@ -165,7 +165,7 @@ bool xfs::write_uuid( const Partition & partition, OperationDetail & operationde
 bool xfs::create( const Partition & new_partition, OperationDetail & operationdetail )
 {
 	//mkfs.xfs will not create file system if label is longer than 12 characters, hence truncation.
-	Glib::ustring label = new_partition .label ;
+	Glib::ustring label = new_partition .get_label() ;
 	if( label .length() > 12 )
 		label = label.substr( 0, 12 ) ;
 	return ! execute_command( "mkfs.xfs -f -L \"" + label + "\" " + new_partition .get_path(), operationdetail ) ;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]