d-sky

Hi, I have a question regarding the file system on CE. Do point me to the correct section if this isnt the right place to ask about my problem.

I'm having trouble creating a huge number of files (about 100000) in a single directory on a FAT partition on CE for logging. (Generally on a flash device)

I have a simple file creating code that generally quits midway with the error code 112 (ERROR_DISK_FULL). This shouldnt be true since the files are zero bytes and upon checking, I still have sufficient space (50MB left). Has anyone encountered this phenomena before

for(int cnt=0; cnt<100000; cnt++){
_stprintf(fileName,_T("\\Storage Card\\TestFiles\\%6d"), cnt);
hFile = CreateFile(fileName,
GENERIC_READ|GENERIC_WRITE,

FILE_SHARE_READ,

NULL,

OPEN_ALWAYS,

FILE_ATTRIBUTE_NORMAL,

NULL);

if(hFile == INVALID_HANDLE_VALUE){
printf("ERROR %d - %x\n", cnt, GetLastError());
break;
}
}

I can only guess that it has to do with the file name length. The original code has a long prefix "trx_<YEAR><MONTH><DATE><HOUR><MINUTES><SECONDS>.trx" only gives me about 2000 files before the 112 error is reported. Whereas the shorter file name effectively creates about 10000 files before quitting.

I need to expect about 100000 files of about 1-2kb each to be created over time. I know subdirectories would help and will be a possible workaround. But I need your expert oppinion on this on why this phenomena is happenening. Thanks!



Re: Smart Devices Native C++ Development ERROR_DISK_FULL with CreateFile() although sufficient space on FAT FS when massive number of files created

Ilya Tumanov

Which FAT is that FAT16 What's the volume size and cluster size






Re: Smart Devices Native C++ Development ERROR_DISK_FULL with CreateFile() although sufficient space on FAT FS when massive number of files created

d-sky

Thanks for your response, Ilya.

I am not sure and I do not know how to identify. But it is the same FAT File System used on all flash devices with WinCE. I'm using CE 5.0 and the dll that handles this FS is the fatfsd.dll.

I've found that there is indeed a bug with the FAT file system concerning WriteFile() which was fixed in the Feb2006 QFE (http://www.microsoft.com/downloads/details.aspx FamilyID=8a5147fa-6e4d-4939-bc3c-824786bccbb8&displaylang=en). I've installed it hoping that it was somehow related to the CreateFile() and would fix it. It didnt solve my problem. I'm back to square one.





Re: Smart Devices Native C++ Development ERROR_DISK_FULL with CreateFile() although sufficient space on FAT FS when massive number of files created

d-sky

I reformatted the flash to

FAT Version: FAT32

Number of FAT: 1

Root Entries: 512

Cluster Size: 0.5

TFAT: Unchecked

The volume size is 86.87MB.

I still get the same error. Specifically my filename to be "\\XXXXXstore\\trx_2007061819%4d.trx" , i only get exactly 999 files (each 1k in size). It still reports a ERROR_DISK_FULL although I have sufficient space.





Re: Smart Devices Native C++ Development ERROR_DISK_FULL with CreateFile() although sufficient space on FAT FS when massive number of files created

d-sky

New findings reveal that when complying to short file name, ie. 8.3 file format, I am able to write up to 48355 files which is a tremendous improvement. However..

A more accurate experiment shows that I get the 112 error (ERROR_DISK_FULL). Whenever long filenames are being used in CE of more than 10 characters not including the extension, exactly 999 files can only be created. This is not the case in Desktop Windows XP on a flashdisk formatted to FAT32 file system. Any attempt in renaming the file via the OS explorer interface would produce a popup alert that Disk Is Full.

Can anyone help explain to me why this is so





Re: Smart Devices Native C++ Development ERROR_DISK_FULL with CreateFile() although sufficient space on FAT FS when massive number of files created

d-sky

Found the answer:

Supporting more than 1000 files requires Extended FAT (exFAT). Extended FAT is only supported in CE6.0.

http://msdn2.microsoft.com/en-us/library/aa914353.aspx

The exFAT system offers the following advantages:

  • Enables the file system to handle growing capacities in media, increasing capacity to 32GB and larger
  • Handles more than 1000 files in a single directory
  • Speeds up storage allocation processes
  • Removes the previous file size limit of 4GB
  • Supports interoperability with future desktop operating systems
  • Provides an extensible format, including OEM-definable parameters to customize the file system for specific device characteristics

http://msdn2.microsoft.com/en-us/library/aa914353.aspx

Optional Wiki Link: http://en.wikipedia.org/wiki/ExFAT

Thanks Everyone.