Use FILE_FLAG_WRITE_THROUGH | FILE_FLAG_NO_BUFFERING with OVERLAPPED IO
If the hardware supports this, and since we are now finally rid of IDE drives generally it does, the IOP will not return until you can rely on persistent storage (or a broken driver you shout sue the makers of )
Sent from Surface Pro
From: xxxxx@rafael.co.il
Sent: Tuesday, February 10, 2015 11:28 AM
To: Windows System Software Devs Interest List
Hi all,
I have a user mode process (written in C++) that needs to write a file to a local hard disk partition
and then verify that the file has been written to the physical media without errors.
Is this doable under Windows? How?
I ask the question in NTDEV because I know that hard disks have their own internal cache, so I
am worried that if I use the following sequence: [write - flush - read - compare], then the
read may return (at least some) data from the on-disk cache, and not from the physical media.
In case the physical media has errors, I will not be able to detect the corruption.
I think that if I can purge the on-disk cache then all the required data will be read from the
physical media. But I don’t know how to do that.
I am aware that Windows has its own caching as well.
Thank you,
Itai Handler
NTDEV is sponsored by OSR
Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
OSR is HIRING!! See http://www.osr.com/careers
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer