In linux, I am using the blkid apis to get most information about disk partitions. I am unable to find an API that would let me find out the mapping between a partition name and its drive.
For example, the disk /dev/sda is partitioned into /dev/sda1 and /dev/sda2. Given two partition names, how do I know whether it comes from the same drive ? By looking for a common prefix (sda), one could see if they belong to the same drive or not. But is this fool proof ? Will this work in all cases ? What if this is part of a volume ? Also, can the drive name/volume name ("sda") contain numbers ?
I am assuming that there should be an easy way to determine this mapping.