views:

1186

answers:

2

Hi All,

I am trying to develop a program in Mac OS and Linux which lists the files and folders in USB drive. I need to get the some events when USB device is connected and removed. I know that in Mac OS X I can use IOKit. But I do n't know how to get the mount point where the device is mounted. Can I get it using IOkit? Is there any cross platform solution for Linux and Mac?

A: 

No, there isn't. Under Linux you may use HAL or DeviceKit-disks D-Bus interfaces. Note those are optional components and may be absent. HAL is older and DeviceKit-disks is newer implementations, with DK-d replacing HAL.

dottedmag
Thanks a lot for the response.In general, how do I get the mount path of a USB device (I am using iPods) in Mac. I am using IOServiceMatching(kIOUSBDeviceClassName) and IOServiceAddMatchingNotification to listen to the USB device add/remove notifications. Once I get the notification I am using IORegistryEntryCreateCFProperty ( device, CFSTR(kIOBSDNameKey), kCFAllocatorDefault,0);to get the device name. But this call is returning NULL.
sbabu
Continuing from the above comment ...When I used IORegistryEntrySearchCFProperty( e, kIOServicePlane, CFSTR(kIOBSDNameKey), NULL, bits ); I am getting the BSD name as disk2. Is this how I should get the BSD name? Because the system profler is showing the device as /dev/disk2s1
sbabu
I have no idea about MacOSX.
dottedmag
A: 

Hi Saheer - I recently posted a tutorial to do this: http://joubert.posterous.com/notification-when-usb-storage-device-is-conne

Two solutions are presented; you will be interested in the second.

Joubert Nel
thanks I checked the links it is quite useful for me.
sbabu