AFSVolumeCB *pNewVolumeCB = NULL;
LONG NewVolumeReferenceReason = AFS_VOLUME_REFERENCE_INVALID;
AFSDirectoryCB *pDirectoryEntry = NULL, *pParentDirEntry = NULL;
+ AFSDirectoryCB *pNewParentDirEntry = NULL;
WCHAR *pwchBuffer = NULL;
UNICODE_STRING uniComponentName, uniRemainingPath, uniParsedName;
ULONG ulNameDifference = 0;
pParentDirEntry,
&pNewVolumeCB,
&NewVolumeReferenceReason,
- &pParentDirEntry,
+ &pNewParentDirEntry,
&pDirectoryEntry,
NULL);
NewVolumeReferenceReason = AFS_VOLUME_REFERENCE_INVALID;
- if( !NT_SUCCESS( ntStatus) ||
- ntStatus == STATUS_REPARSE)
- {
-
- if( ntStatus == STATUS_OBJECT_NAME_NOT_FOUND)
- {
-
- if( pDirectoryEntry != NULL)
- {
-
- lCount = InterlockedDecrement( &pDirectoryEntry->DirOpenReferenceCount);
+ //
+ // AFSLocateNameEntry does not alter the reference count of
+ // pParentDirectoryCB and it returns pNewParentDirectoryCB with
+ // a reference held.
+ //
- AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSRetrieveFileAttributes Decrement1 count on %wZ DE %p Ccb %p Cnt %d\n",
- &pDirectoryEntry->NameInformation.FileName,
- pDirectoryEntry,
- NULL,
- lCount);
+ lCount = InterlockedDecrement( &pParentDirEntry->DirOpenReferenceCount);
- ASSERT( lCount >= 0);
- }
- else
- {
+ AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSRetrieveFileAttributes DecrementX count on %wZ DE %p Cnt %d\n",
+ &pParentDirEntry->NameInformation.FileName,
+ pParentDirEntry,
+ lCount);
- lCount = InterlockedDecrement( &pParentDirEntry->DirOpenReferenceCount);
+ pParentDirEntry = pNewParentDirEntry;
- AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSRetrieveFileAttributes Decrement2 count on %wZ DE %p Ccb %p Cnt %d\n",
- &pParentDirEntry->NameInformation.FileName,
- pParentDirEntry,
- NULL,
- lCount);
+ pNewParentDirEntry = NULL;
- ASSERT( lCount >= 0);
- }
- }
+ if( !NT_SUCCESS( ntStatus) ||
+ ntStatus == STATUS_REPARSE)
+ {
try_return( ntStatus);
}
FileInfo->ChangeTime = pDirectoryEntry->ObjectInformation->ChangeTime;
- //
- // Remove the reference made above
- //
+try_exit:
- lCount = InterlockedDecrement( &pDirectoryEntry->DirOpenReferenceCount);
+ if( pDirEntry != NULL)
+ {
- AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSRetrieveFileAttributes Decrement3 count on %wZ DE %p Ccb %p Cnt %d\n",
- &pDirectoryEntry->NameInformation.FileName,
- pDirectoryEntry,
- NULL,
- lCount);
+ AFSExFreePoolWithTag( pDirEntry, AFS_GENERIC_MEMORY_2_TAG);
+ }
- ASSERT( lCount >= 0);
+ if( pDirectoryEntry != NULL)
+ {
-try_exit:
+ lCount = InterlockedDecrement( &pDirectoryEntry->DirOpenReferenceCount);
- if( pDirEntry != NULL)
+ AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSRetrieveFileAttributes Decrement1 count on %wZ DE %p Ccb %p Cnt %d\n",
+ &pDirectoryEntry->NameInformation.FileName,
+ pDirectoryEntry,
+ NULL,
+ lCount);
+
+ ASSERT( lCount >= 0);
+ }
+
+ if ( pParentDirEntry != NULL)
{
- AFSExFreePoolWithTag( pDirEntry, AFS_GENERIC_MEMORY_2_TAG);
+ lCount = InterlockedDecrement( &pParentDirEntry->DirOpenReferenceCount);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSRetrieveFileAttributes Decrement2 count on %wZ DE %p Ccb %p Cnt %d\n",
+ &pParentDirEntry->NameInformation.FileName,
+ pParentDirEntry,
+ NULL,
+ lCount);
+
+ ASSERT( lCount >= 0);
}
if( pVolumeCB != NULL)
AFSVolumeCB *pNewVolumeCB = NULL;
LONG NewVolumeReferenceReason = AFS_VOLUME_REFERENCE_INVALID;
AFSDirectoryCB *pDirectoryEntry = NULL, *pParentDirEntry = NULL;
+ AFSDirectoryCB *pNewParentDirEntry = NULL;
WCHAR *pwchBuffer = NULL;
UNICODE_STRING uniComponentName, uniRemainingPath, uniParsedName;
ULONG ulNameDifference = 0;
pParentDirEntry,
&pNewVolumeCB,
&VolumeReferenceReason,
- &pParentDirEntry,
+ &pNewParentDirEntry,
&pDirectoryEntry,
NULL);
NewVolumeReferenceReason = AFS_VOLUME_REFERENCE_INVALID;
- if( !NT_SUCCESS( ntStatus) ||
- ntStatus == STATUS_REPARSE)
- {
-
- if( ntStatus == STATUS_OBJECT_NAME_NOT_FOUND)
- {
-
- if( pDirectoryEntry != NULL)
- {
-
- lCount = InterlockedDecrement( &pDirectoryEntry->DirOpenReferenceCount);
+ //
+ // AFSLocateNameEntry does not alter the reference count of
+ // pParentDirectoryCB and it returns pNewParentDirectoryCB with
+ // a reference held.
+ //
- AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSEvaluateRootEntry Decrement1 count on %wZ DE %p Ccb %p Cnt %d\n",
- &pDirectoryEntry->NameInformation.FileName,
- pDirectoryEntry,
- NULL,
- lCount);
+ lCount = InterlockedDecrement( &pParentDirEntry->DirOpenReferenceCount);
- ASSERT( lCount >= 0);
- }
- else
- {
+ AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSEvaluateRootEntry DecrementX count on %wZ DE %p Cnt %d\n",
+ &pParentDirEntry->NameInformation.FileName,
+ pParentDirEntry,
+ lCount);
- lCount = InterlockedDecrement( &pParentDirEntry->DirOpenReferenceCount);
+ pParentDirEntry = pNewParentDirEntry;
- AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSEvaluateRootEntry Decrement2 count on %wZ DE %p Ccb %p Cnt %d\n",
- &pParentDirEntry->NameInformation.FileName,
- pParentDirEntry,
- NULL,
- lCount);
+ pNewParentDirEntry = NULL;
- ASSERT( lCount >= 0);
- }
- }
+ if( !NT_SUCCESS( ntStatus) ||
+ ntStatus == STATUS_REPARSE)
+ {
pVolumeCB = NULL;
*TargetDirEntry = pDirectoryEntry;
+ pDirectoryEntry = NULL;
+
try_exit:
+ if( pDirectoryEntry != NULL)
+ {
+
+ lCount = InterlockedDecrement( &pDirectoryEntry->DirOpenReferenceCount);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSEvaluateRootEntry Decrement1 count on %wZ DE %p Ccb %p Cnt %d\n",
+ &pDirectoryEntry->NameInformation.FileName,
+ pDirectoryEntry,
+ NULL,
+ lCount);
+
+ ASSERT( lCount >= 0);
+ }
+
+ if ( pParentDirEntry != NULL)
+ {
+
+ lCount = InterlockedDecrement( &pParentDirEntry->DirOpenReferenceCount);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSEvaluateRootEntry Decrement2 count on %wZ DE %p Ccb %p Cnt %d\n",
+ &pParentDirEntry->NameInformation.FileName,
+ pParentDirEntry,
+ NULL,
+ lCount);
+
+ ASSERT( lCount >= 0);
+ }
+
if( pDirEntry != NULL)
{
UNICODE_STRING uniFullPathName, uniRemainingPath, uniComponentName, uniParsedName;
AFSNameArrayHdr *pNameArray = NULL;
AFSDirectoryCB *pDirectoryEntry = NULL, *pParentDirEntry = NULL;
+ AFSDirectoryCB *pNewParentDirEntry = NULL;
LONG lCount;
__Enter
pParentDirEntry,
&pNewVolumeCB,
&NewVolumeReferenceReason,
- &pParentDirEntry,
+ &pNewParentDirEntry,
&pDirectoryEntry,
NULL);
NewVolumeReferenceReason = AFS_VOLUME_REFERENCE_INVALID;
- if( !NT_SUCCESS( ntStatus) ||
- ntStatus == STATUS_REPARSE)
- {
-
- //
- // The volume lock was released on failure or reparse above
- // Except for STATUS_OBJECT_NAME_NOT_FOUND
- //
-
- if( ntStatus == STATUS_OBJECT_NAME_NOT_FOUND)
- {
-
- if( pDirectoryEntry != NULL)
- {
-
- lCount = InterlockedDecrement( &pDirectoryEntry->DirOpenReferenceCount);
+ //
+ // AFSLocateNameEntry does not alter the reference count of
+ // pParentDirectoryCB and it returns pNewParentDirectoryCB with
+ // a reference held.
+ //
- AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSGetObjectStatus Decrement1 count on %wZ DE %p Ccb %p Cnt %d\n",
- &pDirectoryEntry->NameInformation.FileName,
- pDirectoryEntry,
- NULL,
- lCount);
+ lCount = InterlockedDecrement( &pParentDirEntry->DirOpenReferenceCount);
- ASSERT( lCount >= 0);
- }
- else
- {
+ AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSGetObjectStatus DecrementX count on %wZ DE %p Cnt %d\n",
+ &pParentDirEntry->NameInformation.FileName,
+ pParentDirEntry,
+ lCount);
- lCount = InterlockedDecrement( &pParentDirEntry->DirOpenReferenceCount);
+ pParentDirEntry = pNewParentDirEntry;
- AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSGetObjectStatus Decrement2 count on %wZ DE %p Ccb %p Cnt %d\n",
- &pParentDirEntry->NameInformation.FileName,
- pParentDirEntry,
- NULL,
- lCount);
+ pNewParentDirEntry = NULL;
- ASSERT( lCount >= 0);
- }
- }
+ if( !NT_SUCCESS( ntStatus) ||
+ ntStatus == STATUS_REPARSE)
+ {
pVolumeCB = NULL;
try_return( ntStatus);
}
- //
- // Remove the reference obtained from AFSLocateNameEntry
- //
-
- lCount = InterlockedDecrement( &pDirectoryEntry->DirOpenReferenceCount);
-
- AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSGetObjectStatus Decrement3 count on %wZ DE %p Ccb %p Cnt %d\n",
- &pDirectoryEntry->NameInformation.FileName,
- pDirectoryEntry,
- NULL,
- lCount);
-
- ASSERT( lCount >= 0);
-
pObjectInfo = pDirectoryEntry->ObjectInformation;
lCount = AFSObjectInfoIncrement( pObjectInfo,
try_exit:
+ if( pDirectoryEntry != NULL)
+ {
+
+ lCount = InterlockedDecrement( &pDirectoryEntry->DirOpenReferenceCount);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSGetObjectStatus Decrement1 count on %wZ DE %p Ccb %p Cnt %d\n",
+ &pDirectoryEntry->NameInformation.FileName,
+ pDirectoryEntry,
+ NULL,
+ lCount);
+
+ ASSERT( lCount >= 0);
+ }
+
+ if ( pParentDirEntry != NULL)
+ {
+
+ lCount = InterlockedDecrement( &pParentDirEntry->DirOpenReferenceCount);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSGetObjectStatus Decrement2 count on %wZ DE %p Ccb %p Cnt %d\n",
+ &pParentDirEntry->NameInformation.FileName,
+ pParentDirEntry,
+ NULL,
+ lCount);
+
+ ASSERT( lCount >= 0);
+ }
+
if( pObjectInfo != NULL)
{