inode_newsize_ok(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 NAME 🌸

inode_newsize_ok(9) β€” bestie, this is the Kernel API Manual entry for the function that asks: may this inode be truncated to a given size? ✨

πŸ’… SYNOPSIS πŸ’…

int inode_newsize_ok (const struct inode *inode , loff_t offset );

πŸŽ€ ARGUMENTS πŸŽ€

  • inode β€” the inode that's getting truncated, aka the main character here. πŸ’–
  • offset β€” the new size you want to assign to that inode. Not a suggestion, bestie.

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so first rule: inode_newsize_ok must be called with i_rwsem held exclusively. Like, not optional, not β€œoops I forgot” β€” hold it exclusively. πŸ’…

Then it checks filesystem limits and ulimits to make sure the new inode size is within limits. It will also send SIGXFSZ when necessary. Lowkey important. πŸ‘‘

⚠️ If failure is returned, the caller must not proceed with the inode size change. Periodt.

Also: inode must be a file (not a directory), with appropriate permissions to allow truncate. And because this is giving β€œread the room”: inode_newsize_ok does NOT check these conditions. That's on the caller, bestie β€” no cap. 😭

πŸ”₯ RETURN πŸ”₯

  • 0 on success β€” slay. ✨
  • -ve errno on failure β€” not slay, handle it. πŸ’€

🌈 SEE ALSO 🌈

Kernel file ./fs/attr.c: setattr_should_drop_sgid(9), setattr_should_drop_suidgid(9), chown_ok(9), chgrp_ok(9), setattr_prepare(9), setattr_copy_mgtime(9), setattr_copy(9), notify_change(9).


mwah πŸ’‹ β€” source/version ./fs, date October 2026, page inode_newsize_ok(9). Byeee 🫢

πŸ“¦ where this page comes from