Hi,
Please point me in the right direction.
I am looking at the fileinfo.c in the fastfat code. Here I am looking at 2 functions
- FatSetEndOfFileInfo
- FatSetAllocationInfo
I have written a test appication that does below:
- Create a file [caching enabled].
- Write into the file using WriteFile api.
- Wait for sometime while debugging.
- Set end of file so that the length of the file is less than the amount of data that was written using the write call.
- Close the file.
The WriteFile api will result in a cached write and then this cached data will be written to the disk. After I observe this paging write in filespy I resume with debugging my test application. When set end of file is called to reduce the file size I can see two set information calls that change the end of file and the allocation size. Also I see an additional paging write [top level irp set FSRTL_CACHE_TOP_LEVEL_IRP] that writes the data upto the new reduced length.
Does CCSetFilesizes result in this additional write?
Does CCSetFilesizes in FatSetEndOfFileInfo or FatSetAllocationInfo (equivalent functions with NTFS) resulting in the additional write?
Rajeev Nagar book [CCSetFileSizes] pg. 355 mentions that “if the new end of file is less then previous end of file the cache manager may purge the cache of all the extraneous pages. You should note that in certain cases the NT cache manager may actually flush some dirty data to disk before purging the pages from the cache”
Also how should I handle the write byteoffset for this write if I insert header in the file?
Thanks,
Trav