• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1333
  • Last Modified:

16MB Compact Flash Card states wrong geometry data (half size only) - How to determine capacity properly?

Hi everybody,

I have a very strange phenomenon here. I took two CF cards, one 16MB, the other 512MB and tried to determine their storage capacity programmatically. To do so, I used two different methods (all experiments done on Windows 2000 with latest updates):

1) Determine size of logical drive with GetDiskFreeSpace and GetVolumeInformation.
This delivers the proper size on both cards but obviously only when the cards are properly formatted.

2) Open a handle to the physical device with CreateFile, then use DeviceIoControl with the control code IOCTL_DISK_GET_DRIVE_GEOMETRY. This should work as long as Windows can see a card in the card reader.
However, for this method, the 16MB card returns a structure which would outline an 8MB card!
I did some searching on the website and found some WMI script for enumerating all the hard discs in a computer. This delivers the wrong value of 8MB as well!

My first assumption was that the card is broken somehow, but I tried another card and it shows the same effect. Both cards are completely okay, my Digicam detects them as 16MB card as well and it is possible to use the whole 16MB for data, too.

So here are my questions:
Is this behaviour common? How do I determine the proper size? (My digicam can, so should Windows!) And is there another, more reliable method of determining the card size regardless of a working file system on it?

I am pretty clueless at present, any ideas and suggestions are welcome :D

0
engelmann_media
Asked:
engelmann_media
  • 4
1 Solution
 
WatzmanCommented:

You never told us how you were accessing the cards under 2000 (what physical hardware).  That might be part of the problem/solution.

Also, I'd have more confidence working with CF cards with XP than with 2000.
0
 
engelmann_mediaAuthor Commented:
I am using a noname USB 2.0 card reader with slots for CF, MMC, SD, etc. General usage of the card is completely okay, filled the card with different patterns and ran compares, everything seems completely fine for both cards. Although I doubt that 2000 is the problem, I will do some tests on XP just to verify everything.
0
 
engelmann_mediaAuthor Commented:
Okay, some more details from the lab:
I get identical results on several cards, 2000 and XP, using two different card readers. For example:

GetVolumeInformation delivers 8 sectors per cluster, 512 bytes per sector, 3900 clusters total size. Makes 15,974,400 bytes.
The DeviceIoControl method delivers 1 cylinder, 63 tracks per cylinder, 255 sectors per track, 512 bytes per sector. Makes 8,225,280 bytes. What the heck?!

0
Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

 
engelmann_mediaAuthor Commented:
One more thing: I found this conversation on google: http://www.webservertalk.com/archive232-2005-2-638923.html
The recommendation is not to use CHS notation but LBA mode. So how do I determine the physical size of a disk in Windows (2000, XP and later only will be fine) in LBAs?
0
 
engelmann_mediaAuthor Commented:
I couldn't found any other solution than just working around, by attempting to read beyond the physical size stated by the geometry info. If I can read noticably further, I will change the nominal capacity of the card to the next common size and verify this by additional read attempts. I know this sounds ugly but it works for all the cards I could test. It didn't occur on any other cards than just the 16MB items I had to examine anyway, so I guess this is a safe method when the partition information has been corrupted or deleted.

Just in case somebody ever stumbles across this, I'd like to have this question PAQ'd and refunded, thanks. Maybe my findings can be helpful to others out there.
0
 
moduloCommented:
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now