求助:驱动test编译问题,恳请高手帮忙。急,万分感谢。

simba_610 2007-02-13 02:40:36
make 后的错误信息如下:
[root@localhost test]# make
gcc -Wall -DMODULE -D__KERNEL__ -DLINUX -I/usr/src/linux-2.4.20-8/include -c test.c
test.c: In function `read_test':
test.c:14: warning: implicit declaration of function `verify_area'
test.c:14: `VERIFY_WRITE' undeclared (first use in this function)
test.c:14: (Each undeclared identifier is reported only once
test.c:14: for each function it appears in.)
test.c:19: warning: implicit declaration of function `__put_user'
test.c:20: warning: statement with no effect
test.c: In function `open_tibet':
test.c:32: `MOD_INC_USE_COUNT' undeclared (first use in this function)
test.c: In function `release_tibet':
test.c:37: `MOD_DEC_USE_COUNT' undeclared (first use in this function)
test.c: At top level:
test.c:42: warning: initialization from incompatible pointer type
test.c:43: `write_test' undeclared here (not in a function)
test.c:43: initializer element is not constant
test.c:43: (near initialization for `test_fops.write')
test.c:48: `open_test' undeclared here (not in a function)
test.c:48: initializer element is not constant
test.c:48: (near initialization for `test_fops.open')
test.c:49: `release_test' undeclared here (not in a function)
test.c:49: initializer element is not constant
test.c:49: (near initialization for `test_fops.release')
test.c:27: warning: `write_tibet' defined but not used
test.c:31: warning: `open_tibet' defined but not used
test.c:36: warning: `release_tibet' defined but not used
make: *** [test.o] Error 1

========================================================================
我的makefile文件如下:
C=gcc
MODCFLAGS:=-Wall -DMODULE -D__KERNEL__ -DLINUX -I/usr/src/linux-2.4.20-8/include
test.o:test.c
$(CC) $(MODCFLAGS) -c test.c
========================================================================
我的C源程序如下:
#include <linux/types.h>
#include <linux/fs.h>
#include <linux/mm.h>
#include <linux/errno.h>
#include <asm/segment.h>
unsigned int test_major = 0;

static int read_test(struct inode *node, struct file *file,
char *buf, int count)
{
int left;
if (verify_area(VERIFY_WRITE,buf,count) == -EFAULT )
return -EFAULT;

for(left = count ; left > 0 ; left--)
{
__put_user(1, buf, 1);
buf ;
}
return count;
}
/********************************************************************/
static int write_tibet(struct inode *inode, struct file *file,
const char *buf, int count)
{
return count;
}
static int open_tibet(struct inode *inode, struct file *file )
{
MOD_INC_USE_COUNT;
return 0;
}
static void release_tibet(struct inode *inode, struct file *file )
{
MOD_DEC_USE_COUNT;
}
/********************************************************************/
struct file_operations test_fops = {
NULL,
read:read_test,
write:write_test,
NULL, /* test_readdir */
NULL,
NULL, /* test_ioctl */
NULL, /* test_mmap */
open:open_test,
release:release_test, NULL, /* test_fsync */
NULL, /* test_fasync */
/* nothing more£¬ fill with NULLs */
};
/******************************************************************/
int init_module(void)
{
int result;
result = register_chrdev(0, "test", &test_fops);
if (result < 0) {
printk(KERN_INFO "test: can't get major number\n");
return result;
}
if (test_major == 0){
test_major = result; /* dynamic */
return 0;
}
}
========================================================================
不知是什么原因,恳请高手帮忙看看,小弟多谢了!
...全文
218 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复
提供的源码资源涵盖了安卓应用、小程序、Python应用和Java应用等多个领域,每个领域都包含了丰富的实例和项目。这些源码都是基于各自平台的最新技术和标准编写,确保了在对应环境下能够无缝运行。同时,源码中配备了详细的注释和文档,帮助用户快速理解代码结构和实现逻辑。 适用人群: 这些源码资源特别适合大学生群体。无论你是计算机相关专业的学生,还是对其他领域编程感兴趣的学生,这些资源都能为你提供宝贵的学习和实践机会。通过学习和运行这些源码,你可以掌握各平台开发的基础知识,提升编程能力和项目实战经验。 使用场景及目标: 在学习阶段,你可以利用这些源码资源进行课程实践、课外项目或毕业设计。通过分析和运行源码,你将深入了解各平台开发的技术细节和最佳实践,逐步培养起自己的项目开发和问题解决能力。此外,在求职或创业过程中,具备跨平台开发能力的大学生将更具竞争力。 其他说明: 为了确保源码资源的可运行性和易用性,特别注意了以下几点:首先,每份源码都提供了详细的运行环境和依赖说明,确保用户能够轻松搭建起开发环境;其次,源码中的注释和文档都非常完善,方便用户快速上手和理解代码;最后,我会定期更新这些源码资源,以适应各平台技术的最新发展和市场需求。

4,438

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 内核源代码研究区
社区管理员
  • 内核源代码研究区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧