drop_nlink(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

okay so we're in the Kernel API Manual bestie, and this is the page for drop_nlink β€” yes it's a whole mood, let's get into it ✨


πŸŽ€ NAME πŸŽ€

drop_nlink β€” directly drop an inode's link count. that's it, that's the whole vibe πŸ’–


🌸 SYNOPSIS 🌸

void drop_nlink (struct inode *inode );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • inode β€” it's an inode. girl, that's the description, I don't make the rules πŸ’€

✨ DESCRIPTION ✨

so this is a low-level filesystem helper, and its whole job is to replace any direct filesystem manipulation of i_nlink β€” like, you don't touch that field yourself, you call this instead. slay 🫢

and here's the part that actually matters at 3am: in cases where we are attempting to track writes to the filesystem, a decrement to zero means an imminent write β€” that happens when the file is truncated and actually unlinked on the filesystem. so yeah, hitting zero is not a drill, it's giving "the real unlink is coming" energy πŸ”₯


πŸ‘‘ SEE ALSO πŸ‘‘

the whole squad, no cap β€” and the kernel file ./fs/inode.c is where it lives:

inode_init_always_gfp(9), alloc_inode(9), clear_nlink(9), set_nlink(9), inc_nlink(9), inode_sb_list_add(9), __insert_inode_hash(9), __remove_inode_hash(9), evict_inodes(9), new_inode(9), unlock_new_inode(9), lock_two_nondirectories(9), unlock_two_nondirectories(9), inode_insert5(9), iget5_locked(9), iget5_locked_rcu(9), iget_locked(9), iunique(9), ihold(9), ilookup5_nowait(9), ilookup5(9), ilookup(9), find_inode_nowait(9), find_inode_rcu(9), find_inode_by_ino_rcu(9), iput(9), iput_not_last(9), bmap(9), inode_update_time(9), generic_update_time(9), atime_needs_update(9), file_remove_privs(9), current_time(9), file_update_time(9), file_modified_flags(9), file_modified(9), kiocb_modified(9), inode_init_owner(9), inode_owner_or_capable(9), inode_dio_wait(9), timestamp_truncate(9), inode_set_ctime_current(9), inode_set_ctime_deleg(9), in_group_or_capable(9), mode_strip_sgid(9), dump_inode(9)


friendly reminder bestie: it's i_nlink handling done through the helper, not by hand. respect the abstraction, she's there for a reason πŸ’…

mwah πŸ’œ this lil page came from ./fs and it's dated October 2026 β€” go be iconic with your inodes, ily 🧚

πŸ“¦ where this page comes from