Wrap text
Report abuse
|
|
diff -r bc704c9af6d6 user/test/ileaf.c
--- a/user/test/ileaf.c Tue Sep 02 10:17:39 2008 -0700
+++ b/user/test/ileaf.c Tue Sep 02 10:19:14 2008 -0700
@@ -133,11 +133,32 @@
return 1;
}
+int attr_check(BTREE, struct ileaf *leaf)
+{
+ u16 *dict = (void *)leaf + btree->sb->blocksize;
+ for (int i = 0, offset = 0, limit; i > -leaf->count; i--, offset = limit)
+ {
+ unsigned head, kind;
+ limit = dict[i];
+ if (limit - offset >= 2)
+ {
+ decode16(leaf->table + offset, &head);
+ kind = head >> 12;
+ if (kind < 6 || kind > 10)
+ 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 = "not an ileaf attribute";
+ if (!attr_check(btree, leaf))
goto eek;
why = "dict out of order";
if (!isinorder(btree, leaf))
|