lookup_znode(9)
π lookup_znode β a kernel API manual, but make it make sense
okay so bestie, this is lookup_znode from section 9 of the kernel API manual β¨ it lives in the UBIFS corner of the kernel and honestly? she's doing a lot. let's get into it π«Ά
πΈ NAME πΈ
lookup_znode β find a particular indexing node from TNC. no cap, that's literally the whole job π
π SYNOPSIS π
struct ubifs_znode * lookup_znode (struct ubifs_info *c , union
ubifs_key *key , int level , int lnum , int offs );
look at her go π five args, one pointer back, iconic behavior only π
β¨ ARGUMENTS β¨
cβ the UBIFS file-system description object. the whole vibe check for the filesystem, basically π¦keyβ index node key to lookup. this is the key we're hunting with πlevelβ index node level. where in the tree we're looking πlnumβ index node LEB number. half of the address, periodt πoffsβ index node offset. the other half of that address π―
π DESCRIPTION π
so what she actually does: this function searches an indexing node by its first key key and its address lnum:offs. both. at the same time. she's thorough like that π§
while she's looking up the indexing tree, she pulls all the indexing nodes she traverses into TNC. all of them. no skipping π
she gets called for indexing nodes that were found on the media by scanning β for example when garbage-collecting, or when doing in-the-gaps commit. so think of her as the girl who shows up when stuff was discovered the hard way π₯
and here's the cute part: the indexing node she's looking for does not have to have exactly the same leftmost key key, because the leftmost key may have been changed. in that case, TNC will contain a dirty znode which still refers the same lnum:offs. and this function is clever enough to recognize such indexing nodes. she's not confused, she's just built different π
β οΈ note bestie: if a znode was deleted or changed too much, then this function will not find it. for situations like this, UBIFS has the old index RB-tree (indexed by lnum:offs). so there's a backup plan, don't panic π
she returns a pointer to the znode found, or NULL if it is not found. and a negative error code is returned on failure. so watch that return value, fr fr π
π¦ SEE ALSO π¦
the whole group chat, all here, no one left out π the file is Kernel ./fs/ubifs/tnc.c, and these are her friends:
insert_old_idx(9)insert_old_idx_znode(9)ins_clr_old_idx_znode(9)destroy_old_idx(9)copy_znode(9)add_idx_dirt(9)replace_znode(9)dirty_cow_znode(9)lnc_add(9)lnc_free(9)tnc_read_hashed_node(9)try_read_node(9)fallible_read_node(9)matches_name(9)get_znode(9)tnc_next(9)tnc_prev(9)resolve_collision(9)fallible_matches_name(9)fallible_resolve_collision(9)matches_position(9)resolve_collision_directly(9)dirty_cow_bottom_up(9)ubifs_lookup_level0(9)lookup_level0_dirty(9)maybe_leb_gced(9)ubifs_tnc_locate(9)ubifs_tnc_get_bu_keys(9)read_wbuf(9)validate_data_node(9)ubifs_tnc_bulk_read(9)do_lookup_nm(9)ubifs_tnc_lookup_nm(9)ubifs_tnc_lookup_dh(9)correct_parent_keys(9)insert_zbranch(9)tnc_insert(9)ubifs_tnc_add(9)ubifs_tnc_replace(9)ubifs_tnc_add_nm(9)tnc_delete(9)ubifs_tnc_remove(9)ubifs_tnc_remove_nm(9)ubifs_tnc_remove_dh(9)key_in_range(9)ubifs_tnc_remove_range(9)ubifs_tnc_remove_ino(9)ubifs_tnc_next_ent(9)tnc_destroy_cnext(9)ubifs_tnc_close(9)left_znode(9)right_znode(9)is_idx_node_in_tnc(9)is_leaf_node_in_tnc(9)ubifs_tnc_has_node(9)ubifs_dirty_idx_node(9)dbg_check_inode_size(9)
like, that's the entire extended universe right there ππ
π sign-off π
this page reps ./fs/ubifs, and it's dated October 2026 β so yeah, she's from the future, we don't ask questions π°οΈβ¨ mwah, go read your kernel trees bestie π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms