Re: how to get volume information

Aaron Burghardt <[email protected]> Sun, 20 Feb 2011 16:19:20 -0500
Newsgroups gmane.comp.macosx.devel
Message-ID <[email protected]>
I think the IOMedia objects in the I/O Kit registry will have what you are looking for. Use stat() to get the device ID of the disk that your app is on (i.e., stat() the path of the main bundle). The ID in the stat struct is a combination of the BSD Major and BSD Minor. For example, my boot drive is:

$ stat -f "%d" /
234881026
$ printf "%#x\n" 234881026
0xe000002

where 0xe is the BSD Major, and 0x2 is BSD Minor. Create an I/O Kit matching dictionary that matches  the IOMedia class and the BSD Major and BSD Minor values you got from stat, then use it to get matching objects (for example, get an iterator and iterate its objects). If you need more references to working with I/O Kit, let me know. You should be able to determine from the IOMedia properties whether the device is optical or not (in fact, I think optical media uses  a subclass of IOMedia). Depending on the file system on the media, there may be a UUID which satisfies your second requirement.

You can use the Disk Arbitration framework as an alternate way to get IOMedia objects, but I think the registration/callback design of that framework would make it more cumbersome for your task.

Aaron


On Feb 14, 2011, at 8:45 AM, Abhijeet Singh wrote:

> Hi,In my application 1. I want to check whether my application is running from CD (removable media) or from hard disk.I dont want to allow my user to run my application from hard disk. 2. Same application i developed in windows. I used to store the volume serial number of the CD that was first time used to run my application. How can i get Volume Serial Number of the CD here?(I found stat() of BSD. It returns several volume information parameters. Can i get volume serial number from stat()?)Thanks & RegardsAbhijeetDear macosxdev ! Get Yourself a cool, short @in.com Email ID now!
> _______________________________________________
> MacOSX-dev mailing list
> [email protected]
> http://www.omnigroup.com/mailman/listinfo/macosx-dev