ext4_block_to_path(9)
π ext4_block_to_path(9) β a Kernel API Manual moment
okay so bestie, welcome to the Kernel API Manual page for ext4_block_to_path(9) and honestly? it's giving "small function, big responsibility" β¨
β¨ NAME β¨
ext4_block_to_path β parse the block number into an array of offsets π
πΈ SYNOPSIS πΈ
int ext4_block_to_path (struct inode *inode , ext4_lblk_t i_block ,
ext4_lblk_t offsets[4] , int *boundary );
like, that's the whole signature, no cap π«Ά
π¦ ARGUMENTS π¦
inodeβ the inode in question, but lowkey we only care about its superblock. it's not about the inode's whole personality, it's about its sb πi_blockβ the block number we're parsing, the main character of this whole operation πoffsetsβ the array where we stash the offsets. that's its whole job, and it ate π₯boundaryβ set this to non-zero if the referred-to block is likely to be followed (on disk) by an indirect block. yes, "likely" β it's a vibe check, not a promise π
π§ DESCRIPTION π§
so here's the lore π to store the locations of a file's data, ext4 uses a data structure that's common across UNIX filesystems β a tree of pointers anchored in the inode, with data blocks at the leaves and indirect blocks chilling in the intermediate nodes. iconic design, fr fr π
this function translates the block number into a path in that tree. the return value is the path length, and offsets[n] is the offset of the pointer to the (n+1)th node in the nth one. literally just following the breadcrumbs down the tree π
and if the block is out of range β negative or too large β a warning gets printed and zero is returned. that's the error path, bestie, don't ignore it π
π NOTE π
big one: this function doesn't find node addresses, so no IO is needed. none. zero. zip. π
all we need to know is the capacity of the indirect blocks β and we take that straight from inode->i_sb. that's the whole reason the superblock is the only part of the inode we're interested in, iykyk π
β SEE ALSO β
go read the kernel file ./fs/ext4/indirect.c first, then these besties:
ext4_get_branch(9)ext4_find_near(9)ext4_find_goal(9)ext4_blks_to_allocate(9)ext4_alloc_branch(9)ext4_splice_branch(9)ext4_find_shared(9)ext4_free_data(9)ext4_free_branches(9)ext4_ind_remove_space(9)
and that's the page! π¦ sign-off time: this gem lives in ./fs/ext4, it's dated October 2026, and the name on the tin is ext4_block_to_path(9). slay, go parse some blocks πβ¨
π¦ 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