Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2549694
  • 博文数量: 351
  • 博客积分: 76
  • 博客等级: 上将
  • 技术积分: 3555
  • 用 户 组: 普通用户
  • 注册时间: 2004-11-13 21:27
文章分类

全部博文(351)

文章存档

2013年(1)

2012年(4)

2011年(7)

2010年(16)

2009年(34)

2008年(34)

2007年(34)

2006年(68)

2005年(82)

2004年(71)

分类:

2005-10-13 12:59:53

《The Linux Kernel Module Programming Guide》一书中第七章Talking to Device Files
(book and source can be downloaded form http://blog.chinaunix.net/article.php?articleId=51744&blogId=2108)

insmod 的时候出错:
[root@localhost 07-TalkingToDeviceFiles]# insmod chardev.o
chardev.o: unresolved symbol module_unregister_chrdev
chardev.o: unresolved symbol module_register_chrdev
chardev.o:
Hint: You are trying to load a module without a GPL compatible license
and it has unresolved symbols. The module may be trying to access
GPLONLY symbols but the problem is more likely to be a coding or
user error. Contact the module supplier for assistance, only they
can help you.

google了一下,发现没有module_register_chrdev()和module_unregister_chrdev()。
于是修改代码:
module_register_chrdev()为register_chrdev()
module_unregister_chrdev()为unregister_chrdev()


然后insmod的时候又出错
[root@localhost 07-TalkingToDeviceFiles]# insmod chardev.o
Warning: loading chardev.o will taint the kernel: no license
See for information about tainted modules
chardev.o: init_module: Device or resource busy
Hint: insmod errors can be caused by incorrect module parameters, including invalid IO or IRQ parameters.
You may find more information in syslog or the output from dmesg

dmsg内容如下:
Sorry, registering the character device failed with -16

然后 cat /proc/devices
发现major num 100已经使用,
于是修改 chardev.h
#define MAJOR_NUM 200

then ok

阅读(3234) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~