do_shrink(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… do_shrink β€” make a file smaller (yes, literally that) πŸŽ€

okay so this is a page from the Kernel API Manual, and it's about do_shrink(9). bestie, the name is not mysterious: it makes a file smaller. that's the whole gig. let's go ✨


🌸 SYNOPSIS 🌸

int do_shrink (struct inode *inode , u64 newsize );

that's it, that's the signature. two args, one int coming back at you 🫢


πŸ¦‹ ARGUMENTS πŸ¦‹

  • inode β€” the inode. yeah. the inode. the one we're shrinking. πŸ‘‘
  • newsize β€” the size to make the file. that's the target size, the goal, the destination, the moment πŸ’«

πŸ’– DESCRIPTION πŸ’–

so here's the vibe check: this function is called with an exclusive lock on inode. exclusive. no sharing, no plus-ones, nobody else touching this inode while we're working. πŸ”’

and the rule, the one non-negotiable rule: the size must be equal to or smaller than the current inode size. equal is fine. smaller is fine. bigger? absolutely not, that's not shrinking, that's a whole different function (do_grow(9) is right there in SEE ALSO, iykyk 😌).

no cap, if you're coming in here trying to make a file bigger, you have misunderstood the assignment πŸ’€

⭐ RETURN ⭐

errno β€” that's the return value. periodt.


🌈 SEE ALSO 🌈

it's giving extended universe, honestly. the whole bmap.c friend group shows up:

like, the entire roster. main character energy from every single one of them πŸ’…


and that's the page!! mwah πŸ“ this one came out of ./fs/gfs2, dated October 2026, and it's filed under do_shrink(9). go shrink something (smaller than it is now, PLEASE, we went over this 😭) πŸ’œ

πŸ“¦ where this page comes from