Lines Matching refs:key

27 static int fallible_read_node(struct ubifs_info *c, const union ubifs_key *key,
352 ubifs_assert(c, is_hash_key(c, &zbr->key)); in lnc_add()
426 ubifs_assert(c, is_hash_key(c, &zbr->key)); in tnc_read_hashed_node()
436 err = fallible_read_node(c, &zbr->key, zbr, node); in tnc_read_hashed_node()
534 static int fallible_read_node(struct ubifs_info *c, const union ubifs_key *key, in fallible_read_node() argument
539 dbg_tnck(key, "LEB %d:%d, key ", zbr->lnum, zbr->offs); in fallible_read_node()
541 ret = try_read_node(c, node, key_type(c, key), zbr); in fallible_read_node()
547 key_read(c, &dent->key, &node_key); in fallible_read_node()
548 if (keys_cmp(c, key, &node_key) != 0) in fallible_read_node()
552 dbg_mntk(key, "dangling branch LEB %d:%d len %d, key ", in fallible_read_node()
737 static int resolve_collision(struct ubifs_info *c, const union ubifs_key *key, in resolve_collision() argument
760 if (keys_cmp(c, &(*zn)->zbranch[*n].key, key)) { in resolve_collision()
824 if (keys_cmp(c, &znode->zbranch[nn].key, key)) in resolve_collision()
868 err = fallible_read_node(c, &zbr->key, zbr, dent); in fallible_matches_name()
926 const union ubifs_key *key, in fallible_resolve_collision() argument
962 if (keys_cmp(c, &(*zn)->zbranch[*n].key, key)) { in fallible_resolve_collision()
1007 if (keys_cmp(c, &znode->zbranch[nn].key, key)) in fallible_resolve_collision()
1029 dbg_mntk(key, "dangling match LEB %d:%d len %d key ", in fallible_resolve_collision()
1071 const union ubifs_key *key, in resolve_collision_directly() argument
1090 if (keys_cmp(c, &znode->zbranch[nn].key, key)) in resolve_collision_directly()
1108 if (keys_cmp(c, &znode->zbranch[nn].key, key)) in resolve_collision_directly()
1207 int ubifs_lookup_level0(struct ubifs_info *c, const union ubifs_key *key, in ubifs_lookup_level0() argument
1214 dbg_tnck(key, "search key "); in ubifs_lookup_level0()
1215 ubifs_assert(c, key_type(c, key) < UBIFS_INVALID_KEY); in ubifs_lookup_level0()
1229 exact = ubifs_search_zbranch(c, znode, key, n); in ubifs_lookup_level0()
1251 if (exact || !is_hash_key(c, key) || *n != -1) { in ubifs_lookup_level0()
1307 if (keys_cmp(c, key, &znode->zbranch[*n].key)) { in ubifs_lookup_level0()
1343 static int lookup_level0_dirty(struct ubifs_info *c, const union ubifs_key *key, in lookup_level0_dirty() argument
1350 dbg_tnck(key, "search and dirty key "); in lookup_level0_dirty()
1368 exact = ubifs_search_zbranch(c, znode, key, n); in lookup_level0_dirty()
1395 if (exact || !is_hash_key(c, key) || *n != -1) { in lookup_level0_dirty()
1412 if (keys_cmp(c, key, &znode->zbranch[*n].key)) { in lookup_level0_dirty()
1478 int ubifs_tnc_locate(struct ubifs_info *c, const union ubifs_key *key, in ubifs_tnc_locate() argument
1487 found = ubifs_lookup_level0(c, key, &znode, &n); in ubifs_tnc_locate()
1500 if (is_hash_key(c, key)) { in ubifs_tnc_locate()
1523 err = fallible_read_node(c, key, &zbr, node); in ubifs_tnc_locate()
1556 unsigned int block = key_block(c, &bu->key); in ubifs_tnc_get_bu_keys()
1565 err = ubifs_lookup_level0(c, &bu->key, &znode, &n); in ubifs_tnc_get_bu_keys()
1584 union ubifs_key *key; in ubifs_tnc_get_bu_keys() local
1592 key = &zbr->key; in ubifs_tnc_get_bu_keys()
1594 if (key_inum(c, key) != key_inum(c, &bu->key) || in ubifs_tnc_get_bu_keys()
1595 key_type(c, key) != UBIFS_DATA_KEY) { in ubifs_tnc_get_bu_keys()
1622 next_block = key_block(c, key); in ubifs_tnc_get_bu_keys()
1664 block = key_block(c, &bu->key) + bu->blk_cnt; in ubifs_tnc_get_bu_keys()
1667 if (key_block(c, &bu->zbranch[bu->cnt - 1].key) < block) in ubifs_tnc_get_bu_keys()
1760 if (!keys_eq(c, &zbr->key, &key1)) { in validate_data_node()
1763 dbg_tnck(&zbr->key, "looked for key "); in validate_data_node()
1817 dbg_tnck(&bu->key, "key "); in ubifs_tnc_bulk_read()
1846 static int do_lookup_nm(struct ubifs_info *c, const union ubifs_key *key, in do_lookup_nm() argument
1852 dbg_tnck(key, "key "); in do_lookup_nm()
1854 found = ubifs_lookup_level0(c, key, &znode, &n); in do_lookup_nm()
1865 err = resolve_collision(c, key, &znode, &n, nm); in do_lookup_nm()
1894 int ubifs_tnc_lookup_nm(struct ubifs_info *c, const union ubifs_key *key, in ubifs_tnc_lookup_nm() argument
1904 err = ubifs_tnc_lookup(c, key, node); in ubifs_tnc_lookup_nm()
1917 return do_lookup_nm(c, key, node, nm); in ubifs_tnc_lookup_nm()
1920 static int search_dh_cookie(struct ubifs_info *c, const union ubifs_key *key, in search_dh_cookie() argument
1937 dkey = &zbr->key; in search_dh_cookie()
1939 if (key_inum(c, dkey) != key_inum(c, key) || in search_dh_cookie()
1940 key_type(c, dkey) != key_type(c, key)) { in search_dh_cookie()
1948 if (key_hash(c, key) == key_hash(c, dkey) && in search_dh_cookie()
1960 static int do_lookup_dh(struct ubifs_info *c, const union ubifs_key *key, in do_lookup_dh() argument
1967 ubifs_assert(c, is_hash_key(c, key)); in do_lookup_dh()
1969 lowest_dent_key(c, &start_key, key_inum(c, key)); in do_lookup_dh()
1976 err = search_dh_cookie(c, key, dent, cookie, &znode, &n, err); in do_lookup_dh()
1997 int ubifs_tnc_lookup_dh(struct ubifs_info *c, const union ubifs_key *key, in ubifs_tnc_lookup_dh() argument
2010 err = ubifs_tnc_lookup(c, key, node); in ubifs_tnc_lookup_dh()
2021 return do_lookup_dh(c, key, node, cookie); in ubifs_tnc_lookup_dh()
2036 union ubifs_key *key, *key1; in correct_parent_keys() local
2041 key = &znode->zbranch[0].key; in correct_parent_keys()
2042 key1 = &znode->parent->zbranch[0].key; in correct_parent_keys()
2044 while (keys_cmp(c, key, key1) < 0) { in correct_parent_keys()
2045 key_copy(c, key, key1); in correct_parent_keys()
2050 key1 = &znode->parent->zbranch[0].key; in correct_parent_keys()
2123 union ubifs_key *key = &zbr->key, *key1; in tnc_insert() local
2132 dbg_tnck(key, "inserted at %d level %d, key ", n, znode->level); in tnc_insert()
2147 dbg_tnck(key, "splitting level %d, key ", znode->level); in tnc_insert()
2163 if (znode->level == 0 && key_type(c, key) == UBIFS_DATA_KEY) { in tnc_insert()
2166 key1 = &znode->zbranch[n - 1].key; in tnc_insert()
2167 if (key_inum(c, key1) == key_inum(c, key) && in tnc_insert()
2177 key1 = &znode->zbranch[0].key; in tnc_insert()
2178 if (key_inum(c, key1) == key_inum(c, key) && in tnc_insert()
2180 key1 = &znode->zbranch[n].key; in tnc_insert()
2181 if (key_inum(c, key1) != key_inum(c, key) || in tnc_insert()
2241 dbg_tnck(key, "inserting at %d level %d, key ", n, zn->level); in tnc_insert()
2254 zbr->key = zn->zbranch[0].key; in tnc_insert()
2277 zi->zbranch[0].key = znode->zbranch[0].key; in tnc_insert()
2282 zi->zbranch[1].key = zn->zbranch[0].key; in tnc_insert()
2311 int ubifs_tnc_add(struct ubifs_info *c, const union ubifs_key *key, int lnum, in ubifs_tnc_add() argument
2318 dbg_tnck(key, "%d:%d, len %d, key ", lnum, offs, len); in ubifs_tnc_add()
2319 found = lookup_level0_dirty(c, key, &znode, &n); in ubifs_tnc_add()
2328 key_copy(c, key, &zbr.key); in ubifs_tnc_add()
2362 int ubifs_tnc_replace(struct ubifs_info *c, const union ubifs_key *key, in ubifs_tnc_replace() argument
2369 dbg_tnck(key, "old LEB %d:%d, new LEB %d:%d, len %d, key ", old_lnum, in ubifs_tnc_replace()
2371 found = lookup_level0_dirty(c, key, &znode, &n); in ubifs_tnc_replace()
2390 } else if (is_hash_key(c, key)) { in ubifs_tnc_replace()
2391 found = resolve_collision_directly(c, key, &znode, &n, in ubifs_tnc_replace()
2446 int ubifs_tnc_add_nm(struct ubifs_info *c, const union ubifs_key *key, in ubifs_tnc_add_nm() argument
2454 dbg_tnck(key, "LEB %d:%d, key ", lnum, offs); in ubifs_tnc_add_nm()
2455 found = lookup_level0_dirty(c, key, &znode, &n); in ubifs_tnc_add_nm()
2463 found = fallible_resolve_collision(c, key, &znode, &n, in ubifs_tnc_add_nm()
2466 found = resolve_collision(c, key, &znode, &n, nm); in ubifs_tnc_add_nm()
2503 key_copy(c, key, &zbr.key); in ubifs_tnc_add_nm()
2520 return ubifs_tnc_remove_nm(c, key, &noname); in ubifs_tnc_add_nm()
2549 dbg_tnck(&znode->zbranch[n].key, "deleting key "); in tnc_delete()
2653 int ubifs_tnc_remove(struct ubifs_info *c, const union ubifs_key *key) in ubifs_tnc_remove() argument
2659 dbg_tnck(key, "key "); in ubifs_tnc_remove()
2660 found = lookup_level0_dirty(c, key, &znode, &n); in ubifs_tnc_remove()
2683 int ubifs_tnc_remove_nm(struct ubifs_info *c, const union ubifs_key *key, in ubifs_tnc_remove_nm() argument
2690 dbg_tnck(key, "key "); in ubifs_tnc_remove_nm()
2691 err = lookup_level0_dirty(c, key, &znode, &n); in ubifs_tnc_remove_nm()
2697 err = fallible_resolve_collision(c, key, &znode, &n, in ubifs_tnc_remove_nm()
2700 err = resolve_collision(c, key, &znode, &n, nm); in ubifs_tnc_remove_nm()
2732 int ubifs_tnc_remove_dh(struct ubifs_info *c, const union ubifs_key *key, in ubifs_tnc_remove_dh() argument
2744 err = lookup_level0_dirty(c, key, &znode, &n); in ubifs_tnc_remove_dh()
2763 lowest_dent_key(c, &start_key, key_inum(c, key)); in ubifs_tnc_remove_dh()
2769 err = search_dh_cookie(c, key, dent, cookie, &znode, &n, err); in ubifs_tnc_remove_dh()
2801 static int key_in_range(struct ubifs_info *c, union ubifs_key *key, in key_in_range() argument
2804 if (keys_cmp(c, key, from_key) < 0) in key_in_range()
2806 if (keys_cmp(c, key, to_key) > 0) in key_in_range()
2826 union ubifs_key *key; in ubifs_tnc_remove_range() local
2836 key = from_key; in ubifs_tnc_remove_range()
2845 key = &znode->zbranch[n].key; in ubifs_tnc_remove_range()
2846 if (!key_in_range(c, key, from_key, to_key)) { in ubifs_tnc_remove_range()
2863 key = &znode->zbranch[i].key; in ubifs_tnc_remove_range()
2864 if (!key_in_range(c, key, from_key, to_key)) in ubifs_tnc_remove_range()
2873 dbg_tnck(key, "removing key "); in ubifs_tnc_remove_range()
2955 key_read(c, &xent->key, &key1); in ubifs_tnc_remove_ino()
2989 union ubifs_key *key, in ubifs_tnc_next_ent() argument
2992 int n, err, type = key_type(c, key); in ubifs_tnc_next_ent()
2998 dbg_tnck(key, "key "); in ubifs_tnc_next_ent()
2999 ubifs_assert(c, is_hash_key(c, key)); in ubifs_tnc_next_ent()
3002 err = ubifs_lookup_level0(c, key, &znode, &n); in ubifs_tnc_next_ent()
3010 err = fallible_resolve_collision(c, key, &znode, &n, in ubifs_tnc_next_ent()
3013 err = resolve_collision(c, key, &znode, &n, nm); in ubifs_tnc_next_ent()
3053 dkey = &zbr->key; in ubifs_tnc_next_ent()
3054 if (key_inum(c, dkey) != key_inum(c, key) || in ubifs_tnc_next_ent()
3231 union ubifs_key *key, int level, in lookup_znode() argument
3237 ubifs_assert(c, key_type(c, key) < UBIFS_INVALID_KEY); in lookup_znode()
3260 ubifs_search_zbranch(c, znode, key, &n); in lookup_znode()
3275 ubifs_search_zbranch(c, znode, key, &n); in lookup_znode()
3288 if (!is_hash_key(c, key)) in lookup_znode()
3314 if (keys_cmp(c, &znode->zbranch[n].key, key) < 0) in lookup_znode()
3336 if (keys_cmp(c, &znode->zbranch[n].key, key) > 0) in lookup_znode()
3359 int is_idx_node_in_tnc(struct ubifs_info *c, union ubifs_key *key, int level, in is_idx_node_in_tnc() argument
3364 znode = lookup_znode(c, key, level, lnum, offs); in is_idx_node_in_tnc()
3386 static int is_leaf_node_in_tnc(struct ubifs_info *c, union ubifs_key *key, in is_leaf_node_in_tnc() argument
3392 const int unique = !is_hash_key(c, key); in is_leaf_node_in_tnc()
3394 found = ubifs_lookup_level0(c, key, &znode, &n); in is_leaf_node_in_tnc()
3417 if (keys_cmp(c, key, &znode->zbranch[n].key)) in is_leaf_node_in_tnc()
3433 if (keys_cmp(c, key, &znode->zbranch[n].key)) in is_leaf_node_in_tnc()
3456 int ubifs_tnc_has_node(struct ubifs_info *c, union ubifs_key *key, int level, in ubifs_tnc_has_node() argument
3463 err = is_idx_node_in_tnc(c, key, level, lnum, offs); in ubifs_tnc_has_node()
3475 err = is_leaf_node_in_tnc(c, key, lnum, offs); in ubifs_tnc_has_node()
3496 int ubifs_dirty_idx_node(struct ubifs_info *c, union ubifs_key *key, int level, in ubifs_dirty_idx_node() argument
3503 znode = lookup_znode(c, key, level, lnum, offs); in ubifs_dirty_idx_node()
3536 union ubifs_key from_key, to_key, *key; in dbg_check_inode_size() local
3555 key = &from_key; in dbg_check_inode_size()
3568 key = &znode->zbranch[n].key; in dbg_check_inode_size()
3569 if (!key_in_range(c, key, &from_key, &to_key)) in dbg_check_inode_size()
3573 block = key_block(c, key); in dbg_check_inode_size()