debugfs_create_dir(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 debugfs_create_dir(9) 🌸

okay so bestie, welcome to the Kernel API Manual β€” this one's called debugfs_create_dir(9) and it's literally the ✨make a folder in debugfs✨ function. pulling up a chair? good. let's go πŸ’…


✨ NAME ✨

debugfs_create_dir β€” creates a directory in the debugfs filesystem. yes. that's the whole job. iconic behaviour tbh πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

struct dentry * debugfs_create_dir (const char *name , struct dentry
*parent );

πŸ“ ARGUMENTS πŸ“

  • name β€” a pointer to a string holding the name of the directory you wanna create. like, what's it gonna be called, bestie 🏷️
  • parent β€” a pointer to the parent dentry for this file. if you set it, it should be a directory dentry, mkay? and if this parameter is NULL, then the directory gets created in the root of the debugfs filesystem. no parent, no problem 🌈

πŸ’– DESCRIPTION πŸ’–

This function creates a directory in debugfs with the given name. simple as that, no cap.

This function will return a pointer to a dentry if it succeeds. and heads up β€” that pointer must be passed to the debugfs_remove function when the file is to be removed. there's no automatic cleanup happening if your module is unloaded, so you are responsible here, bestie 😭 you. personally. nobody's coming to save you.

If an error occurs, ERR_PTR(-ERROR) will be returned. and if debugfs is not enabled in the kernel, the value -ENODEV will be returned. that's the vibe check result, fr fr πŸ’€


πŸ™ˆ NOTE πŸ™ˆ

it's expected that most callers should _ignore_ the errors returned by this function. why? because other debugfs functions handle the fact that the "dentry" passed to them could be an error, and they don't crash in that case. love that for us 🫢

Drivers should generally work fine even if debugfs fails to init anyway. so like… breathe. it's giving resilience 🌸


πŸ‘‘ SEE ALSO πŸ‘‘

Kernel file ./fs/debugfs/inode.c β€” plus the whole friend group:


and that's the page, bestie!! 🧚 sign-off time: this lil masterpiece lives at ./fs/debugfs, dated October 2026, and it's filed under debugfs_create_dir(9). slay, go make some directories, and remember to clean up after yourself πŸ’œπŸ”₯

πŸ“¦ where this page comes from