ext4_block_to_path(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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:


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