How to create a device file when I do not know the minor and major number (i.e. by using dynamic registration) without using mknod
or MAKEDEV
.
Asked
Active
Viewed 2,690 times
0

ArjunShankar
- 23,020
- 5
- 61
- 83

user1395806
- 145
- 1
- 4
- 15
-
2You should learn a lot more about `udev` – Basile Starynkevitch May 18 '12 at 12:48
-
2See also this question: http://stackoverflow.com/questions/5970595/ – Eugene May 19 '12 at 05:53
2 Answers
2
Say you want to dynamically assign a major number to a char device on insertion, use:
int alloc_chrdev_region(dev_t *dev, unsigned int firstminor, unsigned int count, char *name);
From Linux Device Drivers 3rd Edition. Google it you can get the entire book for free along with tons of great source code for messing with drivers.

NKamrath
- 536
- 3
- 9
0
Also, the codes provided in the LDD3 are obsolete now. So, use this github repo to download example codes of LDD3: https://github.com/martinezjavier/ldd3

vishwakarma09
- 254
- 3
- 17