Linux设备驱动开发中有关scull模块的编译问题

<

div id=”content” contentScore=”1609″>运行了一下《linux设备驱动程序》第三章的那个scull例子,发现出现如下错误提示:
        error: linux/config.h: No such file or directory
我的系统内核版本是2.6.35的,config.h这个头文件貌似在2.6.19的内核版本后就没有了,搜了搜网上的文章,有些人说打过patch的没问题,这是肯定的,如果不打patch,就只有改代码了,又有人说只要在access.c中添加 #include <linux/sched.h>和#include <linux/capability.h>就能通过编译,不过,出现了如下错误:
        error: ‘struct task_struct’ has no member named ‘uid’
        error: ‘struct task_struct’ has no member named ‘euid’

本文相配套的《Linux设备驱动程序》下载在http://www.linuxidc.net/thread-2029-1-1.html
       
下面是我的解决办法:

    1. 在 pipi.c 文件中添加 #include <linux/sched.h>

    2. 去掉 main.c 中的 #include <linux/config.h>

    3. 在 access.c 文件中添加 #include <linux/sched.h>

    4. struct task_struct定义在include/linux/sched.h中,原来task_struct结构体定义有所改动,将uid和euid等挪到 cred中,见            
       include/linux/sched.h和include/linux/cred.h。

    因此只需要将报error的代码所在的文件做如下修改
    current->uid 修改为 current->cred->uid
    current->euid 修改为 current->cred->euid
    5. 将Makefile中的
    CFLAGS += $(DEBFLAGS)<br