Solved

creating device nodes.

Posted on 2003-11-07
5
180 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Debian 3.16.7 3 123
what does getent do 3 42
linux / python expert needed 3 79
Linux : how to point the OS to use the new DNS server 11 99
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

758 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