PC Review


Reply
Thread Tools Rate Thread

Bypassing Disk Caching

 
 
sturnfie@gmail.com
Guest
Posts: n/a
 
      17th Feb 2007
Anyone know a way to bypass disk caching in Windows XP?

I am working on a C# program that needs to verify the integrity of
data that was copied to a removable drive. My approach is to read the
data back and compare it to the original data source. Problem is,
this process is happening way too quickly to be possible.

I used filemon to see what the file system is doing when I attempt to
copy back the file I just wrote to the removable drive, and although
there are tons of FASTIO_WRITE requests directing chucks of the data
to a local file (a file that holds a "copy" of the removable drive's
data), there is not a single request for any information from the
external drive.

My best guess is that the entire file is still in the local disk's
cache; this would explain the super speeds I am seeing.

So my question(s): Is there a way to force windows to not use the
disk cache? If not, is there a way to flush the disk cache? Is there
another workaround someone can suggest?

I am going to start trying to hack something together to fool it
(maybe renaming the file on the external drive will be enough to fool
it), but thanks in advance to anyone who knows a proper way to handle
this problem.

--
lucas

 
Reply With Quote
 
 
 
 
Barry Kelly
Guest
Posts: n/a
 
      17th Feb 2007
(E-Mail Removed) wrote:

> Anyone know a way to bypass disk caching in Windows XP?


Yes, use FILE_FLAG_NO_BUFFERING with CreateFile. That'll require
P/Invoke etc., and there are other restrictions, like working with
aligned buffers of specific sizes etc.

> If not, is there a way to flush the disk cache?


FlushFileBuffers is the function to use, again with P/Invoke.

-- Barry

--
http://barrkel.blogspot.com/
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Disk Caching =?Utf-8?B?a2Vs?= Windows XP Hardware 1 22nd Jul 2004 08:59 PM
Disk write-caching LundFanatic Windows XP Customization 2 5th Apr 2004 06:03 AM
Disk caching Mark Henry Microsoft Windows 2000 Developer 0 15th Mar 2004 08:57 PM
disable Disk Caching =?Utf-8?B?QW5kcmV3IFRhbg==?= Microsoft Windows 2000 1 14th Nov 2003 10:08 AM
Disk Caching Hafiz Shivji Microsoft Windows 2000 Hardware 0 27th Aug 2003 03:00 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:53 PM.