tags:

views:

334

answers:

4

I'm looking for a way to list all connected storage devices, like Disk Utility does. That means also for not mounted volumes.

The second thing I'm looking for is more detailed information, to what port a device is connected, the size of it and the block size of it.

Is there an API to do this? I prefer Cocoa, but a unix API is also ok.

What I've found so far

diskutil can be used on the command line.

getmntinfo and getfsstat return information about mounted devices.

A: 

The command:

diskutil info /Volumes/*

might work for you.

Michael Gee
This works only for mounted volumes. I'm looking for a way to get information about unmounted devices.
Georg
A: 

There is also FSGetVolumeInfo(). I am not sure if it works for unmounted volumes.

mouviciel
A: 

Check out df in the terminal and statfs (loot at man 2 statfs).

These will both tell you the size, what is free and used, and statfs (in whatever language you are using) will give you block sizes and such.

Mike Boers
This works only for mounted volumes. I'm looking for a way to get information about unmounted devices.
Georg
+1  A: 

You can use the the various IOKit APIs to search for all block devices. You can check out the documentation, specifically you want to pay attention to IOServiceGetMatchingServices. There is example code to find all CD-Roms media in the system that could be easily adapted.

Louis Gerbarg
This looks very promising, I'll look into it.
Georg
Easily the most complicated framework OS X has, I'm still trying to find out how exactly to use it.
Georg