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').