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
This commit is contained in:
Mike Fleetwood 2012-10-11 00:07:08 +01:00 committed by Mike Fleetwood
parent 686ec8f713
commit 5ca702019e
1 changed files with 3 additions and 5 deletions

View File

@ -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
{