[gparted] Fix btrfs volume label reading



commit cbd3170e579cc1794ada5316858829e58fbfcb85
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Mon Nov 7 23:00:00 2011 +0000

    Fix btrfs volume label reading
    
    There are still 2 issues with reading btrfs labels when falling back
    on using btrfs-show command, rather than primary method of using the
    blkid command:
    
    1)  Label is set no "none" when btrfs-show is reporting there is no
        label, although it is impossible to distinguish from the case of the
        label actually being set to "none".
    
    2)  The label has 2 trailing spaces appended as the regular expression
        matches "Label: (btrfslabel  )uuid:" rather than
        "Label: (btrfslabel)  uuid:" in the btrfs-show output.
    
    Assume a label "none" means there is no label and fix the regular
    expression.

 src/btrfs.cc |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/src/btrfs.cc b/src/btrfs.cc
index e779402..e29d913 100644
--- a/src/btrfs.cc
+++ b/src/btrfs.cc
@@ -192,7 +192,12 @@ void btrfs::read_label( Partition & partition )
 {
 	if ( ! Utils::execute_command( "btrfs-show " + partition .get_path(), output, error, true ) )
 	{
-		partition .label = Utils::regexp_label( output, "^Label:?\\s*([^\n\t]*)\\s*uuid:" ) ;
+		Glib::ustring label = Utils::regexp_label( output, "^Label: (.*)  uuid:" ) ;
+		//Btrfs-show reports "none" when there is no label, but
+		//  this is indistinguishable from the label actually
+		//  being "none".  Assume no label case.
+		if ( label != "none" )
+			partition .label = label ;
 	}
 	else
 	{



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