init_module - 初始化一条可加载模块的记录.

总览

#include <linux/module.h>

int init_module(const char *name, struct module *image);

描述

init_module加载已被重定位的模块映象到内核空间,并运行模块的初始化函数. 模块映象以module结构开始,紧跟着代码和数据,module定义如下:
       struct module                                              
       {
         unsigned long size_of_struct; /* module结构的大小 */
         struct module *next; /*指向下一个module结构 */
         const char *name; /* 模块名字 */
         unsigned long size;
         long usecount; /* 使用计数 */
         unsigned long flags; /* 模块当前状态标志 */
         unsigned int nsyms;
         unsigned int ndeps; /* 正使用模块的模块个数 */
         struct module_symbol *syms;
         struct module_ref *deps;
         struct module_ref *refs;
         int (*init)(void); /* 模块的初始化函数指针 */
         void (*cleanup)(void); /*模块的清除函数指针 */
         const struct exception_table_entry *ex_table_start;
         const struct exception_table_entry *ex_table_end;
       #ifdef __alpha__
         unsigned long gp;
       #endif
       }; 除了next和refs外,所有的指针被期望指在模块体内, 该系统调用只对超级用户开放.

返回值

成功时返回0,错误时返回 -1,errno被相应设置.

错误

EPERM

    用户不是超级用户.
ENOENT

    name指定的模块不存在.
EINVAL
EBUSY

    模块的初始化函数失败.
EFAULT

    name或image越出了程序可访问的地址空间. 

转载于:https://www.cnblogs.com/fanweisheng/p/11087954.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值