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.
This commit is contained in:
Mike Fleetwood 2011-11-07 23:00:00 +00:00 committed by Curtis Gedak
parent 07bc770c31
commit cbd3170e57
1 changed files with 6 additions and 1 deletions

View File

@ -192,7 +192,12 @@ void btrfs::read_label( Partition & partition )
{ {
if ( ! Utils::execute_command( "btrfs-show " + partition .get_path(), output, error, true ) ) 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 else
{ {