/* * test module to try and submit one single 4K bio * with multiple bvecs */ #define pr_fmt(fmt) "hello-debugfs: " fmt #include #include #include #include #define MODULE_NAME "hello-debugfs" MODULE_VERSION("1.0"); MODULE_AUTHOR("Lars Ellenberg "); MODULE_DESCRIPTION("hello-debugfs - to excercise debugfs_remove_recursive"); MODULE_LICENSE("GPL"); static struct dentry *debug_dir; struct hello_entry { int s_ifmt; char *d_iname; u32 value; }; struct hello_entry tree[] = { { S_IFDIR, "dir1" }, { S_IFREG, "file1", 1 }, { S_IFREG, "file2", 2 }, { S_IFREG, "file3", 3 }, { S_IFREG, "file4", 4 }, { S_IFDIR, "dir2" }, { S_IFREG, "file5", 5 }, { S_IFDIR, /* .. */ }, { S_IFDIR, "dir3" }, { S_IFREG, "file6", 6 }, { S_IFREG, "file7", 7 }, { S_IFREG, "file8", 8 }, { S_IFREG, "file9", 9 }, }; int __init hello_debugfs(void) { struct dentry *dir; int i; debug_dir = debugfs_create_dir("hello-debugfs", NULL); if (IS_ERR_OR_NULL(debug_dir)) { pr_info("sorry, failed to create my top level dir\n"); if (debug_dir) return PTR_ERR(debug_dir); else return -EINVAL; } dir = debug_dir; for (i = 0; i < ARRAY_SIZE(tree); i++) { struct hello_entry *e = tree+i; switch(e->s_ifmt & S_IFMT) { default: continue; case S_IFDIR: if (!e->d_iname) { if (dir != debug_dir) dir = dir->d_parent; } else dir = debugfs_create_dir(e->d_iname, dir); break; case S_IFREG: debugfs_create_u32(e->d_iname, 0444, dir, &e->value); break; } } return 0; } static void good_bye_debugfs(void) { debugfs_remove_recursive(debug_dir); } module_init(hello_debugfs) module_exit(good_bye_debugfs)