Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I am able to obtain the filesystem for partitions on standard MBR disks. However I am hitting a brick wall trying to obtain the filesystem on a GPT-style partitioning scheme. To-date I can obtain the volume information (from a little C++ CLI test app - compiled with VS2010):
[1] GPT entry:
        partition number (2)
        partition name: Basic data partition
        partition Type GUID: {EBD0A0A2-B9E5-4433-87C0-68B6B72699C7}
        partition GUID ID: {AF359AFD-C400-419A-A0DF-6E0E084A548E}

ERROR: Cannot access volume '\\?\Volume{AF359AFD-C400-419A-A0DF-6E0E084A548E}' filesystem information. Have you specified a valid volume GUID? [DeviceIoControl() error: 1]

The above partition is standard 2Tb NTFS partition on a 2Tb harddisk (entry 1 is obviously the system reserved GPT table). I can obtain a handle to the Volume correctly (using the CreateFile() function). However when I call the DeviceIoControl(hVolume, FSCTL_QUERY_FILE_SYSTEM_RECOGNITION, ...) function it returns an invalid function error??

Does the FSCTL_QUERY_FILE_SYSTEM_RECOGNITION call work for GPT formatted harddisks? If not how do I obtain the filesystem information for a given GUID volume code?

Thanks
Bob
Posted
Updated 31-Aug-11 17:50pm
v2

1 solution

OK
I solved this problem myself. Hopefully the solution will help other folks. The
answer is to use the function: GetVolumeInformation().

You must pass L"\\?\Volume{AF359AFD-C400-419A-A0DF-6E0E084A548E}\" (an example GUID volume descriptor) as the first argument. NOTE THE TRAILING SLASH (\)... Ah wonderful Microsoft - being consistent with their APIs again!

The return parameters from the GetVolumeInformation():
lpFileSystemNameBuffer [out]
will contain the real world filesystem on your GPT/MBR partition!

Bob
 
Share this answer
 
Comments
André Kraak 1-Sep-11 7:55am    
+5 Thank you for posting the self found solution. It indeed might help other people with the same problem.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900