468,496 Members | 1,804 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,496 developers. It's quick & easy.

File contains only or mainly zero

I've got a problem with an embedded PC which generates corrupted files during a shutdown-boot cycle. The corrupted files contain the correct (estimated) number of bytes, but all bytes have a zero value. To make the problem more interesting this occurs sometimes (after 1 cycle or after 30 cycles), and when it happens it can be possible that only the last number of bytes of the file contain zero's. Shutdown means that the power is shut down on the complete machine, thus stopping the PC immdiately. There's no way of forcing the OS to start a shutdown process.

System used:
Embedded PIV platform based on Intel 845GV chipset.
Harddisk: Maxtor Fireball 3 or Diamonmax Plus 8 (40Gb). Microsoft XP embedded, EWF using RAM overlay on c: partition. Corrupted files are created on NTFS non-EWF d: partition.

File handling code (c++):

m_hFile = CreateFile( fname,
GENERIC_WRITE | GENERIC_READ,
0,
&sa,
OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH | FILE_FLAG_RANDOM_ACCESS ,
NULL);

if (m_hFile)
{
//doing stuff...

FlushFileBuffers(m_hFile);
CloseHandle(m_hFile);
}

And on the same file(s), not at the same time:

fp = fopen(fname,"rt");

if (fp)
{
//doing stuff...

fflush(fp);
fclose(fp);
}

I suspect that some kind of buffer failed to write (all) bytes to an already prepared file. This explains the number of bytes being zero. If this is an OS buffer, a filesystem buffer or a hardware buffer is unclear to me. Does one of you have experienced the same problem, or got any idea on how I can solve this problem? "

===
Afsluiting :) :
"
Thanks in advance,

Greetings from your big friend from The Netherlands, "
Jul 21 '06 #1
0 1042

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

12 posts views Thread by aa | last post: by
1 post views Thread by jase_dukerider | last post: by
3 posts views Thread by comp_novice | last post: by
7 posts views Thread by Ympostor | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.