【问题标题】:Passing parameters from mount to kernel module将参数从挂载传递到内核模块
【发布时间】:2014-04-24 22:23:23
【问题描述】:

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

这里我想将参数 abc 从挂载传递到内核模块。

谢谢

【问题讨论】:

    标签: linux filesystems kernel kernel-module mount


    【解决方案1】:

    如果您开发自己的文件系统,您只能让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);
    

    您可以通过data 参数访问使用-o 传递的数据以进行挂载。


    如果您只想将一些数据从用户区传递到您的模块,则更简单的方法是使用module_param

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

    【讨论】:

    • 嘿,你能准确地说出如何获取 -o 参数吗?就像它们存储在字符串中一样,我们必须从中提取子字符串或其他内容?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-05
    • 2011-03-01
    相关资源
    最近更新 更多