I puzzled a bit around what would be the enumeration scheme on my systems and I've came up with following algorithm:
The /dev/sdY devices are created in the same order as the ataX identifiers are enumerated in the kern.log while ignoring non-disk devices (ATAPI) and not-connected links.
Thus, following command displays the mapping:
$ grep '^May 28 2' /var/log/kern.log.0 | \
grep 'ata[0-9]\+.[0-9][0-9]: ATA-' | \
sed 's/^.*\] ata//' | \
sort -n | sed 's/:.*//' | \
awk ' { a="ata" $1; printf("%10s is /dev/sd%c\n", a, 96+NR); }'
ata1.00 is /dev/sda
ata3.00 is /dev/sdb
ata5.00 is /dev/sdc
ata7.00 is /dev/sdd
ata8.00 is /dev/sde
ata10.00 is /dev/sdf
(Note that ata4 is not displayed because the above log messages are from another system.)
I am using /var/log/kern.log.0 and not /var/log/kern.log because the boot messages are already rotated. I grep for May 28 2 because this was the last boot time and I want to ignore previous messages.
To verify the mapping you can do some checks via looking at the output of:
$ grep '^May 28 2' /var/log/kern.log.0 | \
grep 'ata[0-9]\+.[0-9][0-9]: ATA-'
May 28 20:43:26 hn kernel: [ 1.260488] ata1.00: ATA-7: SAMSUNG SV0802N, max UDMA/100
May 28 20:43:26 hn kernel: [ 1.676400] ata5.00: ATA-5: ST380021A, 3.19, max UDMA/10
[..]
And you can compare this output with hdparm output, e.g.:
$ hdparm -i /dev/sda
/dev/sda:
Model=SAMSUNG SV0802N [..]
(using Kernel 2.6.32-31)
I am still interested in alternative solutions, e.g. in a solution which does not need to access the kernel log (perhaps using some information from the /sys tree or something like that).