Hi,
How do I purge a cached file (or invalidate a cached file)? For example,
when there is a file truncation, I would like to force the cached file to be
purged, and I am not sure how to do this. I assume that after a cache file
is purged, a read request (from kernel or usermode) will always initiate a
paging IO read, am I right?
What did I do wrong with the following code? The cache is not purged at all.
Thanks for any information!
-SL
VOID PurgeCacheFile(PFILE_OBJECT FileObject) {
PFSRTL_COMMON_FCB_HEADER pFcb =
(PFSRTL_COMMON_FCB_HEADER)FileObject>FsContext;
__try {
CcFlushCache( FileObject->SectionObjectPointer, NULL, 0, NULL );
FsRtlEnterFileSystem();
ExAcquireResourceExclusive( pFcb->PagingIoResource, TRUE);
ExReleaseResource( pFcb->PagingIoResource );
FsRtlExitFileSystem();
if (!CcPurgeCacheSection( FileObject->SectionObjectPointer, NULL, 0,
FALSE )) {
DbgPrint((“PurgeCacheFile: failed\n”));
} else {
DbgPrint((“PurgeCacheFile: success\n”));
}
} __except (EXCEPTION_EXECUTE_HANDLER) {
DbgPrint((“### PurgeCacheFile: Exception encountered with value =
%x\n”, GetExceptionCode()));
DbgBreakPoint();
}
}
You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com