debugfs_create_file_unsafe(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… debugfs_create_file_unsafe(9) β€” the Kernel API Manual, bestie edition ✨

okay so this is a page from the Kernel API Manual and it's literally about debugfs_create_file_unsafe. yes the name sounds scary. no it's not that deep. come sit with me 🫢


🌸 NAME 🌸

debugfs_create_file_unsafe β€” create a file in the debugfs filesystem πŸ’–


✨ SYNOPSIS ✨

struct dentry * debugfs_create_file_unsafe (const char *name , umode_t
mode , struct dentry *parent , void *data , const struct file_operations
*fops );

that's the whole signature, character for character, no cap πŸ‘‘


πŸŽ€ ARGUMENTS πŸŽ€

  • name β€” a pointer to a string holding the name of the file you wanna create. like, what's it called bestie 🏷️
  • mode β€” the permission the file should have. the vibe check on who gets to touch it πŸ”
  • parent β€” a pointer to the parent dentry for this file. if it's set, this should be a directory dentry. and if this parameter is NULL, the file gets created in the root of the debugfs filesystem. iconique default behavior πŸ’…
  • data β€” a pointer to something you'll wanna get back to later. the inode.i_private pointer will point to this value on the open call. it's giving "leave a little note for future you" πŸ“
  • fops β€” a pointer to a struct file_operations that should be used for this file πŸ› οΈ

πŸ¦‹ DESCRIPTION πŸ¦‹

debugfs_create_file_unsafe is completely analogous to debugfs_create_file β€” same energy, same everything β€” the only difference being that the fops you hand it will not get protected against file removals by the debugfs core 😭

⚠️ so like, it's your responsibility to protect your struct file_operation methods against file removals by means of debugfs_file_get and debugfs_file_put. not me doing it for you, bestie. that's on you fr fr πŸ’€

good news though: ->open is still protected by debugfs. so that one's fine, we gotchu 🫢

and any struct file_operations defined by means of DEFINE_DEBUGFS_ATTRIBUTE is protected against file removals and thus, may be used here. lowkey slay ✨


πŸ‘‘ SEE ALSO πŸ‘‘

Kernel file ./fs/debugfs/inode.c plus these absolute main characters:


that's the whole page bestie, go forth and make files responsibly πŸ’œπŸŒΈβœ¨

source/version + date, coming at you from ./fs/debugfs, dated October 2026, and the page is debugfs_create_file_unsafe(9). don't forget me when you're famous πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from