I would like to use configfs for some personal out-of-tree kernel module of mine, but I'm having trouble understanding how to set it up.
I'm running Ubuntu Linux with the kernel v6.8.0-rc6.
Below is what I understood to be a minimally viable module with configfs working
#include <linux/configfs.h>
#include <linux/module.h>
#include <linux/init.h>
MODULE_LICENSE("GPL");
MODULE_AUTHOR("me");
MODULE_DESCRIPTION("");
static struct configfs_subsystem subsys = {
.su_group = {
.cg_item = {
.ci_namebuf = "hello",
},
},
};
static int __init setup(void)
{
config_group_init(&subsys.su_group);
return configfs_register_subsystem(&subsys); // -22 EINVAL
}
static void __exit cleanup(void)
{
configfs_unregister_subsystem(&subsys);
}
module_init(setup);
module_exit(cleanup);
It appears to be incorrect:
configfs_register_subsystem() fails and returns -22 (-EINVAL) right after insmod mymod. This is unexpected, I hoped the module to load without error and a directory named /sys/kernel/config/mymod to appear.