I noticed that I never figured this out completely. Linux maps SATA and USB (and many more kind of) storage devices to
/dev/sd[a-z] device files in the order in which they were "found". Now given that you know that for example a CF flash card is connected to a machine via SATA how do you determine which device file it got? Of course you could just look at
dmesg, but what if you want to do this programmatically? Parsing it? That's not a good solution. The kernel must provide an API to figure this out and I guess it should be simple. But so far I just haven't found it.
Linux nowadays has a lot of system information written into the filesystem (
etc) where you might get the information required to figure out the device file. This however depends on weather the features were enabled at compile time. I am looking for a solution which also works on a minimal kernel, without all the fancy fs things.