+static void yaffs_VerifyObjectInDirectory(yaffs_Object *obj)
+{
+ struct ylist_head *lh;
+ yaffs_Object *listObj;
+
+ int count = 0;
+
+ if(!obj){
+ T(YAFFS_TRACE_ALWAYS, (TSTR("No object to verify" TENDSTR)));
+ YBUG();
+ }
+
+ if(yaffs_SkipVerification(obj->myDev))
+ return;
+
+ if(!obj->parent){
+ T(YAFFS_TRACE_ALWAYS, (TSTR("Object does not have parent" TENDSTR)));
+ YBUG();
+ }
+
+ if(obj->parent->variantType != YAFFS_OBJECT_TYPE_DIRECTORY){
+ T(YAFFS_TRACE_ALWAYS, (TSTR("Parent is not directory" TENDSTR)));
+ YBUG();
+ }
+
+ /* Iterate through the objects in each hash entry */
+
+ ylist_for_each(lh, &obj->parent->variant.directoryVariant.children) {
+ if (lh) {
+ listObj = ylist_entry(lh, yaffs_Object, siblings);
+ yaffs_VerifyObject(listObj);
+ if(obj == listObj)
+ count ++;
+ }
+ }
+
+ if(count != 1){
+ T(YAFFS_TRACE_ALWAYS, (TSTR("Object in directory %d times" TENDSTR),count));
+ YBUG();
+ }
+
+}
+
+static void yaffs_VerifyDirectory(yaffs_Object *directory)
+{
+
+ struct ylist_head *lh;
+ yaffs_Object *listObj;
+
+ if(!directory)
+ YBUG();
+
+ if(yaffs_SkipFullVerification(directory->myDev))
+ return;
+
+
+ if(directory->variantType != YAFFS_OBJECT_TYPE_DIRECTORY){
+ T(YAFFS_TRACE_ALWAYS, (TSTR("Directory has wrong type: %d" TENDSTR),directory->variantType));
+ YBUG();
+ }
+
+ /* Iterate through the objects in each hash entry */
+
+ ylist_for_each(lh, &directory->variant.directoryVariant.children) {
+ if (lh) {
+ listObj = ylist_entry(lh, yaffs_Object, siblings);
+ if(listObj->parent != directory){
+ T(YAFFS_TRACE_ALWAYS, (TSTR("Object in directory list has wrong parent %p" TENDSTR),listObj->parent));
+ YBUG();
+ }
+ yaffs_VerifyObjectInDirectory(listObj);
+ }
+ }
+
+}
+
+