gfs2-utils: master - gfs2_edit: Fix find_mtype and support gfs1 structures

Andrew Price andyp at fedoraproject.org
Fri May 25 10:37:45 UTC 2012


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=b1a3d725b0b5cb448ed232fb325a696aa3d32932
Commit:        b1a3d725b0b5cb448ed232fb325a696aa3d32932
Parent:        23393916ad3d8784befd9062c7faa1605199f1b5
Author:        Andrew Price <anprice at redhat.com>
AuthorDate:    Fri May 25 02:42:30 2012 +0100
Committer:     Andrew Price <anprice at redhat.com>
CommitterDate: Fri May 25 11:36:43 2012 +0100

gfs2_edit: Fix find_mtype and support gfs1 structures

Fixes up find_mtype to really iterate over the metadata array and to
choose between gfs2 and gfs1 structures.

Signed-off-by: Andrew Price <anprice at redhat.com>
---
 gfs2/edit/hexedit.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 69d1940..8311534 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -813,14 +813,15 @@ int display_block_type(int from_restore)
 	return ret_type;
 }
 
-static const struct lgfs2_metadata *find_mtype(uint32_t mtype)
+static const struct lgfs2_metadata *find_mtype(uint32_t mtype, int gfs1)
 {
 	const struct lgfs2_metadata *m = lgfs2_metadata;
 	unsigned n = 0;
 
 	do {
-		if (m->gfs2 && m->mh_type == mtype)
-			return m;
+		if (((gfs1 && m[n].gfs1) || (!gfs1 && m[n].gfs2))
+		                         && m[n].mh_type == mtype)
+			return &m[n];
 		n++;
 	} while (n < lgfs2_metadata_size);
 
@@ -934,7 +935,7 @@ static int hexdump(uint64_t startaddr, int len)
 		}
 		print_gfs2("] ");
 		if (print_field >= 0) {
-			const struct lgfs2_metadata *m = find_mtype(get_block_type(bh));
+			const struct lgfs2_metadata *m = find_mtype(get_block_type(bh), sbd.gfs1);
 			if (m) {
 				const struct lgfs2_metafield *f;
 				unsigned n;


More information about the cluster-commits mailing list