Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

creating device nodes.

Posted on 2003-11-07
5
Medium Priority
?
198 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 400 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

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 fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

885 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