2

I have been provided a Linux kernel module with these instructions: insmod . Then determine the major number and create a /dev entry. I was able to successfully install as is evident from the dmesg file. However, I do not know how to determine the device number. Any help appreciated

doon
  • 2,311
  • 7
  • 31
  • 52
  • Possible duplicate of [How to create a device in /dev automatically upon loading of the kernel module for a device driver?](https://stackoverflow.com/questions/8697300/how-to-create-a-device-in-dev-automatically-upon-loading-of-the-kernel-module-f) – Ciro Santilli OurBigBook.com Aug 06 '17 at 09:01

1 Answers1

2

I assume you know the name of a device you are talking about. You can retrieve the major number from /proc/devices. Here is an extract from this file:

Character devices:
1 mem
<...>
216 rfcomm
226 drm
252 hidraw
253 bsg
254 rtc

Block devices:
259 blkext
8 sd
9 md
<...>

Look for the name of your device there. The major number is on the same line, just before the name.

A sidenote. I would also recommend looking at "Linux Driver Development" book (http://lwn.net/Kernel/LDD3/), esp. chapters 1-3. The device numbers and many other useful things are explained there. Although some parts of the book are a bit out-of-date now, it is still very useful. End of a sidenote.

Eugene
  • 5,977
  • 2
  • 29
  • 46