flash filesystem write problem

I have a flash filesystem. I am using generic driver with S29GL512 flash chip.

devf-generic -s0xf8000000,64m,128k -r -u2 -b5 -t3 -f3 -m /

The copy, erase and move operations seems good. I have a problem when I am trying to use write() to write to the file in the ffs:

int fd;
int size_written;
fd=open(fileName, O_RDWR | O_CREAT | O_TRUNC | O_DSYNC);
for (i = 0; i < p_count; i++)
char buf[] = “1234567890123456789012345678901\n” };
size_written = write( fd, buf,sizeof( buf ) );
if( size_written != sizeof( buf ) )
perror( “Error writing buf” );

The data that is written into the file is corrupted in a very specific way.
The beginning of the file is correct. The number of bytes written is correct, but some parts of the file are corrupted such that about 75% of the symbols are substituted with “00â€