I know that there is /dev/disk/by-id/
folder which contains links to /dev/sd*
elements. I'd like to know, is there any way to get by-id
element pointing to, for example, /dev/sda
.
P.S.: yeah, I know that I can loop through elements in by-id
folder and /dev/sd*
, so that I can compare serial numbers and match them. But is there any better way?
EDIT: sorry for my mistake. It should be done in C/C++. UUID's were mentioned. That would be great, they are unique and so on, but how can I collect all the UUID's of one hdd? I mean the main, pointing to sda, for example, and partition UUID's, pointing to sda1, sda2 and so on.
I'm sorry for late answer.
My question was wrong, I did not need
/dev/sd*
element to get/dev/disk/by-id/
elements.I've used libudev and got these elements:
P.S.: I've used that in special LFS-based distribution, that does have serial numbers in
/dev/disk/by-id/
name.