#include #include #include #include static struct dentry *root; static struct dentry *file; static int test_open(struct inode *inode, struct file *file) { return -1; } static struct file_operations test_fops = { .owner = THIS_MODULE, .open = test_open, }; static int __init test_init(void) { root = securityfs_create_dir("test", NULL); if (IS_ERR(root)) { printk("error creating root %d\n", PTR_ERR(root)); return PTR_ERR(root); } file = securityfs_create_file("file", S_IRUSR, root, NULL, &test_fops); if (IS_ERR(file)) { printk("error creating file %d\n", PTR_ERR(file)); securityfs_remove(root); return PTR_ERR(file); } return 0; } static void __exit test_exit(void) { securityfs_remove(file); securityfs_remove(root); } MODULE_LICENSE("GPL"); module_init(test_init); module_exit(test_exit);