Re: Re: how to get volume information

"Abhijeet Singh" <[email protected]> Sat, 06 Aug 2011 18:14:36 +0530
Newsgroups gmane.comp.macosx.devel
Message-ID <[email protected]>
Hi,Can you give me some more reference on I/O Kit. I just want to allow m=
y application to be run from USB Jump drive or from CD/DVD. I dont want t=
o allow user to run it from Hardisk.I am using getFileSystemInfoForPath o=
f NSWorkspace class to retrieve the same information. It works fine with =
Jump drive or CD drive but when I create DMG file of my application and c=
opy it on my hard disk and then run it from hard disk it let me run my ap=
plication.Thanks & RegardsAbhijeet Original message From:"Aaron Burghardt=
"< [email protected] >Date: 25 Feb 11 17:11:34Subject: Re: how to=
 get volume informationTo: Cc: "macosxdev" Hi,Sorry, didn't see your repl=
y.stdev is not a UUID, it is a reference that is valid only as long as th=
e device is connected. I should have been more explicit in my command lin=
e example,but "stat f "%d" prints the stdev field.Once you have the DADis=
k, use DADiskCopyDescription to get a dictionary of properties, in which =
you will find the UUID with the key kDADi
 skDescriptionMediaUUIDKey (see DADisk.h for other keys that may be of in=
terest). Note, a DADisk is a wrapper around an IOMedia object and the des=
cription dictionary corresponds directly to the properties in the IOMedia=
 object.Also, CFShow() is useful for printing the description dictionary =
to the console.AaronOn Feb 21, 2011, at 7:52 AM, Abhijeet Singh wrote:Hi,=
Thanks for the help. I finally used Disk Arbitration framework to find ou=
t whether program is running from removable media or not. But to get the =
identification number i don't find any method in Disk Arbitration framewo=
rk. 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"< aaron.burghard=
[email protected] >Date: 21 Feb 11 02:48:33Subj
 ect: Re: how to get volume informationTo: Cc: "macosxdev" I think the IO=
Media 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., s=
tat() the path of the main bundle). The ID in the stat struct is a combin=
ation of the BSD Major and BSD Minor. For example, my boot drive is:$ sta=
t f "%d" /234881026$ printf "%#x " 2348810260xe000002where 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 itera=
tor 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 p=
roperties 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 me=
dia, there may be a UUID which satisfies=20
 your second requirement.You can use the Disk Arbitration framework as an=
 alternate way to get IOMedia objects, but I think the registration/callb=
ack 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 applica=
tion 1. I want to check whether my application is running from CD (remova=
ble media) or from hard disk.I dont want to allow my user to run my appli=
cation 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. Ca=
n i get volume serial number from stat()?)Thanks & RegardsAbhijeetDear ma=
cosxdev ! Get Yourself a cool, short @in.com Email ID now!> Get Yourself =
a cool, short @in.com Email ID now!