Linux 内核模块配置

Linux kernel module configuration

对于我的大学项目,我正在做一个模块,该模块将允许或禁止进程执行系统调用(例如,一个小的可加载 selinux)。现在我有控制系统调用的代码。对于每个进程,我将 link 存储到包含权限配置的结构中。但是,现在我只是硬编码了两个配置:一个是默认配置(允许所有配置),另一个是允许除打开“/testfile”之外的所有配置。

我的问题是如何动态加载配置?

我有一个配置文件的解析器,但我读到从内核访问文件是个坏主意。

我应该如何存储配置以及如何加载它们?

I've read that reading files from the kernel is bad idea

内核源代码中filp_open函数的描述说:

This is the helper to open a file from kernelspace if you really have to. But in generally you should not do this, so please move along, nothing to see here..

所以,如果你需要到load/store文件的内容into/from内核模块,那么做.但是使用适当的功能,如 in that question.

所述