static void sprintf_item_head (char * buf, struct item_head * ih) { if (ih) { strcpy (buf, (ih_version (ih) == KEY_FORMAT_3_6) ? "*3.6* " : "*3.5*"); sprintf_le_key (buf + strlen (buf), &(ih->ih_key)); sprintf (buf + strlen (buf), ", item_len %d, item_location %d, " "free_space(entry_count) %d", ih_item_len(ih), ih_location(ih), ih_free_space (ih)); } else sprintf (buf, "[NULL]"); }
static void sprintf_item_head (char * buf, struct item_head * ih) { if (ih) { sprintf (buf, "%s", (ih_version (ih) == ITEM_VERSION_2) ? "*NEW* " : "*OLD*"); sprintf_le_key (buf + strlen (buf), &(ih->ih_key)); sprintf (buf + strlen (buf), ", item_len %d, item_location %d, " "free_space(entry_count) %d", ih_item_len(ih), ih_location(ih), ih_free_space (ih)); } else sprintf (buf, "[NULL]"); }
/* Get the next key, i.e. the key following the last retrieved key in * tree order. INFO->current_ih and * INFO->current_info are adapted accordingly. */ static int next_key( void ) { __u16 depth; struct item_head *ih = INFO->current_ih + 1; char *cache; DEBUG_F( "next_key:\n old ih: key %u:%u:%u:%u version:%u\n", le32_to_cpu(INFO->current_ih->ih_key.k_dir_id), le32_to_cpu(INFO->current_ih->ih_key.k_objectid), le32_to_cpu(INFO->current_ih->ih_key.u.k_offset_v1.k_offset), le32_to_cpu(INFO->current_ih->ih_key.u.k_offset_v1.k_uniqueness), ih_version(INFO->current_ih) ); if ( ih == &ITEMHEAD[blkh_nr_item(BLOCKHEAD( LEAF ))] ) { depth = BLKH_LEVEL_LEAF; /* The last item, was the last in the leaf node. * Read in the next * * block */ do { if ( depth == INFO->tree_depth ) { /* There are no more keys at all. * Return a dummy item with * * MAX_KEY */ ih = ( struct item_head * ) &BLOCKHEAD( LEAF )->blk_right_delim_key; goto found; } depth++; DEBUG_F( " depth=%u, i=%u\n", depth, INFO->next_key_nr[depth] ); } while ( INFO->next_key_nr[depth] == 0 ); if ( depth == INFO->tree_depth ) cache = ROOT; else if ( depth <= INFO->cached_slots ) cache = CACHE( depth ); else { cache = read_tree_node( INFO->blocks[depth], --depth ); if ( !cache ) return 0; } do { __u16 nr_item = blkh_nr_item(BLOCKHEAD( cache )); int key_nr = INFO->next_key_nr[depth]++; DEBUG_F( " depth=%u, i=%u/%u\n", depth, key_nr, nr_item ); if ( key_nr == nr_item ) /* This is the last item in this block, set the next_key_nr * * to 0 */ INFO->next_key_nr[depth] = 0; cache = read_tree_node( dc_block_number( &(DC( cache )[key_nr])), --depth ); if ( !cache ) return 0; } while ( depth > BLKH_LEVEL_LEAF ); ih = ITEMHEAD; } found: INFO->current_ih = ih; INFO->current_item = &LEAF[ih_location(ih)]; DEBUG_F( " new ih: key %u:%u:%u:%u version:%u\n", le32_to_cpu(INFO->current_ih->ih_key.k_dir_id), le32_to_cpu(INFO->current_ih->ih_key.k_objectid), le32_to_cpu(INFO->current_ih->ih_key.u.k_offset_v1.k_offset), le32_to_cpu(INFO->current_ih->ih_key.u.k_offset_v1.k_uniqueness), ih_version(INFO->current_ih) ); return 1; }