linux 内核模块调试错误
2011-09-09 14:44
148 查看
各位,我在编译内核模块时有一个错误调了很久也没解决,请那位仁兄帮忙看看,
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/ 有搜索栏
请朋友帮忙消除第二行报错。谢了!
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/ 有搜索栏
请朋友帮忙消除第二行报错。谢了!
相关文章推荐
- GDB简单调试linux内核与模块的方法
- Linux 2.6.x 内核模块加载错误 “Invalid module format” 解决办法
- 使用kgdb调试linux内核及内核模块
- 使用kgdb调试linux内核及内核模块
- linux 内核及驱动模块调试
- GDB简单调试linux内核与模块的方法
- 使用kgdb调试linux内核及内核模块
- 使用 GDB 和 KVM 调试 Linux 内核与模块
- 使用kgdb调试linux内核及内核模块
- Linux 内核与模块调试
- 在双机调试linux3.2内核的基础上源码调试编写的内核模块
- Linux 2.6.x 内核模块加载错误 “Invalid module format” 解决办法
- 使用kgdb调试linux内核及内核模块
- Linux 内核与模块调试
- Ubuntu 编译安装 Linux 4.0.5 内核,并修复 vmware 网络内核模块编译错误
- 使用kgdb调试linux内核及内核模块
- Linux 2.6.35内核配置 armv7 s5pv210 模块加载错误
- (转载)使用kgdb调试linux内核及内核模块
- linux 内核分析+使用SystemTap调试新增内核模块
- Linux 2.6.x 内核模块加载错误 “Invalid module format” 解决办法