Linux Device Driver study: scull TIPS

來源:互聯網
上載者:User

用到的例子為Linux裝置驅動程式中的源碼。

 

存在的問題和解決方案:

1、關於CFLAG的錯誤。將Makefile中的CFLAG項全部屏蔽即可;

2、提示linux/config.h no such file or directory。在/usr/src/linux-source..../include/linux中建立config.h即可(例:touch /usr/src/linux-source-2.6.35/include/linux/config.h   實際路徑中沒有config.h)

3、提示TASK_INTERRUPTIBLE undeclared,增加標頭檔#include <linux/sched.h>即可;

4、struct task_struct has no member name uid,增加標頭檔 #include <linux/cred.h>,同時將current->uid改成current->cred->uid,將current->euid改為current->cred->euid即可;(原因在於新核心資料結構發生了變化,將uid和euid放入cred結構中,參考:http://hi.baidu.com/swinggucas/blog/item/32e1d3c3d4eacf3ee4dd3b22.html)

 

小結:核心升級後,對相應資料結構或標頭檔的引用進行了修改,因此會存在上述的2、3、4等問題。

 

編譯成功後,insmod scull.ko   用vim開啟/proc/devices會看到scull作為字元模組存在

 

參考資料:

1、關於問題2:http://ubuntuforums.org/showthread.php?t=417072

2、關於問題3:http://www.gossamer-threads.com/lists/linux/kernel/1140561

3、關於問題4:http://hi.baidu.com/swinggucas/blog/item/32e1d3c3d4eacf3ee4dd3b22.html

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.