1、问题
前面有说过如何创建字符设备的文章,今天移植过来发现模块加载不上去的问题。具体如下:
[root@LIN helloDev]$ insmod helloworld.ko
insmod: ERROR: could not insert module helloworld.ko: Operation not permitted
不少文章说是root权限问题,但这里可以看到我这里已经是root账户了。但为什么还是不行呢?
问题到底在哪?
2、解决办法
打印系统加载打印:
[root@LIN-F2290930E53 helloDev]# dmesg
[65920.550333] hello driver exit
[65923.049043] CHRDEV "helloworld" major requested (813) is greater than the maximum (511)
可以看到这里说字符设备主设备号请求大于最大值511;所以将主设备号修改下,小于511(别和已有冲突)就OK了。
unsigned int subDevNum = 1;//请求的连续设备个数
int reg_major = 813;//主设备号
int reg_minor = 0; //次设备号
我生日813所以设置了个813,家里Linux是在centos的版本,公司是Red Hat的版本,哈哈哈哈!!!
另外关于,权限问题可参看:https://blog.csdn.net/sweeneil/article/details/88253973