punch_hole(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ punch_hole(9) ✨

okay bestie, welcome to the Kernel API Manual β€” today’s main character is punch_hole(9), and she is literally here to deallocate blocks in a file πŸ’…


🌸 NAME 🌸

punch_hole β€” deallocate blocks in a file

πŸ¦‹ SYNOPSIS πŸ¦‹

int punch_hole (struct gfs2_inode *ip , u64 offset , u64 length );

πŸŽ€ ARGUMENTS πŸŽ€

  • ip β€” inode to truncate
  • offset β€” the start of the hole
  • length β€” the size of the hole (or 0 for truncate)

πŸ’– DESCRIPTION πŸ’–

okay so punch_hole punches a hole into a file or truncates a file at a given position. That’s the whole vibe ✨

It operates in whole blocks β€” offset and length are rounded accordingly β€” and partially filled blocks must be cleared otherwise. No cap, that part matters.

This function works from the bottom up, and from the right to the left. In other words, it strips off the highest layer (data) before stripping any of the metadata. Doing it this way is best in case the operation is interrupted by power failure, etc. And the dinode is rewritten in every transaction to guarantee integrity. Iconic behavior, honestly πŸ‘‘

🌈 SEE ALSO 🌈

lowkey go read these too, iykyk:


k bye bestie 🫢 source: ./fs/gfs2 Β· date: October 2026 Β· page: punch_hole(9) πŸ’–

πŸ“¦ where this page comes from