[gparted] Recognise when Linux swap label is changed to blank (#685656)



commit 5ca702019efe4f16bbe616992d25569d3d307eef
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Thu Oct 11 00:07:08 2012 +0100

    Recognise when Linux swap label is changed to blank (#685656)
    
    Use swaplabel to read the Linux swap label so that 1) a blank label can
    be read, and 2) to replace deprecated and removed vol_id.
    
    Vol_id was deprecated in May 2009, superseded by blkid and soon
    thereafter removed.  Swaplabel is available in util-linux 2.18 from Jun
    2010.
    
    If the swaplabel command is not available GParted falls back on reading
    the label through the FS_Info cache which uses the blkid command.  If
    the blkid command is also not available FS_Info cache will *NOT* return
    any label and GParted will display blank.
    
    Bug 685656 - GParted doesn't notice when file system label is changed to
                 blank

 src/linux_swap.cc |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)
---
diff --git a/src/linux_swap.cc b/src/linux_swap.cc
index 73c68dc..29a43cd 100644
--- a/src/linux_swap.cc
+++ b/src/linux_swap.cc
@@ -50,11 +50,9 @@ FS linux_swap::get_filesystem_support()
 		fs .shrink = GParted::FS::EXTERNAL ;
 	}
 
-	if ( ! Glib::find_program_in_path( "vol_id" ) .empty() )
-		fs .read_label = FS::EXTERNAL ;
-
 	if ( ! Glib::find_program_in_path( "swaplabel" ) .empty() )
 	{
+		fs .read_label = FS::EXTERNAL ;
 		fs .write_label = FS::EXTERNAL ;
 		fs .read_uuid = FS::EXTERNAL ;
 		fs .write_uuid = FS::EXTERNAL ;
@@ -72,9 +70,9 @@ void linux_swap::set_used_sectors( Partition & partition )
 
 void linux_swap::read_label( Partition & partition )
 {
-	if ( ! Utils::execute_command( "vol_id " + partition .get_path(), output, error, true ) )
+	if ( ! Utils::execute_command( "swaplabel " + partition .get_path(), output, error, true ) )
 	{
-		partition .set_label( Utils::regexp_label( output, "ID_FS_LABEL=([^\n]*)" ) ) ;
+		partition .set_label( Utils::regexp_label( output, "^LABEL:[[:blank:]]*(.*)$" ) ) ;
 	}
 	else
 	{



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