LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Traversing /dev (https://www.linuxquestions.org/questions/linux-newbie-8/traversing-dev-765488/)

whatis 10-30-2009 12:50 AM

Traversing /dev
 
Hi

I am new to the Linux platform.

How can I write a program that traverses /dev and prints the major and minor numbers for the devices

neonsignal 10-30-2009 07:22 AM

In C, you would use opendir and readdir to traverse the directories, and stat to examine the file details. The stat call will give (amongst other things) the device id st_rdev, and you can extract the device numbers from this using the major and minor macros which are found in 'sys/sysmacros.h' (which is included by 'sys/types.h').

malekmustaq 10-30-2009 10:09 AM

A respectable reply. Thanks neonsignal.

pixellany 10-30-2009 10:13 AM

Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place.

Because there are posts in both threads, I'll get this one merged into the other

whatis 10-31-2009 09:02 AM

Thanks Alot!!

That was great help!

Tinkster 11-01-2009 06:45 PM

Closed in favour of the more sensibly placed dupe.

http://www.linuxquestions.org/questi...ng-dev-765489/


All times are GMT -5. The time now is 02:43 PM.