linux 核心模組調試錯誤

來源:互聯網
上載者:User

 各位,我在編譯核心模組時有一個錯誤調了很久也沒解決,請那位仁兄幫忙看看,
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/ 有搜尋欄
請朋友幫忙消除第二行報錯。謝了!

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.