Title: RE: Need to identify a physical USB hub
port
A while back Chris Reed and Rich Kubota answered my question
about obtaining the locationID of a USB device(reader) into which a
flash media is plugged. I just tried their suggestions with the
following code. This code gets called when my app responds to the
mount event that generates from the flash media being plugged into the
reader.
The BSDNodeName is properly returned.
getWholeMedia(...) is derived from the sample code at:
<http://developer.apple.com/samplecode/VolumeToBSDNode/VolumeToBSDNode.html>. After I iterate up to theWholeMedia and use
that value in IORegistryEntrySearchCFProperty, that function
returns 0 for assignment into locationIDCFString. I believe
that that's wrong because the following function crashes the app as
expected. Does anyone see anything wrong with my code? If not, I'll
detail the function
getWholeMedia.
Thank you.
At 9:25 AM -0500 5/26/05, Chris Reed wrote:
It's pretty easy,
actually. Find the IOMedia object for the mounted volume, then
walk up that object's parents until you hit an IOUSBDevice, which will
have the locationID property. Or you can use
IORegistryEntrySearchCFProperty() to do it in one call.
There are several
ways to find the IOMedia object for the volume. Perhaps the easiest is
to install a notification handler to watch for new IOMedia
objects.
Another way would be
to use the statfs() call to get the device path. It will be something
like "/dev/disk0s4". Strip the "/dev/", and
search for an IOMedia with a "BSD Name" property with that
value.
There's other ways
as well, but that should give you the basic idea.
Cheers
-chris
--
-----
B. Mitchell
Loebel 408 425-9920 cell
Executive
Director
The Tech Startup
Connection
(formerly The PARALLEL Processing
Connection)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Usb mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/usb/email@hidden
This email sent to email@hidden