News

I've had feedback from John Rehwinkel saying that the headers have changed in 10.3. Also made modifications to the code to default to IOSCSIParallelController if none are specified on the command line.

You should see output looking something like this: IO service Name Matching: "IOSCSIParallelController"
Found: ADPT7892SCSIController...Scan success

Background

I've got a powerboard problem, I have to share about 15 plugs with only 10 outlets. So occasionally My machine will be booted without my scanner being powered. This is a pain to reboot to detect the scanner, especially when I'm compressing an mpeg file in the background.

Searching the web only tends to find the BSD scsi control subsystem "cam" or other people like myself looking for how to do this.

One page however pointed me in the right direction. Saying he had found a function in the IOKit that would send a rescan request to an IOservice. (IOServiceRequestProbe) I just had to find out which service... So I have code which sends the Probe request to a SCSI controller and does not return a kernel error. But I haven't tested if any new devices appeared. My scanner cable went missing in the move. The one I borrowed was a 2 meter HSSI cable, probably not good as a SCSI cable.

How to use

the program is called rescan_scsi.
It accepts 1 argument (or else it crashes) which is the Service name to match. Normally this is IOSCSIParallelController. But I've found a couple of older beige machines that this doesn't work with, so I decided not to hardcode it. You could also use higher level objects such as IOService or OSObject. I suspect that this code needs to be run as root, I haven't tested that.
Run like: ./rescan_scsi IOSCSIParallelController

Download

How to compile

Throwing gcc at the C source by itself wont do any good. You have to tell the compiler which Libraries to use or in OSX's case which Frameworks: gcc rescan.c -framework IOKit -framework CoreFoundation If I remember correctly should compile it.

Todo

Print a list of SCSI devices found before and after the scan.
Scan the IOServices for potential scan requests.

Email

I've noticed quite a lot of people have downloaded this program however I have received no feedback. I thought that you may've been able to work it out. So here; scsi at silicontrip dot net If I get spammed, that address will change.