Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


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

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

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,

Old 11-13-2007, 08:42 AM   #2
Senior Member
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

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:
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


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 08:59 AM
special device node minor and major numbers crash88 Linux - General 1 06-22-2006 01:17 PM
how to create device node for dynamically allocated major number appas Programming 5 11-01-2004 10:37 AM
what is a major number and a minor number ? Menestrel Linux - Newbie 2 10-11-2004 08: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 10:36 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:49 PM.

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