5

I was looking at the main window of Mac OSX Disk Utility and I found four informations about USB devices (when a drive item is selected):

  • Disk Description
  • Connection Bus
  • Connection Type
  • USB Serial Number

I was able to get the first three information using Disk Arbitration framework. I got them registering a callback routine in response to new disk device detection:

DARegisterDiskAppearedCallback(session, NULL, OnDiskAppeared, (void *)NULL);

The routine looked like this:

static void OnDiskAppeared(DADiskRef disk, void *__attribute__((__unused__)) ctx) {

CFDictionaryRef dict = DADiskCopyDescription(disk);

const void *DAMediaName = CFSTR("DAMediaName");
const void *DAVolumeName = CFSTR("DAVolumeName");
const void *DADeviceModel = CFSTR("DADeviceModel");
const void *DAMediaUUID = CFSTR("DAMediaUUID");
const void *DAVolumeUUID = CFSTR("DAVolumeUUID");    

printf("DAMediaName: ");
CFShow(CFDictionaryGetValue(dict, DAMediaName));
printf("DAVolumeName: ");
CFShow(CFDictionaryGetValue(dict, DAVolumeName));
printf("DADeviceModel: ");
CFShow(CFDictionaryGetValue(dict, DADeviceModel));
printf("DAMediaUUID: ");
CFShow(CFDictionaryGetValue(dict, DAMediaUUID));
printf("DAVolumeUUID: ");
CFShow(CFDictionaryGetValue(dict, DAVolumeUUID));

CFRelease(dict);}

The routine actually returned me informations about volumes and phisical drives and, in the last case, returned me the informations about the three disk properties I was talking about before.

Unfortunately I couldn't find anything about the fourth (USB Serial Number).

I printed the whole dictionary by calling:

CFDictionaryApplyFunction(dict, printKeys, NULL);

having coded the printKeys callback routine like this:

static void printKeys (const void* key, const void* value, void* context) {

CFShow(key);
CFShow(value);}

but no key returned me the desired fourth value.

I guess somewhere, maybe in the Disk Arbitration framework, there had to be something to provide such information but I can't figure out where.

Some advice?

Thanks for help.

Antonio

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Antonio
  • 105
  • 8

0 Answers0