0

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.

ArjunShankar
  • 23,020
  • 5
  • 61
  • 83
user1395806
  • 145
  • 1
  • 4
  • 15

2 Answers2

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