Error caused by statically allocating device number and system device number conflict
Source: Internet
Author: User
Error 1:# insmod Memdev.ko insmod:cannot insert ' Memdev.ko ': Device or resource busy cause analysis: Due to the application of a static application of the device number of the character device driver, the main device number is 254, and the department The equipment number of the system has clashed, so we have to change the equipment number. This is the disadvantage of static distribution device number ...
Error 2:When writing a driver, that is, the file operation structure body pointer definition placed in open, read, write, Llseek, and other functions, if placed at the beginning of the definition, then compile error * * File operation structure/static const struct File_operations mem_ FoPs = {. Owner = This_module,. Llseek = Mem_llseek,. Read = Mem_read,. Write = Mem_write,. Open = Mem_open,. Release = Mem_release,}; 1, when loading prompt: Insmod:cannot insert ' Memdev.ko ':D evice or Resource busy. This occurs because the statically assigned main device number is already in use by another device. Here you can modify the macro definition of the memdev_major in Memdev.h, I change to 203, then reload on OK.
2,cat/proc/devices view device name, device number. The equipment number of this experiment is 203, the device name is Memdev.
[root@hfrk24x0/tmp]# cat/proc/devices Character devices:1 Mem 2 Pty 3 Ttyp 4/dev/vc/0 4 TTY 5/dev/tty 5/dev/console 5/DEV/PTMX 7 Misc Input Sound SG fb Bayi video4linux-I2C-MTD 116 alsa 128 PTM pts 136 SPI 180 usb 188 ttyUSB 189 usb_device 203 memdev 204 s3c2410_serial 251 hidraw 252 ttySDIO 253 usb_endpoint 254 rtc
Block Devices:1 RAMDisk 259 Blkext 7 Loop 8 SD-mtdblock-SD 68 SD-SD. ........
3, create the device node manually:
[root@hfrk24x0/tmp]# mknod/dev/memdev0 C 203 0 [root@hfrk24x0/tmp]# ls-l/dev/memdev0 crw-r--r--1 root root 203, 0 Ja N 1 08:45/dev/memdev0 4, test
[root@hfrk24x0/tmp]#.//app-mem./memdev.ko [root@hfrk24x0/tmp]#./app-mem Buf:mem is char dev! Written 4096 bytes (s) from 0 Buf:buf are null!read 4096 (s) from 0 bytes is char buf:mem 5, uninstall the kernel module
[root@hfrk24x0/tmp]# rmmod memdev rmmod:module ' memdev ' not found [root@hfrk24x0/tmp]# lsmod
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.