[gparted] Update file system specific validation of RFC 4122 UUIDs



commit 4f235ecb06a8e6212366257ecfaea5bfa25d461c
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Sun Sep 23 15:44:40 2012 +0100

    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.

 src/btrfs.cc      |    4 ++--
 src/ext2.cc       |    5 +----
 src/ext3.cc       |    4 +---
 src/ext4.cc       |    4 +---
 src/jfs.cc        |    4 +---
 src/linux_swap.cc |    2 +-
 src/nilfs2.cc     |    4 +---
 src/reiser4.cc    |    2 +-
 src/xfs.cc        |    4 +---
 9 files changed, 10 insertions(+), 23 deletions(-)
---
diff --git a/src/btrfs.cc b/src/btrfs.cc
index f2eb4b2..627d0a8 100644
--- a/src/btrfs.cc
+++ b/src/btrfs.cc
@@ -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 )
diff --git a/src/ext2.cc b/src/ext2.cc
index f55dd2b..6612eb0 100644
--- a/src/ext2.cc
+++ b/src/ext2.cc
@@ -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
 	{
diff --git a/src/ext3.cc b/src/ext3.cc
index 3779936..07e740b 100644
--- a/src/ext3.cc
+++ b/src/ext3.cc
@@ -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
 	{
diff --git a/src/ext4.cc b/src/ext4.cc
index e00fa44..5fdc955 100644
--- a/src/ext4.cc
+++ b/src/ext4.cc
@@ -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
 	{
diff --git a/src/jfs.cc b/src/jfs.cc
index b9aa952..5d53187 100644
--- a/src/jfs.cc
+++ b/src/jfs.cc
@@ -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
 	{
diff --git a/src/linux_swap.cc b/src/linux_swap.cc
index 2b85714..a617e5a 100644
--- a/src/linux_swap.cc
+++ b/src/linux_swap.cc
@@ -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
 	{
diff --git a/src/nilfs2.cc b/src/nilfs2.cc
index 044b257..a72972c 100644
--- a/src/nilfs2.cc
+++ b/src/nilfs2.cc
@@ -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
 	{
diff --git a/src/reiser4.cc b/src/reiser4.cc
index 54de53f..9d7472d 100644
--- a/src/reiser4.cc
+++ b/src/reiser4.cc
@@ -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
 	{
diff --git a/src/xfs.cc b/src/xfs.cc
index 37549c1..ff098a7 100644
--- a/src/xfs.cc
+++ b/src/xfs.cc
@@ -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
 	{



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