Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3470965
  • 博文数量: 1450
  • 博客积分: 11163
  • 博客等级: 上将
  • 技术积分: 11101
  • 用 户 组: 普通用户
  • 注册时间: 2005-07-25 14:40
文章分类

全部博文(1450)

文章存档

2017年(5)

2014年(2)

2013年(3)

2012年(35)

2011年(39)

2010年(88)

2009年(395)

2008年(382)

2007年(241)

2006年(246)

2005年(14)

分类: LINUX

2012-06-05 10:47:50

我的linux系统是 Ubuntu 10.04,内核版本是 


root@libin:~# uname -ar
Linux libin 2.6.32-26-generic #47-Ubuntu SMP Wed Nov 17 15:59:05 UTC 2010 i686 GNU/Linux


LDD3中,内核代码2.6.10所以从下载下来的代码不能够直接编译。今天我在家养病,揉腿烤腿之余,把这个问题解决了。
首先是 Makefile我在网上查,发现 CFLAG不能修改,所以把Makefile中的
CFLAGS用EXTRAFLAGS取代


然后报错的是main.c   /linux/config.h不存在。我查看后,发现的确不存在。



root@libin:/usr/src/linux-headers-2.6.32-26-generic/include/linux# ll config.h
ls: 无法访问config.h: 没有那个文件或目录


1 将main.c中#include 改为 #include


发现出现如下打印信息
/home/libin/project/ldd3/examples/scull/pipe.c: In function ‘scull_p_read’:
/home/libin/project/ldd3/examples/scull/pipe.c:132: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
/home/libin/project/ldd3/examples/scull/pipe.c:132: error: (Each undeclared identifier is reported only once
/home/libin/project/ldd3/examples/scull/pipe.c:132: error: for each function it appears in.)
/home/libin/project/ldd3/examples/scull/pipe.c:132: error: implicit declaration of function ‘signal_pending’
/home/libin/project/ldd3/examples/scull/pipe.c:132: error: implicit declaration of function ‘schedule’
/home/libin/project/ldd3/examples/scull/pipe.c: In function ‘scull_getwritespace’:
/home/libin/project/ldd3/examples/scull/pipe.c:169: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
/home/libin/project/ldd3/examples/scull/pipe.c: In function ‘scull_p_write’:
/home/libin/project/ldd3/examples/scull/pipe.c:220: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
/home/libin/project/ldd3/examples/scull/pipe.c:224: error: ‘SIGIO’ undeclared (first use in this function)
/home/libin/project/ldd3/examples/scull/pipe.c:224: error: ‘POLL_IN’ undeclared (first use in this function)
make[2]: *** [/home/libin/project/ldd3/examples/scull/pipe.o] 错误 1
make[1]: *** [_module_/home/libin/project/ldd3/examples/scull] 错误 2
make[1]:正在离开目录 `/usr/src/linux-headers-2.6.32-26-generic'
 
2 将pipe.c 中添加头文件  linux/sched.h。 即添加 #include


重新make 发现如下打印

/home/libin/project/ldd3/examples/scull/access.c: In function ‘scull_u_open’:
/home/libin/project/ldd3/examples/scull/access.c:107: error: dereferencing pointer to incomplete type
/home/libin/project/ldd3/examples/scull/access.c:108: error: dereferencing pointer to incomplete type
/home/libin/project/ldd3/examples/scull/access.c:115: error: dereferencing pointer to incomplete type
/home/libin/project/ldd3/examples/scull/access.c: In function ‘scull_w_available’:
/home/libin/project/ldd3/examples/scull/access.c:166: error: dereferencing pointer to incomplete type
/home/libin/project/ldd3/examples/scull/access.c:167: error: dereferencing pointer to incomplete type
/home/libin/project/ldd3/examples/scull/access.c: In function ‘scull_w_open’:
/home/libin/project/ldd3/examples/scull/access.c:180: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
/home/libin/project/ldd3/examples/scull/access.c:180: error: (Each undeclared identifier is reported only once
/home/libin/project/ldd3/examples/scull/access.c:180: error: for each function it appears in.)
/home/libin/project/ldd3/examples/scull/access.c:180: error: implicit declaration of function ‘signal_pending’
/home/libin/project/ldd3/examples/scull/access.c:180: error: implicit declaration of function ‘schedule’
/home/libin/project/ldd3/examples/scull/access.c:185: error: dereferencing pointer to incomplete type
/home/libin/project/ldd3/examples/scull/access.c: In function ‘scull_w_release’:
/home/libin/project/ldd3/examples/scull/access.c:206: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
/home/libin/project/ldd3/examples/scull/access.c: In function ‘scull_c_open’:
/home/libin/project/ldd3/examples/scull/access.c:278: error: dereferencing pointer to incomplete type
/home/libin/project/ldd3/examples/scull/access.c:282: error: dereferencing pointer to incomplete type
make[2]: *** [/home/libin/project/ldd3/examples/scull/access.o] 错误 1
make[1]: *** [_module_/home/libin/project/ldd3/examples/scull] 错误 2
make[1]:正在离开目录 `/usr/src/linux-headers-2.6.32-26-generic'
make: *** [modules] 错误 2


3 在access.c添加


make 会出现
error: 'struct task_struct' has no member named 'uid'error: 'struct task_struct' has no member named 'euid'
4struct 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



然后make,就可以大功告成了

root@libin:~/project/ldd3/examples/scull# ll
总用量 280
drwxr-xr-x  3  502 staff  4096 2010-11-20 15:27 ./
drwxr-xr-x 20  502 staff  4096 2005-05-13 06:40 ../
-rw-r--r--  1  502 staff 10905 2010-11-20 15:27 access.c
-rw-r--r--  1 root root   7568 2010-11-20 15:27 access.o
-rw-r--r--  1 root root  28243 2010-11-20 15:27 .access.o.cmd
-rw-r--r--  1  502 staff 16426 2010-11-20 15:02 main.c
-rw-r--r--  1 root root   8602 2010-11-20 15:02 main.o
-rw-r--r--  1 root root  24507 2010-11-20 15:02 .main.o.cmd
-rw-r--r--  1  502 staff   775 2010-11-20 14:56 Makefile
-rw-r--r--  1 root root     56 2010-11-20 15:27 modules.order
-rw-r--r--  1 root root      0 2010-11-20 15:13 Module.symvers
-rw-r--r--  1  502 staff 11162 2010-11-20 15:24 pipe.c
-rw-r--r--  1 root root   6079 2010-11-20 15:25 pipe.o
-rw-r--r--  1 root root  27986 2010-11-20 15:25 .pipe.o.cmd
-rw-r--r--  1  502 staff  5153 2005-02-01 04:31 scull.h
-rw-r--r--  1  502 staff  3309 2005-02-01 04:31 scull.init
-rw-r--r--  1 root root  22520 2010-11-20 15:27 scull.ko
-rw-r--r--  1 root root    307 2010-11-20 15:27 .scull.ko.cmd
-rw-r--r--  1  502 staff  1708 2005-05-13 06:39 scull_load
-rw-r--r--  1 root root   1977 2010-11-20 15:13 scull.mod.c
-rw-r--r--  1 root root   4284 2010-11-20 15:13 scull.mod.o
-rw-r--r--  1 root root  22761 2010-11-20 15:13 .scull.mod.o.cmd
-rw-r--r--  1 root root  18843 2010-11-20 15:27 scull.o
-rw-r--r--  1 root root    270 2010-11-20 15:27 .scull.o.cmd
-rw-r--r--  1  502 staff   335 2005-02-01 04:31 scull_unload
drwxr-xr-x  2 root root   4096 2010-11-20 15:27 .tmp_versions/
阅读(1549) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~