Strange behaviorof Windows File Caching

Hi,

I am writing a file using Win32 API on a XP Fat32 hard disk.
I close the file…
I read the hard disk directory sectors by opening the physical disk using PhysicalDrive0 and CreateFile Function
followed by ReadFile function.

The directory entry does not show up. If I comeback after 2-3 minutes, and read again it shows again.

My questions are:

a) I understand it is an issue of lazy writing. But if I write something and want to read it back, shouldn’t I be able to read it whatever may be the caching mechanism?

b) Can you please tell me, how to flush the drive anyway,so that I can read the directory information? Is there a flush drive
API in Win32?

Help is urgently needed.

Thanks
Basudeb

FlushFileBuffers helps a lot.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “basudeb gupta”
To: “Windows File Systems Devs Interest List”
Sent: Sunday, September 03, 2006 6:28 PM
Subject: [ntfsd] Strange behaviorof Windows File Caching

> Hi,
>
> I am writing a file using Win32 API on a XP Fat32 hard disk.
> I close the file…
> I read the hard disk directory sectors by opening the physical disk using
PhysicalDrive0 and CreateFile Function
> followed by ReadFile function.
>
> The directory entry does not show up. If I comeback after 2-3 minutes, and
read again it shows again.
>
> My questions are:
>
> a) I understand it is an issue of lazy writing. But if I write something and
want to read it back, shouldn’t I be able to read it whatever may be the
caching mechanism?
>
> b) Can you please tell me, how to flush the drive anyway,so that I can read
the directory information? Is there a flush drive
> API in Win32?
>
> Help is urgently needed.
>
> Thanks
> Basudeb
>
>
> —
> Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com