Possible Duplicate:
How to get drive label in Linux using C from userspace
How can I obtain label of a disk by its file name (/dev/sda1, e.g.) in a program written in C/C++?
Possible Duplicate:
How to get drive label in Linux using C from userspace
How can I obtain label of a disk by its file name (/dev/sda1, e.g.) in a program written in C/C++?
You can code the C or C++ equivalent of this command:
That is,
stat()
the device file you care about and remember its inode number. Iterate over all of the files in /dev/disk/by-label, andstat()
each of them. When the inode number matches, then the name of the matched file is the label of that disk.If it were me, I'd code the above algorithm in C++, using Boost.Filesystem.