Update file system specific validation of RFC 4122 UUIDs

Use the new RFC 4122 none Nil UUID regular expression to validate the
UUID read in all the Linux native file system specific read_uuid()
methods.  No longer need to explicitly exclude "<none>" or all zeros Nil
UUID as the regular expression does this.
This commit is contained in:
Mike Fleetwood 2012-09-23 15:44:40 +01:00 committed by Curtis Gedak
parent aa16bf5451
commit 4f235ecb06
9 changed files with 10 additions and 23 deletions

View File

@ -285,7 +285,7 @@ void btrfs::read_uuid( Partition & partition )
exit_status = Utils::execute_command( "btrfs filesystem show " + partition .get_path(), output, error, true ) ;
if ( ! exit_status )
{
partition .uuid = Utils::regexp_label( output, "uuid:[[:blank:]]*([^[:space:]]*)" );
partition .uuid = Utils::regexp_label( output, "uuid:[[:blank:]]*(" RFC4122_NONE_NIL_UUID_REGEXP ")" ) ;
}
}
else
@ -293,7 +293,7 @@ void btrfs::read_uuid( Partition & partition )
exit_status = Utils::execute_command( "btrfs-show " + partition .get_path(), output, error, true ) ;
if ( ! exit_status )
{
partition .uuid = Utils::regexp_label( output, "uuid:[[:blank:]]*([^[:space:]]*)" );
partition .uuid = Utils::regexp_label( output, "uuid:[[:blank:]]*(" RFC4122_NONE_NIL_UUID_REGEXP ")" ) ;
}
}
if ( exit_status )

View File

@ -123,10 +123,7 @@ void ext2::read_uuid( Partition & partition )
{
if ( ! Utils::execute_command( "tune2fs -l " + partition .get_path(), output, error, true ) )
{
partition .uuid = Utils::regexp_label( output, "^Filesystem UUID:[[:blank:]]*([^[:space:]]*)" ) ;
if (partition .uuid == "<none>")
partition .uuid .clear() ;
partition .uuid = Utils::regexp_label( output, "^Filesystem UUID:[[:blank:]]*(" RFC4122_NONE_NIL_UUID_REGEXP ")" ) ;
}
else
{

View File

@ -124,9 +124,7 @@ void ext3::read_uuid( Partition & partition )
{
if ( ! Utils::execute_command( "tune2fs -l " + partition .get_path(), output, error, true ) )
{
partition .uuid = Utils::regexp_label( output, "^Filesystem UUID:[[:blank:]]*([^[:space:]]*)" ) ;
if (partition .uuid == "<none>")
partition .uuid .clear() ;
partition .uuid = Utils::regexp_label( output, "^Filesystem UUID:[[:blank:]]*(" RFC4122_NONE_NIL_UUID_REGEXP ")" ) ;
}
else
{

View File

@ -127,9 +127,7 @@ void ext4::read_uuid( Partition & partition )
{
if ( ! Utils::execute_command( "tune2fs -l " + partition .get_path(), output, error, true ) )
{
partition .uuid = Utils::regexp_label( output, "^Filesystem UUID:[[:blank:]]*([^[:space:]]*)" ) ;
if (partition .uuid == "<none>")
partition .uuid .clear() ;
partition .uuid = Utils::regexp_label( output, "^Filesystem UUID:[[:blank:]]*(" RFC4122_NONE_NIL_UUID_REGEXP ")" ) ;
}
else
{

View File

@ -130,9 +130,7 @@ void jfs::read_uuid( Partition & partition )
{
if ( ! Utils::execute_command( "jfs_tune -l " + partition .get_path(), output, error, true ) )
{
partition .uuid = Utils::regexp_label( output, "^File system UUID:[[:blank:]]*([^[:space:]]+)" ) ;
if ( partition .uuid == "00000000-0000-0000-0000-000000000000" )
partition .uuid .clear() ;
partition .uuid = Utils::regexp_label( output, "^File system UUID:[[:blank:]]*(" RFC4122_NONE_NIL_UUID_REGEXP ")" ) ;
}
else
{

View File

@ -95,7 +95,7 @@ void linux_swap::read_uuid( Partition & partition )
{
if ( ! Utils::execute_command( "swaplabel " + partition .get_path(), output, error, true ) )
{
partition .uuid = Utils::regexp_label( output, "^UUID:[[:blank:]]*([^[:space:]]*)" ) ;
partition .uuid = Utils::regexp_label( output, "^UUID:[[:blank:]]*(" RFC4122_NONE_NIL_UUID_REGEXP ")" ) ;
}
else
{

View File

@ -130,9 +130,7 @@ void nilfs2::read_uuid( Partition & partition )
{
if ( ! Utils::execute_command( "nilfs-tune -l " + partition .get_path(), output, error, true ) )
{
partition .uuid = Utils::regexp_label( output, "^Filesystem UUID:[[:blank:]]*([^[:space:]]*)" ) ;
if (partition .uuid == "00000000-0000-0000-0000-000000000000")
partition .uuid .clear() ;
partition .uuid = Utils::regexp_label( output, "^Filesystem UUID:[[:blank:]]*(" RFC4122_NONE_NIL_UUID_REGEXP ")" ) ;
}
else
{

View File

@ -117,7 +117,7 @@ void reiser4::read_uuid( Partition & partition )
{
if ( ! Utils::execute_command( "debugfs.reiser4 " + partition .get_path(), output, error, true ) )
{
partition .uuid = Utils::regexp_label( output, "uuid:[[:blank:]]*([^[:space:]]*)" ) ;
partition .uuid = Utils::regexp_label( output, "uuid:[[:blank:]]*(" RFC4122_NONE_NIL_UUID_REGEXP ")" ) ;
}
else
{

View File

@ -145,9 +145,7 @@ void xfs::read_uuid( Partition & partition )
{
if ( ! Utils::execute_command( "xfs_admin -u " + partition .get_path(), output, error, true ) )
{
partition .uuid = Utils::regexp_label( output, "^UUID[[:blank:]]*=[[:blank:]]*([^[:space:]]*)" ) ;
if (partition .uuid == "00000000-0000-0000-0000-000000000000")
partition .uuid .clear() ;
partition .uuid = Utils::regexp_label( output, "^UUID[[:blank:]]*=[[:blank:]]*(" RFC4122_NONE_NIL_UUID_REGEXP ")" ) ;
}
else
{