• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            linux 驅動初接觸

            Posted on 2013-04-02 15:36 墨…… 閱讀(919) 評論(0)  編輯 收藏 引用
            編譯 scull

               出現以下錯誤
             Fix it to use ccflags-y.  Stop.
               將 Makefile 中的 CFLAGS 改為 ccflags-y, 重新 make,又出現錯誤
            main.c:15:26: fatal error: linux/config.h: No such file or directory
               將 main.c 中的 #include <linux/config.h> 刪除或注釋掉,重新 make,繼續編譯會遇到如下問題
            main.c:634:2: error: unknown field 'ioctl' specified in initializer
               是因為內核中的 file_operations 結構發生了改變,將 main.c 中 scull_fops 聲明處的 .ioctl 改為 .unlocked_ioctl  即可,繼續編譯還會遇到如下問題
            main.c:652:3: error: implicit declaration of function ‘init_MUTEX’ [-Werror=implicit-function-declaration]
               可在 main.c 的開始處添加以下代碼解決問題
            #include <linux/semaphore.h>
            #define init_MUTEX(a) sema_init(a,1)
            #define init_MUTEX_LOCKED(a) sema_init(a,0)
               到這時還沒完,我開始有點煩燥了...繼續前進時還出現以下錯誤
            pipe.c: In function ‘scull_p_read’:
            pipe.c:131:7: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
            pipe.c:131:7: note: each undeclared identifier is reported only once for each function it appears in
            pipe.c:131:3: error: implicit declaration of function ‘signal_pending’ [-Werror=implicit-function-declaration]
            pipe.c:131:3: error: implicit declaration of function ‘schedule’ [-Werror=implicit-function-declaration]
               該問題可向 pipe.c 和 access.c 中添加 #include <linux/sched.h> 來解決,但后面還會遇到這樣的問題
            access.c:101:34: error: ‘SPIN_LOCK_UNLOCKED’ undeclared here (not in a function)
               在access.c文件中用 static DEFINE_SPINLOCK(scull_w_lock);  來代替 static spinlock_t scull_w_lock = SPIN_LOCK_UNLOCKED;
               繼續進行,遭遇下面問題
            access.c:111:29: error: ‘struct task_struct’ has no member named ‘uid’
            access.c:112:29: error: ‘struct task_struct’ has no member named ‘euid’
            access.c:119:26: error: ‘struct task_struct’ has no member named ‘uid’
               把 access.c 文件中的 
            current->uid 
            current->euid
               全部修對應地改為
            current->cred->uid
            current->cred->euid
               繼續重新 make,終于可以生成 scull.ko 了,OMG......

               還要注意的是,上面的錯誤可能不止發生在一個地方,編譯時需要注意看清錯誤提示,如果有跟上面一樣的錯誤發生,只需參照上面的方法來修改即可。
               驅動不會在虛擬終端上輸出,所以如果在終端上沒看到驅動的輸出,可以看看是不是輸出到日志中了:
            /var/log/syslog


            Contact us

            posts - 8, comments - 0, trackbacks - 0, articles - 0

            Copyright © 墨……

            婷婷久久综合九色综合九七| 久久99热这里只有精品国产| 国产亚洲精久久久久久无码77777| 少妇熟女久久综合网色欲| 99久久免费国产精品特黄| 久久精品国产亚洲av麻豆色欲 | 漂亮人妻被黑人久久精品| 九九久久99综合一区二区| 久久夜色撩人精品国产| 亚洲精品无码久久久久| 久久精品国产清高在天天线| 久久AV高清无码| 免费观看久久精彩视频| 四虎国产精品免费久久| jizzjizz国产精品久久| 欧美亚洲国产精品久久| 久久久九九有精品国产| 午夜欧美精品久久久久久久| 美女久久久久久| 久久99中文字幕久久| 狠狠色婷婷久久一区二区| 久久久久这里只有精品| 999久久久国产精品| 91精品国产综合久久精品| 久久亚洲国产精品成人AV秋霞| 精品午夜久久福利大片| 成人国内精品久久久久影院| 欧洲成人午夜精品无码区久久 | 午夜精品久久久内射近拍高清| AV无码久久久久不卡蜜桃 | 久久午夜福利无码1000合集| 久久久久亚洲爆乳少妇无| 久久九九青青国产精品| 91久久精品91久久性色| 91久久婷婷国产综合精品青草| 一本久道久久综合狠狠爱| 久久久亚洲精品蜜桃臀| 久久久久亚洲AV成人网人人网站| 国产日韩久久免费影院| 国产亚洲精久久久久久无码AV| 国产精品成人99久久久久91gav|