How do I probe for block devices?

Submitted by TragicWarrior
on May 30, 2006 - 9:47am

Can anyone tell me what is the the most reliable way of discovering all block devices attached to the system from user space? I have been using libblkid with the iterate functions, but they do not pick up optical devices (like cdroms, dvd writers, etc...)

Thanks in advance.

/dev

xiox (not verified)
on
May 30, 2006 - 10:24am

If udevd is running, couldn't you just use all the block devices in /dev?

Well, I had thought of that,

TragicWarrior
on
May 30, 2006 - 12:03pm

Well, I had thought of that, but it didn't seem very elegant.

I'm not sure whether this wou

Anonymous (not verified)
on
May 30, 2006 - 12:57pm

I'm not sure whether this would be elegant, but you can elegantly traverse /sys/block/ to get that information.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.