Re: Re: how to get volume information

"Abhijeet Singh" <[email protected]> Mon, 21 Feb 2011 18:22:18 +0530
Newsgroups gmane.comp.macosx.devel
Message-ID <[email protected]>
Hi,Thanks for the help. I finally used Disk Arbitration framework to find out whether program is running from removable media or not. But to get the identification number i don't find any method in Disk Arbitration framework. Is there any method that gives UUID in Disk Arbitration framework. I also checked stat structure. There is one field stdev. Can I use it as a identification number of a media. Because it always gives me a different number for different USB pen drive and same number for same drive.Thanks & RegardsAbhijeet Original message From:"Aaron Burghardt"< [email protected] >Date: 21 Feb 11 02:48:33Subject: Re: how to get volume informationTo: Cc: "macosxdev" 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:$ s
 tat f "%d" /234881026$ printf "%#x
" 2348810260xe000002where 0xe is the BSD Major, and 0x2 is BSD Minor. Create an I/O Kit matching dictionary that matchesthe 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 usesa 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.AaronOn 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!> > MacOSXdev mailing list> [email protected]> http://www.omnigroup.com/mailman/listinfo/macosxdevGet Yourself a cool, short @in.com Email ID now!