We have an embedded Linux build that starts with a HDD in sleep mode (hardware). The software then starts and enables power to the drive. Linux detects the drive fine:
ata1: exception Emask 0x10 SAct 0x0 SErr 0x4050000 action 0x42 frozen
ata1: soft resetting port
ata1: SATA link up 1.5 Gbps (SStatus 113 SControl F0000)
ata1.00: ATA-8, max UDMA/133, 976773168 sectors: LBA48 NCQ (depth 0/32)
ata1.00: ata1: dev 0 multi count 0
ata1.00: configured for UDMA/133
ata1: EH complete
Vendor: ATA Model: Hitachi HCS5C105 Rev: JC2O
Type: Direct-Access ANSI SCSI revision: 05
SCSI device sda: 976773168 512-byte hdwr sectors (500108 MB)
sda: Write Protect is off
SCSI device sda: drive cache: write back
SCSI device sda: 976773168 512-byte hdwr sectors (500108 MB)
sda: Write Protect is off
SCSI device sda: drive cache: write back
sda: sda1 sda2
sd 0:0:0:0: Attached scsi disk sda
sd 0:0:0:0: Attached scsi generic sg0 type 0
Unfortunately the software attempts to access the drive before the above SCSI detect happens. We could add a sleep but this is not a reliable mechanism as we have noticed that the time taken to detect is non-deterministic.
Is there any way to get the kernel/hotplug/etc. system to report when the HDD is detected?
Thanks.
I think the answer is somewhere in the udev device manager (wikipedia page). It is fully usable in an embedded environement.
It allows you to write rules that are able to launch scripts/programs when some devices are detected.
Something like this could do the stuff :
KERNEL=="sda", RUN+="/usr/bin/my_program"
If you have an old kernel, you may have the hotplug system activated.
The last chance wouls be the inotify tool that let you monitor anything in your file system (even /dev directory :)).