__kernfs_create_file(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ¦‹ __kernfs_create_file(9) β€” like, the kernel API manual page, bestie πŸ¦‹

okay so this is a page straight outta the Kernel API Manual, and it's about a kernfs internal function that creates a file. yes, internal. no cap, that word is doing a lot of heavy lifting here so keep it in mind πŸ‘€


✨ NAME ✨

__kernfs_create_file β€” the kernfs internal function that creates a file πŸ’…


✨ SYNOPSIS ✨

struct kernfs_node * __kernfs_create_file (struct kernfs_node *parent ,
const char *name , umode_t mode , kuid_t uid , kgid_t gid , loff_t size
, const struct kernfs_ops *ops , void *priv , const struct ns_common *ns
, struct lock_class_key *key );

it's giving "ten whole arguments, and every single one of them matters" πŸŽ€


✨ ARGUMENTS ✨

  • parent β€” the directory you're creating the file in. it's the vibe check location, iykyk πŸ“
  • name β€” the name of the file ✏️
  • mode β€” the mode of the file πŸ”
  • uid β€” the uid of the file 🫢
  • gid β€” the gid of the file 🫢
  • size β€” the size of the file πŸ“
  • ops β€” the kernfs operations for the file βš™οΈ
  • priv β€” private data for the file πŸ“
  • ns β€” optional namespace tag of the file. optional, bestie, so don't stress 🌸
  • key β€” the lockdep key for the file's active_ref, and <italic>NULL</italic> to disable lockdep πŸ’€
literally so important: key being NULL disables lockdep. that's the documented behavior, not me being dramatic (for once) πŸ™ˆ

✨ RETURN ✨

the created node on success ✨ β€” and an ERR_PTR value on error 😭


✨ SEE ALSO ✨

go read the source, it's iconic πŸ‘‘


and that's the whole page omg πŸŽ€ this one lives under ./fs/kernfs, dated October 2026, and it's __kernfs_create_file(9) β€” go forth and create files responsibly, bestie πŸ’–πŸ¦‹βœ¨

πŸ“¦ where this page comes from