Solved

creating device nodes.

Posted on 2003-11-07
5
183 Views
Last Modified: 2012-05-04
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

 



0
Comment
Question by:jinumjoy
  • 2
5 Comments
 
LVL 45

Expert Comment

by:sunnycoder
ID: 9700844
>@major=`cat /proc/devices | grep $(MODULE) | awk '{print $$1}'`
should perhaps be
@major=`cat /proc/devices | grep $(MODULE) | awk '{print $1}'`
0
 

Author Comment

by:jinumjoy
ID: 9709225
no sunnycoder $1 will not work.

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

-Jinu
0
 
LVL 45

Accepted Solution

by:
sunnycoder earned 100 total points
ID: 9722171
cat /proc/devices | grep $(MODULE) | awk '{print $$1}'
run this with some dummy values and check the ouput ... if the output is what you desire, then check for spaces on either side of =
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now