Gday All,
We are facing a problem of data inconsistency on using
FlushFileBuffers() on NTFS partitions. We need to run “chkdsk” utility
to bring the data
in Sync.
I have two applications both of whom access the drive through RAW mode
(using CreateFile() API with the parameter \\.\g:.) One application
writes to the drive (writer app) and the other application reads from
the drive.(reader app)
The problem arises when I try to see the contents of the drive through
Windows Explorer. It does not show me the writes done by the writer
application. I tried to issue a FlushFileBuffers() on the file handle
of the writer app before checking the contents through Windows
Explorer but was not successful. If I try the same set of operations
on a FAT FS it succeeds and data can be seen in Explorer.
Interestingly if I lock the drive using
(DeviceIoControl(hVolume, FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0,
&dwBytesReturned, NULL))
and then unlock it using
DeviceIoControl(hVolume, FSCTL_UNLOCK_VOLUME, NULL, 0, NULL, 0,
&dwBytesReturned, NULL))
where hVolume = File Descriptor of writer app.
data is found to be consistent even on NTFS partitions. ( I am not
reading or writing data when obtaining the lock)
Could anyone please let me know why FlushFileBuffers() is failing and
how does data comes in sync on issuing “chkdsk” for NTFS partition ?
Thanks,
- Saurabh