summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.de.marchi@gmail.com>2022-06-03 14:50:42 -0700
committerLucas De Marchi <lucas.de.marchi@gmail.com>2022-06-26 23:23:46 -0700
commit2ab4fbcb77aec709261a07d51c3175153c2a4dca (patch)
treebdb313871de118228c50184bb17f4f8907d6d874
parent3a92fc63098571bcf259ffe37cd1fdf69429e4af (diff)
downloadkmod-2ab4fbcb77aec709261a07d51c3175153c2a4dca.tar.gz
kmod-2ab4fbcb77aec709261a07d51c3175153c2a4dca.tar.bz2
kmod-2ab4fbcb77aec709261a07d51c3175153c2a4dca.zip
module-playground: Add debugfs entry in mod-simple
Add a debugfs file in mod-simple for manual tests: insert the module and open the file to have its refcount increased. Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
-rw-r--r--testsuite/module-playground/mod-simple.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/testsuite/module-playground/mod-simple.c b/testsuite/module-playground/mod-simple.c
index cb38580..503e4d8 100644
--- a/testsuite/module-playground/mod-simple.c
+++ b/testsuite/module-playground/mod-simple.c
@@ -1,16 +1,32 @@
+#include <linux/debugfs.h>
#include <linux/init.h>
#include <linux/module.h>
+static struct dentry *debugfs_dir;
+
+static int test_show(struct seq_file *s, void *data)
+{
+ seq_puts(s, "test");
+ return 0;
+}
+
+DEFINE_SHOW_ATTRIBUTE(test);
+
static int __init test_module_init(void)
{
+ debugfs_dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
+ debugfs_create_file("test", 0444, debugfs_dir, NULL, &test_fops);
+
return 0;
}
static void test_module_exit(void)
{
+ debugfs_remove_recursive(debugfs_dir);
}
+
module_init(test_module_init);
module_exit(test_module_exit);
MODULE_AUTHOR("Lucas De Marchi <lucas.demarchi@intel.com>");
-MODULE_LICENSE("LGPL");
+MODULE_LICENSE("GPL");