/*
- * Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC.
- * Copyright (c) 2009, 2010, 2011 Your File System, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Kernel Drivers, LLC.
+ * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014 Your File System, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
- * notice,
- * this list of conditions and the following disclaimer in the
- * documentation
- * and/or other materials provided with the distribution.
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
* - Neither the names of Kernel Drivers, LLC and Your File System, Inc.
* nor the names of their contributors may be used to endorse or promote
* products derived from this software without specific prior written
// We may be performing some cleanup on the Fcb so grab it exclusive to ensure no collisions
//
- AFSDbgTrace(( AFS_SUBSYSTEM_LOCK_PROCESSING,
+
+ AFSDbgTrace(( AFS_SUBSYSTEM_LOCK_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSCleanup Acquiring Fcb lock %p EXCL %08lX\n",
+ &pFcb->NPFcb->Resource,
+ PsGetCurrentThread()));
+
+ AFSAcquireExcl( &pFcb->NPFcb->Resource,
+ TRUE);
+
+ AFSDbgTrace(( AFS_SUBSYSTEM_LOCK_PROCESSING|AFS_SUBSYSTEM_SECTION_OBJECT,
AFS_TRACE_LEVEL_VERBOSE,
"AFSCleanup Acquiring Fcb SectionObject lock %p EXCL %08lX\n",
&pFcb->NPFcb->SectionObjectResource,
AFSAcquireExcl( &pFcb->NPFcb->SectionObjectResource,
TRUE);
- //
- // If the handle has write permission ...
- //
-
- if( ((pCcb->GrantedAccess & FILE_WRITE_DATA) || pFcb->OpenHandleCount == 1) &&
- CcIsFileCached( pIrpSp->FileObject))
+ __try
{
- __try
+ //
+ // If the handle has write permission ...
+ //
+
+ if( ((pCcb->GrantedAccess & FILE_WRITE_DATA) || pFcb->OpenHandleCount == 1) &&
+ CcIsFileCached( pIrpSp->FileObject))
{
CcFlushCache( &pFcb->NPFcb->SectionObjectPointers,
}
}
}
- __except( EXCEPTION_EXECUTE_HANDLER)
- {
-
- ntStatus = GetExceptionCode();
- AFSDbgTrace(( 0,
- 0,
- "EXCEPTION - AFSCleanup Cc FID %08lX-%08lX-%08lX-%08lX Status 0x%08lX\n",
- pObjectInfo->FileId.Cell,
- pObjectInfo->FileId.Volume,
- pObjectInfo->FileId.Vnode,
- pObjectInfo->FileId.Unique,
- ntStatus));
-
- SetFlag( pObjectInfo->Fcb->Flags, AFS_FCB_FLAG_PURGE_ON_CLOSE);
- }
+ //
+ // Uninitialize the cache map. This call is unconditional.
+ //
+
+ AFSDbgTrace(( AFS_SUBSYSTEM_IO_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSCleanup Tearing down cache map for Fcb %p FileObject %p\n",
+ pFcb,
+ pFileObject));
+
+ CcUninitializeCacheMap( pFileObject,
+ NULL,
+ NULL);
+ }
+ __except( EXCEPTION_EXECUTE_HANDLER)
+ {
+
+ ntStatus = GetExceptionCode();
+
+ AFSDbgTrace(( 0,
+ 0,
+ "EXCEPTION - AFSCleanup Cc FID %08lX-%08lX-%08lX-%08lX Status 0x%08lX\n",
+ pObjectInfo->FileId.Cell,
+ pObjectInfo->FileId.Volume,
+ pObjectInfo->FileId.Vnode,
+ pObjectInfo->FileId.Unique,
+ ntStatus));
+
+ SetFlag( pObjectInfo->Fcb->Flags, AFS_FCB_FLAG_PURGE_ON_CLOSE);
}
- //
- // Uninitialize the cache map. This call is unconditional.
- //
-
- AFSDbgTrace(( AFS_SUBSYSTEM_IO_PROCESSING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSCleanup Tearing down cache map for Fcb %p FileObject %p\n",
- pFcb,
- pFileObject));
-
- CcUninitializeCacheMap( pFileObject,
- NULL,
- NULL);
-
-
- AFSDbgTrace(( AFS_SUBSYSTEM_LOCK_PROCESSING,
+ AFSDbgTrace(( AFS_SUBSYSTEM_LOCK_PROCESSING|AFS_SUBSYSTEM_SECTION_OBJECT,
AFS_TRACE_LEVEL_VERBOSE,
"AFSCleanup Releasing Fcb SectionObject lock %p EXCL %08lX\n",
&pFcb->NPFcb->SectionObjectResource,
AFSReleaseResource( &pFcb->NPFcb->SectionObjectResource);
- AFSDbgTrace(( AFS_SUBSYSTEM_LOCK_PROCESSING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSCleanup Acquiring Fcb lock %p EXCL %08lX\n",
- &pFcb->NPFcb->Resource,
- PsGetCurrentThread()));
-
- AFSAcquireExcl( &pFcb->NPFcb->Resource,
- TRUE);
-
//
// Unlock all outstanding locks on the file, again, unconditionally
//
stFileCleanup.LastAccessTime = pObjectInfo->LastAccessTime;
+ //
+ // If the file has been modified set the last write time in ObjectInfo to 'now'
+ // unless the last write time was set via this File Object. Then tell the
+ // following code to write the time.
+ //
+ if ( BooleanFlagOn( pFileObject->Flags, FO_FILE_MODIFIED) &&
+ !BooleanFlagOn( pCcb->Flags, CCB_FLAG_LAST_WRITE_TIME_SET)) {
+
+ SetFlag( pFcb->Flags, AFS_FCB_FLAG_FILE_MODIFIED);
+
+ SetFlag( pFcb->Flags, AFS_FCB_FLAG_UPDATE_LAST_WRITE_TIME);
+
+ KeQuerySystemTime(&pFcb->ObjectInformation->LastWriteTime);
+ }
+
if( BooleanFlagOn( pFcb->Flags, AFS_FCB_FLAG_FILE_MODIFIED))
{
stFileCleanup.LastWriteTime = pObjectInfo->LastWriteTime;
- ClearFlag( pFcb->Flags, AFS_FCB_FLAG_UPDATE_LAST_WRITE_TIME | AFS_FCB_FLAG_UPDATE_WRITE_TIME);
+ ClearFlag( pFcb->Flags, AFS_FCB_FLAG_UPDATE_LAST_WRITE_TIME);
}
}
- if( BooleanFlagOn( pFcb->Flags, AFS_FCB_FLAG_UPDATE_WRITE_TIME))
- {
-
- stFileCleanup.LastWriteTime = pObjectInfo->LastWriteTime;
- }
-
//
// If the count has dropped to one and there is a pending delete
// then delete the node. The final count will be decremented just