• <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 墨…… 閱讀(922) 評論(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 © 墨……

            久久精品aⅴ无码中文字字幕重口 久久精品a亚洲国产v高清不卡 | 97久久超碰成人精品网站| 久久久久人妻一区二区三区| 亚洲综合伊人久久综合| 久久96国产精品久久久| 香蕉99久久国产综合精品宅男自| 99久久精品免费看国产一区二区三区 | 欧美久久综合九色综合| 久久夜色精品国产噜噜亚洲AV| 91秦先生久久久久久久| 久久久久国产精品嫩草影院| 国产精品亚洲美女久久久| 亚洲AV日韩AV天堂久久| 精品无码久久久久久久久久| 久久亚洲精品国产精品| 尹人香蕉久久99天天拍| 精品久久久久久无码中文字幕 | 2021国产精品久久精品| 久久久久久免费一区二区三区| 亚洲国产精品成人久久| 一日本道伊人久久综合影| 久久国产香蕉一区精品| 伊人丁香狠狠色综合久久| 久久久久人妻精品一区二区三区 | 亚洲国产精品无码久久久不卡| 精品久久久久久久久久久久久久久 | 久久亚洲2019中文字幕| 色成年激情久久综合| 国产成人久久精品区一区二区| 久久天天躁狠狠躁夜夜avapp| 三级三级久久三级久久| 97香蕉久久夜色精品国产| 精品久久久久久无码不卡| 久久精品桃花综合| 国产激情久久久久久熟女老人| 狠狠色丁香婷婷久久综合| 日本五月天婷久久网站| 人妻久久久一区二区三区| 国产亚洲婷婷香蕉久久精品| 久久夜色精品国产亚洲| 久久精品中文字幕第23页|