Re: Notifications when iPods are mounted...
Re: Notifications when iPods are mounted...
- Subject: Re: Notifications when iPods are mounted...
- From: Uli Kusterer <email@hidden>
- Date: Sat, 14 Jan 2006 16:44:16 +0100
Am 14.01.2006 um 06:58 schrieb Steve Checkoway:
I'm not quite sure which info you're looking for here, but see below.
Ummm... I just realised that half of my devices don't have the name
I was looking for (or have the same), so it's moot. :-( And just for
the archives: IORegistryEntryGetName() only gives the volume name
(i.e. the name shown in Finder that the user can change).
But I guess the USB Vendor and Device ID would serve the same purpose.
About the easiest way to do this is to get the notification from
NSWorkspace (or the Carbon event), get the mounted path to the
device and call statfs(2) on that path. Then, if you look at the
f_mntfromname member of the statfs struct, it should start with /
dev/ (or _PATH_DEV as defined in <paths.h>). Remove that bit and
you should have disk[#[s#]]. To get the io_object_t that you would
use with the IOKit, you set up a matching dictionary using
IOBSDNameMatching() followed a call to IOServiceGetMatchingServices
() to get an io_iterator_t to iterate over the devices.
Okay, I got this working as well (though using Carbon's
PBHGetVolParmsSync() instead of statfs()). The trouble is that the
IOKit device doesn't seem to have any vendor and device IDs. When I
call IORegistryEntryCreateCFProperties(), I get:
{
"BSD Major" = 14;
"BSD Minor" = 20;
"BSD Name" = disk4s1;
"BSD Unit" = 4;
Content = "DOS_FAT_32";
"Content Hint" = "DOS_FAT_32";
Ejectable = 1;
IOBusyInterest = "IOCommand is not serializable";
Leaf = 1;
"Partition ID" = 1;
"Preferred Block Size" = 512;
Removable = 1;
Size = 1043984384;
Whole = 0;
Writable = 1;
}
Lots of info I can use for other nefarious purposes, but nothing that
even remotely looks like those IDs. I guess I could take all the
possible vendor/device IDs and match for each one with
IOServiceGetMatchingServices(), but since the typical user will have
at most one of these devices attached and the list of possible ones
could be rather large, I'd rather just be able to check the newly-
inserted device's ID.
I also tried checking the parents of this service, but they didn't
contain any info that was much different.
errr... help?
Cheers,
-- M. Uli Kusterer
http://www.zathras.de
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden