Link to home
Start Free TrialLog in
Avatar of jinumjoy
jinumjoy

asked on

creating device nodes.

Hi,

I have a simple device driver which registers a dynamic major number. I would like my install rule in the Makefile to create the device nodes automatically by looking into /proc/devices.

I had referred some text on the net and came up with the below commands for my "install" rule in Makefile.

Makefile
=====

TARGET=abc.o
MODULE="abc-char"
.
.


install:
  @insmod $(TARGET)
  @major=`cat /proc/devices | grep $(MODULE) | awk '{print $$1}'`
  @echo $$major

at this point (echo) i dont get the major number of the device, i get a blank. But if I execute the "cat /proc/devices..." as a command i do get the correct major number of the device.

creating device nodes is easy if i can get the major number from /proc/devices.

Can anyone please help me figure out the mistake i am doing or give some other way of doing the same.

cheers!
-Jinu

 



Avatar of sunnycoder
sunnycoder
Flag of India image

>@major=`cat /proc/devices | grep $(MODULE) | awk '{print $$1}'`
should perhaps be
@major=`cat /proc/devices | grep $(MODULE) | awk '{print $1}'`
Avatar of jinumjoy
jinumjoy

ASKER

no sunnycoder $1 will not work.

$$1 is correct, but @major is not getting updated. I dont know what the problem is.

-Jinu
ASKER CERTIFIED SOLUTION
Avatar of sunnycoder
sunnycoder
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial