kernfs_name(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 kernfs_name(9) β€” the kernel API manual, bestie edition 🌸

Okay so this is kernfs_name(9) from the Kernel API Manual (section 9, kernel-level, no cap) and it's honestly such a useful little guy. Let's get into it πŸ’…


✨ NAME ✨

kernfs_name β€” obtain the name of a given node. That's it, that's the whole gig πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

int kernfs_name (struct kernfs_node *kn , char *buf , size_t buflen );

πŸ’– ARGUMENTS πŸ’–

  • kn β€” the kernfs_node of interest πŸ‘€ like, the node you're curious about
  • buf β€” the buffer you want to copy kn's name into 🫢
  • buflen β€” the size of buf, in bytes, so we know how much room we've got

⭐ DESCRIPTION ⭐

So what it does is: copies the name of kn into buf of buflen bytes. The behavior is similar to strscpy β€” iykyk 😌

If kn is NULL, it fills the buffer with "(null)" instead. Nice of it honestly, no crash, just a polite little placeholder πŸ™ˆ

And the best part? This function can be called from any context. Literally any. Main character energy, it doesn't care where you call it from πŸ”₯


πŸ‘‘ RETURN πŸ‘‘

It returns the resulting length of buf.

But listen β€” if buf isn't long enough, it gets filled up to buflen-1 and nul terminated, and the function returns -E2BIG. So watch your sizes bestie, or you'll get that negative back 😭


🌈 SEE ALSO 🌈

Kernel file ./fs/kernfs/dir.c β€” and these siblings of the kernfs family, all iconic:


That's the whole page babes, go forth and get those node names πŸ’œ

Source path: ./fs/kernfs β€” dated October 2026, and yes that's the whole credit line, slay βœ¨πŸ«ΆπŸŽ€

πŸ“¦ where this page comes from