From: Charles Manning Date: Thu, 11 Jul 2013 05:40:46 +0000 (+1200) Subject: Add some yaffs debug functions for inspecting run-time state. X-Git-Tag: aleph1-release~50 X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=commitdiff_plain;h=6af811eebaf8da9dbb58be70fbb283ecd95f8a32 Add some yaffs debug functions for inspecting run-time state. Signed-off-by: Charles Manning --- diff --git a/yaffs_guts.c b/yaffs_guts.c index ed5a005..8507c2d 100644 --- a/yaffs_guts.c +++ b/yaffs_guts.c @@ -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]++; + } +} diff --git a/yaffs_guts.h b/yaffs_guts.h index 2225fb2..9d71c2b 100644 --- a/yaffs_guts.h +++ b/yaffs_guts.h @@ -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