[Yaird-devel] Bug#337065: yaird support for XFS UUID and LABEL

Patrick McManus mcmanus at ducksong.com
Thu Feb 14 20:37:05 UTC 2008


This patch gives yaird support for UUID and LABEL with XFS

commit a859d72be297f7c7f6dde51ea11e347e160913a8
Author: Patrick McManus <mcmanus at ducksong.com>
Date:   Thu Feb 14 15:21:24 2008 -0500

    yaird label and uuid support for xfs
    http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=337065
    debian bug 337065 merged with Merged with #341498, #457462;
    
    XFS superblock information that allows yaird to work with UUIDs in
    /etc/fstab as it already can for ext3 and Resier
    
    Use of blkid tool is still a better idea, but this patch is consistent
    with existing support

diff --git a/perl/LabeledPartition.pm b/perl/LabeledPartition.pm
index e1c9553..5cbff3d 100644
--- a/perl/LabeledPartition.pm
+++ b/perl/LabeledPartition.pm
@@ -69,6 +69,7 @@ sub try ($) {
 	binmode ($fh);
 	$result = tryExt2 ($fh, $path) unless defined $result;
 	$result = tryReiser ($fh, $path) unless defined $result;
+	$result = tryXFS ($fh, $path) unless defined $result;
 
 	# ignore errors, could not have been very wrong
 	# if a working superblock came out of it.
@@ -149,4 +150,42 @@ sub tryReiser ($$) {
 	return $result;
 }
 
+sub tryXFS ($$)
+{
+	my ($fh, $path) = @_;
+	my $result = undef;
+       
+	# bytes 32-47 are the uuid
+	# offset is 0 - seek back to start
+	if (! seek ($fh, 0, 0)) {
+		return $result;
+	}
+
+	my $superBlock;
+	my $rc = read ($fh, $superBlock, 120);
+	if (! defined ($rc) || $rc != 120) {
+		return $result;
+	}
+
+	my ($magic, $uuid, $label) =
+		unpack
+		"N x[28] a[16] x[60] Z[12]",
+		$superBlock;
+
+	my $t = join ("", map { sprintf "%02x", ord($_) } split(//, $uuid));
+
+	if ($magic == 0x58465342) {
+
+		$uuid = fancyUuid ($uuid);
+		$result = LabeledPartition->new (
+			type => "xfs",
+			label => $label,
+			uuid => fancyUuid($t),
+			path => $path,
+			);
+
+	}
+	return $result;
+}    
+
 1;







More information about the Yaird-devel mailing list