LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-13-2007, 05:53 AM   #1
guptarai
LQ Newbie
 
Registered: Oct 2007
Posts: 2

Rep: Reputation: 0
How to get a node from major number


Hi,
There can be multiple devices attached to a system for one type of work(say printer). Every object type has a unique major number as defined in major.h. For every printer there will be a minor number.

Can some body tell me the mechanism how to retrieve the minor numbers for a particular major number and then from that combination(major + minor number) how I can get the device node(We need to pass device node to open a device e.g. dev/node).

I want to know how to use a device for my application.

Thanks in Advance,

Regards,
Ravi
 
Old 11-13-2007, 07:42 AM   #2
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,991

Rep: Reputation: 76
Are you working in kernel space (i.e. writing a kernel module) or user space (a regular program)?

You can get a list of device nodes with major and minor versions easily enough:
Code:
find /dev -type b -exec ls -l {} \; ; find /dev -type c -exec ls -l {} \;
. You should be able to parse that to find both the minor numbers and the corresponding device nodes.

If you know that your device is a block device, you can ignore everything from the second semicolon afterwards, and if it's a character device then you can ignore from the start to the second semicolon.

Hope that helps,

—Robert J Lee
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
changing Major Number binumohanr AIX 1 07-28-2006 07:59 AM
special device node minor and major numbers crash88 Linux - General 1 06-22-2006 12:17 PM
how to create device node for dynamically allocated major number appas Programming 5 11-01-2004 09:37 AM
what is a major number and a minor number ? Menestrel Linux - Newbie 2 10-11-2004 07:53 AM
why there is a need for minor number and major number for monitor/keyboard in pc? tripathi Solaris / OpenSolaris 1 11-07-2003 09:36 AM


All times are GMT -5. The time now is 03:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration