将参数从mount传递到内核模块

时间:2014-03-18 23:02:46

标签: linux filesystems kernel kernel-module mount

有没有办法将参数从mount系统调用传递给内核模块。 像mount -t ext2 abc = / Dir / target。

这里我想将参数abc从mount传递给内核模块。

由于

1 个答案:

答案 0 :(得分:2)

如果您开发自己的文件系统,则只能mount为您做点什么。

在这种情况下,当您致电register_filesystem时,您需要为其提供一个file_system_type字段,其中包含.mount字段。 Mount是这个原型的函数:

struct dentry *some_mount(struct file_system_type *fs_type,
    int flags, const char *dev_name, void *data);

您可以通过-o参数访问通过data传递的数据。


如果您只想将一些数据从userland传递到您的模块,那么更简单的方法就是使用module_param

static char *abc = "";
module_param(abc, charp, 0000);
MODULE_PARM_DESC(abc, "Some string that you give to insmod");
相关问题