debugfs_create_dir(9)
πΈ 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 isNULL, 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:
debugfs_lookup(9)debugfs_create_file_unsafe(9)debugfs_create_file_size(9)debugfs_create_automount(9)debugfs_create_symlink(9)debugfs_remove(9)debugfs_lookup_and_remove(9)debugfs_change_name(9)debugfs_initialized(9)
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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms