file_ref_get(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– file_ref_get(9) πŸ’–

okay bestie, welcome to the Kernel API Manual, where today’s main character is file_ref_get(9). This is the little function that goes β€œyes, give me one reference on this file” β€” and it does it with full memory ordering. no cap, it’s giving careful refcount energy. 🫢

✨ NAME ✨

file_ref_get β€” acquire one reference on a file. πŸ’…

🌸 SYNOPSIS 🌸

bool file_ref_get (file_ref_t *ref );

πŸŽ€ ARGUMENTS πŸŽ€

  • ref β€” pointer to the reference count. literally the thing you’re trying to get a ref on, bestie.

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so this is similar to atomic_inc_not_zero, but it saturates at FILE_REF_MAXREF. yes, it has a ceiling β€” it will not just keep climbing forever.

It provides full memory ordering. 🧚✨

⭐ RETURN ⭐

  • False β€” if the attempt to acquire a reference failed. This happens when the last reference has been put already. 😭
  • True β€” if a reference was successfully acquired. slay. πŸ‘‘

🌈 SEE ALSO 🌈

Kernel file ./include/linux/file_ref.h β€” plus file_ref_init(9), file_ref_inc(9), file_ref_put(9), file_ref_put_close(9), and file_ref_read(9). go read those too, iykyk πŸ“šπŸ’–


okay that’s the whole vibe: file_ref_get(9), from ./include/linux, dated October 2026 β€” source/version noted, date noted, and this page is officially signed off with a sparkle. πŸŽ€πŸ’œ

πŸ“¦ where this page comes from