Fatfsys problem with available space

I’m using a call to disk_space to calculate the used disk space
on a DOS partition on an IDE compatible flash device
(Kontron chipDISK). I’m getting anomalies if the software has
been running for a while.

The used disk space is calculated by:
result = disk_space(evl_data, &free_blocks, &total_blocks);
if (result !=-1) {
eventlog_usage = 100.0 - 100.0 * free_blocks / total_blocks;

After a while this goes up and up, even over 100%, and if all
files are deleted from the DOS partition, the space freed up
is not reflected in this statistic. IT goes down a little
but never back to or close to 0 as expected.

If the system is reset, things work again for a while.

A chkdsk ran from booting DOS on the partition didn’t reveal
anything obviously wrong.

I’m comparing this information against information gathered
from running du and ls -l.

The DOS partition was an unfortunate choice, and there is a
chance yet to change it to a QNX partition.
I’m just concerned that the same problem will manifest with a
QNX partition.

Any ideas?