securityfs_create_file(9)
π securityfs_create_file π
okay so this whole page is from the Kernel API Manual, section 9, and it's literally all about one function: securityfs_create_file. bestie, it makes a file in securityfs. that's the vibe. β¨
πΈ NAME πΈ
securityfs_create_file β create a file in the securityfs filesystem π
π¦ SYNOPSIS π¦
struct dentry * securityfs_create_file (const char *name , umode_t mode
, struct dentry *parent , void *data , const struct file_operations
*fops );
like, five arguments, one dentry pointer out. it's giving "small function, big responsibilities" ngl π
β¨ ARGUMENTS β¨
nameβ a pointer to a string with the name of the file you wanna create. that's its whole thing. name it something cute πmodeβ the permission the file should have. yes, the permissions. you know the ones π«Άparentβ a pointer to the parent dentry for this file. if it's set, it should be a directory dentry (obvi). and if this parameter isNULL, then the file gets created in the root of the securityfs filesystem. no parent, no problem β¨dataβ a pointer to something the caller is gonna want to get back to later on. fr fr. theinode.i_privatepointer will point to this value on the open call πfopsβ a pointer to astruct file_operationsthat should be used for this file. that's the personality of the file basically π
π DESCRIPTION π
so this function creates a file in securityfs with the given name. periodt. π¦
when it works, this function returns a pointer to a dentry. and here's the thing β you MUST pass that pointer to the securityfs_remove function when the file is to be removed. no automatic cleanup happens if your module is unloaded. none. zero. you are responsible here, bestie π
like literally, you're the main character of cleanup. own it π
if an error occurs, the function will return the error value (via ERR_PTR). yup, error value tucked inside the pointer. iykyk πΈ
and if securityfs isn't enabled in the kernel, the value -ENODEV is returned. so if you see -ENODEV, check your kernel config before you spiral π
π SEE ALSO π
- Kernel file
./security/inode.cβ like, the source of truth π securityfs_create_dentry(9)securityfs_create_dir(9)securityfs_create_symlink(9)securityfs_remove(9)β the one you have to call, remember? π
and that's the page!! π source & version vibes: ./security, dated October 2026, from the Kernel API Manual, section 9. slay, go write your securityfs files responsibly. mwah πβ¨
π¦ 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