Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

vishal.chauhan

macrumors newbie
Original poster
Feb 4, 2008
8
0
Hi All,

I am working on Mac OS 10.4.10 on my Mac Intel.
I can get the list of all the Disk on my MAC by following..

CFMutableDictionaryRef classesToMatch;
kern_return_t kernResult = KERN_FAILURE;

classesToMatch = IOServiceMatching( kIOMediaClass );
if ( classesToMatch == NULL ) goto Bail;
CFDictionarySetValue( classesToMatch, CFSTR(kIOMediaWholeKey), kCFBooleanTrue );

kernResult = IOServiceGetMatchingServices( kIOMasterPortDefault, classesToMatch, mediaIterator );

then Iterate through the mediaIterator.

Now I want to search the volume on my Mac through programming.
I have search for the APIs for the same but with no luck thus I have found the function to get the properties of the Volume by FSGetVolumeInfo but I donot know how to get the list of volumes.

Thanks.
Vishal
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
You can use the getmntinfo function. Here's some sample code:

Code:
#include <sys/mount.h>

struct statfs *buf = NULL;
unsigned i, count = 0;

count = getmntinfo(&buf, 0);
for (i=0; i<count; i++)
{
	char *volName = buf[i].f_mntonname;
	printf("Volume: %s\n", volName);
}
 

gnasher729

Suspended
Nov 25, 2005
17,980
5,565
Hi All,

I am working on Mac OS 10.4.10 on my Mac Intel.
I can get the list of all the Disk on my MAC by following..

CFMutableDictionaryRef classesToMatch;
kern_return_t kernResult = KERN_FAILURE;

classesToMatch = IOServiceMatching( kIOMediaClass );
if ( classesToMatch == NULL ) goto Bail;
CFDictionarySetValue( classesToMatch, CFSTR(kIOMediaWholeKey), kCFBooleanTrue );

kernResult = IOServiceGetMatchingServices( kIOMasterPortDefault, classesToMatch, mediaIterator );

then Iterate through the mediaIterator.

Now I want to search the volume on my Mac through programming.
I have search for the APIs for the same but with no luck thus I have found the function to get the properties of the Volume by FSGetVolumeInfo but I donot know how to get the list of volumes.

Thanks.
Vishal

Call FSGetVolumeInfo and pass numbers 1, 2, 3 etc. as the volumeIndex parameter. That will give you the information about the 1st, 2nd, 3rd etc. volume. Eventually one call will return an error because there are no more volumes.
 

vishal.chauhan

macrumors newbie
Original poster
Feb 4, 2008
8
0
Thanks for Reply.

Yes I do getting the list of volumes on my Mac now.
But now I have another problem that I can get various properties of the Voulme but I also want to know the start of the volume(either in terms of Sector no or in terms of block).

So would it is possible to get the start of the volume in the disk.
 

gnasher729

Suspended
Nov 25, 2005
17,980
5,565
Thanks for Reply.

Yes I do getting the list of volumes on my Mac now.
But now I have another problem that I can get various properties of the Voulme but I also want to know the start of the volume(either in terms of Sector no or in terms of block).

So would it is possible to get the start of the volume in the disk.

That is a question that might not even make sense. Connect to another computer using Samba or mount a volume on another Macintosh. Mount a Disk Image. Put a recordable CD into your computer. Check how your list of volumes changes. A good one is this: In XCode 3, create a snapshot of your project. Then check the list of volumes again.

I think it might be better if you describe what you actually want to achieve.
 

vishal.chauhan

macrumors newbie
Original poster
Feb 4, 2008
8
0
Actually I mean by sector starting that suppose a disk has 100000 sector and it has 2 volumes.

So first few sector is for the of disk own information and then there should be the start of the volume for which we have signature H+ or BD.

So I want to know how can I get the start of the volume within a disk that is logical start of volume.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.