[Tux3] [PATCH] Add check for ileaf dict ordering

Conrad Meyer konrad at tylerc.org
Tue Sep 2 06:47:40 PDT 2008


diff -r fd5ca07f03dd user/test/ileaf.c
--- a/user/test/ileaf.c	Tue Sep 02 00:06:45 2008 -0700
+++ b/user/test/ileaf.c	Tue Sep 02 06:47:17 2008 -0700
@@ -124,11 +124,23 @@
 	return attrs;
 }
 
+int isinorder(BTREE, struct ileaf *leaf)
+{
+	u16 *dict = (void *)leaf + btree->sb->blocksize;
+	for (int i = 0, offset = 0, limit; i > -leaf->count; i--, offset = limit)
+		if ((limit = dict[i]) < offset)
+			return 0;
+	return 1;
+}
+
 int ileaf_check(BTREE, struct ileaf *leaf)
 {
 	char *why;
 	why = "not an inode table leaf";
 	if (leaf->magic != 0x90de);
+		goto eek;
+	why = "dict out of order";
+	if (!isinorder(btree, leaf))
 		goto eek;
 	return 0;
 eek:



_______________________________________________
Tux3 mailing list
Tux3 at tux3.org
http://tux3.org/cgi-bin/mailman/listinfo/tux3



More information about the Tux3 mailing list