How to determine the filesystem name in Windows CE (c/winapi)?

I want to determine the filesystem of an SD card in code (c/winapi) so I can display it for troubleshooting purposes.

I am currently using GetPartitionInfo but the resulting PARTINFO::szFileSys is “exfat.dll” regardless if the SD card is formatted as FAT32 or exFAT. I’m not interested in the driver filename. I want to identify either FAT32 or exFAT.

Any suggestions?

Did you already checked the bPartType of the PARTINFO struct? This should contain this information. See more details on MSDN.

You can use CeGetVolueInfo using CE_VOLUME_INFO dwFlags to check for TFAT. We have seen, that this does not properly work CE 7. More on that also on MSDN.

FYI:
The MSDN documentation for PARTINFO struct doesn’t mention exFAT or FAT32. FAT32 is the same as PART_DOS32, but there is no documented value for exFAT that I can find.
PARTINFO::bPartType for exFAT is 0x07 (and for FAT32 is 0x0B).
Thanks.

@ed.nafziger: Thanks for the pointing that out. You are right, there is no indicator if it is exFAT or not. If you want to dig deeper, you could read some sectors of the partition and decide up on that what type it is. We do something like that in our UpdateTool when doing a backup. If it is only about trouble shooting for the local partition, you could use the latest UpdateTool with enabled debug output. When you click the “Backup” button, you get some information of the local FlashDisk partition.

@samuel.tx do you mean that CeGetVolumeInfo is unreliable but GetPartitionInfo should be reliable? CeGetVolumeInfo seems to work fine for me, the flags value has always given me a correct bit for TFAT (I’ve never seen it wrong after hundreds of tests). I’m having trouble with GetPartitionInfo, sometimes the PARTINFO::bPartType value is wrong. The same incorrect value is also displayed by the Storage Manager control panel applet. If I format 2 SD cards as exFAT and insert both, one will show correctly as 0x07, the other as 0x04 (which is wrong). If I only insert 1 card, then sometimes the bPartType is 0x07 sometimes is 0x04. Sometimes re-inserting the card will change the value. Sometimes, if it shows the 0x04 value, then it will stick with that card, and that same value shows when putting it in another machine even after multiple reboots and multiple reformats. Any suggestions?

@ed.nafziger: We have not seen that this is kind of unstable, we just have seen, that CeGetVolumeInfo does not report the CE_VOLUME_TRANSACTION_SAFE flag for TFAT32 but it works for TexFAT32 formated disks. Currently we are not aware of any issue with that function if you have more than card inserted. Do you see that also if you have only one SD Card driver enabled?

Disabling the SDIO2 driver fixes the problem (both GetPartitionInfo and Storage Manager control panel applet shows the correct partition type).
Re-enabling the SDIO2 driver and the problem returns (installing 1 SD card formatted as exFAT the partition type shows up randomly as either 0x04 or 0x07).

FYI: I’m using V2.0B2.

Was this reproduced with the “rename”-trick as well? (Rename SDIO driver)

@samuel.tx yes I have the SDIO2 driver using its own copy of the DLL.

@ed.nafziger. I was not able to reproduce this issue. Neigher on a default setup nor on a setup using two different SDIO drivers. Here is Project including code and binary I have used to test that issue. Can you reproduce this also with that code?

@samuel.tx yes I can reproduce the issue with your code sample. 2 newly exFAT formatted SD cards.
DSK2 0x7
DSK3 0x4

After some further testing, it appears that the issue stays with a particular card. Reformatting the card in Windows CE or Windows 7 as exFAT or FAT32 doesn’t seem to actually format the card. There are no errors and nothing to indicate something went wrong. Putting the card into Windows CE and running your program or going to storage manager control panel applet, it shows the 0x04 for the partition type.
After using the SD card formatter from https://www.sdcard.org/downloads/formatter_4/index.html (the only option is to format as FAT32) it now seems to work properly, both your program and storage manager show 0x0B for the partition type (correct). I then formatted the card as exFAT in Windows CE and its now showing 0x07 for the partition type (correct).

Thanks for the update.Did not know that tool before. Seems the card was “broke” on a deeper layer, which was not reached by the format of the OS. Probably the SD Card Formater sends some additional special SD CMDs.