Add some yaffs debug functions for inspecting run-time state.
authorCharles Manning <cdhmanning@gmail.com>
Thu, 11 Jul 2013 05:40:46 +0000 (17:40 +1200)
committerCharles Manning <cdhmanning@gmail.com>
Thu, 11 Jul 2013 05:40:46 +0000 (17:40 +1200)
Signed-off-by: Charles Manning <cdhmanning@gmail.com>
yaffs_guts.c
yaffs_guts.h

index ed5a005ebc1873e5a30d7691db730386e9c0bd1a..8507c2d94a7b128af414c7c0ad572716d73b163d 100644 (file)
@@ -980,7 +980,7 @@ static int yaffs_find_chunk_in_group(struct yaffs_dev *dev, int the_chunk,
        return -1;
 }
 
-static int yaffs_find_chunk_in_file(struct yaffs_obj *in, int inode_chunk,
+int yaffs_find_chunk_in_file(struct yaffs_obj *in, int inode_chunk,
                                    struct yaffs_ext_tags *tags)
 {
        /*Get the Tnode, then get the level 0 offset chunk offset */
@@ -5072,3 +5072,23 @@ loff_t yaffs_oh_to_size(struct yaffs_obj_hdr *oh)
 
        return retval;
 }
+
+
+void yaffs_count_blocks_by_state(struct yaffs_dev *dev, int bs[10])
+{
+       int i;
+       struct yaffs_block_info *bi;
+       int s;
+
+       for(i = 0; i < 10; i++)
+               bs[i] = 0;
+
+       for(i = dev->internal_start_block; i <= dev->internal_end_block; i++) {
+               bi = yaffs_get_block_info(dev, i);
+               s = bi->block_state;
+               if(s > YAFFS_BLOCK_STATE_DEAD || s < YAFFS_BLOCK_STATE_UNKNOWN)
+                       bs[0]++;
+               else
+                       bs[s]++;
+       }
+}
index 2225fb27bb5055367e3d6680ad872b5b4211cf36..9d71c2b6b8b67d782d7e79cf323ca339afbcdbce 100644 (file)
@@ -989,5 +989,14 @@ void yaffs_oh_size_load(struct yaffs_obj_hdr *oh, loff_t fsize);
 loff_t yaffs_oh_to_size(struct yaffs_obj_hdr *oh);
 loff_t yaffs_max_file_size(struct yaffs_dev *dev);
 
+/*
+ * Debug function to count number of blocks in each state
+ * NB Needs to be called with correct number of integers
+ */
+
+void yaffs_count_blocks_by_state(struct yaffs_dev *dev, int bs[10]);
+
+int yaffs_find_chunk_in_file(struct yaffs_obj *in, int inode_chunk,
+                                   struct yaffs_ext_tags *tags);
 
 #endif