linux 内核模块调试错误

 各位,我在编译内核模块时有一个错误调了很久也没解决,请那位仁兄帮忙看看,
666 static __init int  cbac_init(void)
667 {
668         struct cred *cred;
669
670         if (!security_module_enable(&cbac_ops))
671         return 0;
672
673         printk(KERN_INFO "cbac:  InitializE ");
674 /*
675 * Set the security state for the initial task.
676  */
677         cred = (struct cred *) current->cred;
678         cred->security = &c_f_key.cbackey;
679
680       /*register new key */
681    //        if (register_key_type(struct key_type *ckey))
682    //      printk(KERN_INFO "CBACKEY INITIALIZED");
683      /* Register with LSM*/
684         if (register_security(&cbac_ops))
685         panic("cbac: Unable to register with kernel.\n");
686
687         return 0;
688 }
689
690  /*cbac requires early initialization in order to label
691  *  all processes and objects when they are created.
692  */
693   security_initcall(cbac_init);

调试结果:
security/cbac/cbac_lsm.c:665:20: 错误:函数‘cbac_init’存储类无效
security/cbac/cbac_lsm.c:693:1: 错误:初始值设定元素不是常量
security/cbac/cbac_lsm.c:693:1: 错误:expected declaration or statement at end of input
就是一个内核模块注册和初始化函数,是仿照源代码里面的现有函数写的
函数体里面可以不看,主要就是666 和693行出错
函数‘cbac_init’存储类无效,将static关键字去掉会消除这个报错,但是问题还是得不到解决,
源码加了 static关键字就没事,我这里就报错,不知道为什么
最可恨的还是 666行的__init(宏) 和693行的 security_initcall,一层层往下追最后还是没有弄清这两个函数
查这两个函数可以到这个网址 lxr.linux.no/#linux+v2.6.39/ 有搜索栏
请朋友帮忙消除第二行报错。谢了!


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值