AFSVolumeCB *pNewVolumeCB = NULL;
LONG NewVolumeReferenceReason = AFS_VOLUME_REFERENCE_INVALID;
AFSDirectoryCB *pParentDirectoryCB = NULL, *pDirectoryCB = NULL;
+ AFSDirectoryCB *pNewParentDirectoryCB = NULL;
BOOLEAN bReleaseParentDir = FALSE, bReleaseDir = FALSE;
ULONG ulParseFlags = 0;
GUID stAuthGroup = {0};
pParentDirectoryCB,
&pNewVolumeCB,
&NewVolumeReferenceReason,
- &pParentDirectoryCB,
+ &pNewParentDirectoryCB,
&pDirectoryCB,
&uniComponentName);
bReleaseVolume = (pVolumeCB != NULL);
+ //
+ // AFSLocateNameEntry does not alter the reference count of
+ // pParentDirectoryCB and it returns pNewParentDirectoryCB with
+ // a reference held.
+ //
+
+ if ( bReleaseParentDir)
+ {
+
+ lCount = InterlockedDecrement( &pParentDirectoryCB->DirOpenReferenceCount);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSCommonCreate DecrementX count on %wZ DE %p Ccb %p Cnt %d\n",
+ &pParentDirectoryCB->NameInformation.FileName,
+ pParentDirectoryCB,
+ pCcb,
+ lCount);
+ }
+
+ pParentDirectoryCB = pNewParentDirectoryCB;
+
+ pNewParentDirectoryCB = NULL;
+
+ bReleaseParentDir = (pParentDirectoryCB != NULL);
+
+ if ( pDirectoryCB)
+ {
+
+ bReleaseDir = TRUE;
+ }
+
if( !NT_SUCCESS( ntStatus) &&
ntStatus != STATUS_OBJECT_NAME_NOT_FOUND)
{
&uniFileName,
ntStatus);
- bReleaseParentDir = FALSE;
-
try_return( ntStatus);
}
Irp->IoStatus.Information = IO_REPARSE;
- bReleaseParentDir = FALSE;
-
try_return( ntStatus);
}
try_return( ntStatus);
}
}
- else
- {
-
- //
- // AFSLocateNameEntry succeeded. The parent directory reference
- // has been released and if there is a directory returned, it is
- // referenced.
- //
-
- bReleaseParentDir = FALSE;
-
- if ( pDirectoryCB)
- {
-
- bReleaseDir = TRUE;
- }
- }
}
//
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)
{
// will be assigned the new current volume with a held ReferenceCount.
//
// On entry, *ParentDirectoryCB must have a held DirOpenReferenceCount
-// provided by the caller.
+// provided by the caller. This reference will not be released.
+// On exit, if OutParentDirectoryCB is set, it will have a new reference.
+//
+// On exit, if OutDirectoryCB is set, it will have a reference.
//
NTSTATUS
UNICODE_STRING uniPathName, uniComponentName, uniRemainingPath, uniSearchName, uniFullPathName;
ULONG ulCRC = 0;
AFSDirectoryCB *pDirEntry = NULL, *pParentDirEntry = NULL;
- AFSDeviceExt *pDevExt = (AFSDeviceExt *) AFSRDRDeviceObject->DeviceExtension;
+ AFSDeviceExt *pDevExt = (AFSDeviceExt *) AFSRDRDeviceObject->DeviceExtension;
UNICODE_STRING uniSysName;
ULONG ulSubstituteIndex = 0;
BOOLEAN bSubstituteName = FALSE;
pDirEntry = ParentDirectoryCB;
+ //
+ // Increment our reference on this dir entry
+ //
+
+ lCount = InterlockedIncrement( &pDirEntry->DirOpenReferenceCount);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSLocateNameEntry Increment1 count on %wZ DE %p Ccb %p Cnt %d\n",
+ &pDirEntry->NameInformation.FileName,
+ pDirEntry,
+ NULL,
+ lCount);
+
pCurrentVolume = VolumeCB;
VolumeReferenceReason = AFS_VOLUME_REFERENCE_LOCATE_NAME;
*OutParentDirectoryCB = pParentDirEntry;
+ pParentDirEntry = NULL;
+
*OutDirectoryCB = pDirEntry;
+ pDirEntry = NULL;
+
*OutVolumeCB = pCurrentVolume;
*OutVolumeReferenceReason = VolumeReferenceReason;
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSLocateNameEntry Increment1 count on %wZ DE %p Ccb %p Cnt %d\n",
+ "AFSLocateNameEntry Increment2 count on %wZ DE %p Ccb %p Cnt %d\n",
&pDirEntry->NameInformation.FileName,
pDirEntry,
NULL,
lCount);
- if( BooleanFlagOn( pDirEntry->ObjectInformation->Flags, AFS_OBJECT_ROOT_VOLUME))
+ if ( pParentDirEntry)
{
+ lCount = InterlockedDecrement( &pParentDirEntry->DirOpenReferenceCount);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSLocateNameEntry Decrement count on %wZ DE %p Ccb %p Cnt %d\n",
+ &pParentDirEntry->NameInformation.FileName,
+ pParentDirEntry,
+ NULL,
+ lCount);
+
pParentDirEntry = NULL;
}
- else
+
+ if( !BooleanFlagOn( pDirEntry->ObjectInformation->Flags, AFS_OBJECT_ROOT_VOLUME))
{
pParentDirEntry = AFSGetParentEntry( pNameArray);
ASSERT( pParentDirEntry != pDirEntry);
+
+ lCount = InterlockedIncrement( &pParentDirEntry->DirOpenReferenceCount);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSLocateNameEntry Increment count on %wZ DE %p Ccb %p Cnt %d\n",
+ &pParentDirEntry->NameInformation.FileName,
+ pParentDirEntry,
+ NULL,
+ lCount);
}
}
else
pNameArray->LinkCount = lLinkCount;
- pParentDirEntry = NULL;
+ if ( pParentDirEntry)
+ {
+
+ lCount = InterlockedDecrement( &pParentDirEntry->DirOpenReferenceCount);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSLocateNameEntry Decrement count on %wZ DE %p Ccb %p Cnt %d\n",
+ &pParentDirEntry->NameInformation.FileName,
+ pParentDirEntry,
+ NULL,
+ lCount);
+
+ pParentDirEntry = NULL;
+ }
}
//
*OutParentDirectoryCB = pParentDirEntry;
+ pParentDirEntry = NULL;
+
*OutDirectoryCB = pDirEntry;
+ pDirEntry = NULL;
+
*OutVolumeCB = pCurrentVolume;
*OutVolumeReferenceReason = VolumeReferenceReason;
AFSInsertNextElement( pNameArray,
pDirEntry);
- pParentDirEntry = NULL;
+ if ( pParentDirEntry)
+ {
+
+ lCount = InterlockedDecrement( &pParentDirEntry->DirOpenReferenceCount);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSLocateNameEntry Decrement count on %wZ DE %p Ccb %p Cnt %d\n",
+ &pParentDirEntry->NameInformation.FileName,
+ pParentDirEntry,
+ NULL,
+ lCount);
+
+ pParentDirEntry = NULL;
+ }
//
// Increment our link count
*OutParentDirectoryCB = pParentDirEntry;
+ pParentDirEntry = NULL;
+
*OutDirectoryCB = pDirEntry;
+ pDirEntry = NULL;
+
*OutVolumeCB = pCurrentVolume;
*OutVolumeReferenceReason = VolumeReferenceReason;
*OutParentDirectoryCB = pParentDirEntry;
+ pParentDirEntry = NULL;
+
*OutDirectoryCB = pDirEntry;
+ pDirEntry = NULL;
+
*OutVolumeCB = pCurrentVolume;
*OutVolumeReferenceReason = VolumeReferenceReason;
*OutParentDirectoryCB = pParentDirEntry;
+ pParentDirEntry = NULL;
+
*OutDirectoryCB = pDirEntry;
+ pDirEntry = NULL;
+
*OutVolumeCB = pCurrentVolume;
*OutVolumeReferenceReason = VolumeReferenceReason;
NULL,
lCount);
- if( BooleanFlagOn( pDirEntry->ObjectInformation->Flags, AFS_OBJECT_ROOT_VOLUME))
+ if ( pParentDirEntry)
{
+ lCount = InterlockedDecrement( &pParentDirEntry->DirOpenReferenceCount);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSLocateNameEntry Decrement count on %wZ DE %p Ccb %p Cnt %d\n",
+ &pParentDirEntry->NameInformation.FileName,
+ pParentDirEntry,
+ NULL,
+ lCount);
+
pParentDirEntry = NULL;
}
- else
+
+ if( !BooleanFlagOn( pDirEntry->ObjectInformation->Flags, AFS_OBJECT_ROOT_VOLUME))
{
pParentDirEntry = AFSGetParentEntry( pNameArray);
ASSERT( pParentDirEntry != pDirEntry);
+
+ if ( pParentDirEntry)
+ {
+
+ lCount = InterlockedIncrement( &pParentDirEntry->DirOpenReferenceCount);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSLocateNameEntry Increment count on %wZ DE %p Ccb %p Cnt %d\n",
+ &pParentDirEntry->NameInformation.FileName,
+ pParentDirEntry,
+ NULL,
+ lCount);
+ }
}
uniPathName = uniRemainingPath;
// Update our pointers
//
+ if ( pParentDirEntry)
+ {
+
+ lCount = InterlockedDecrement( &pParentDirEntry->DirOpenReferenceCount);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSLocateNameEntry Decrement count on %wZ DE %p Ccb %p Cnt %d\n",
+ &pParentDirEntry->NameInformation.FileName,
+ pParentDirEntry,
+ NULL,
+ lCount);
+ }
+
pParentDirEntry = pDirEntry;
pDirEntry = NULL;
*OutParentDirectoryCB = pParentDirEntry;
+ pParentDirEntry = NULL;
+
*OutDirectoryCB = NULL;
*OutVolumeCB = pCurrentVolume;
continue; // while( pDirEntry == NULL)
}
+ //
+ // Node name not found so get out
+ //
+
+ AFSReleaseResource( pParentDirEntry->ObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock);
+
if( uniRemainingPath.Length > 0)
{
*OutParentDirectoryCB = pParentDirEntry;
+ pParentDirEntry = NULL;
+
*OutDirectoryCB = NULL;
*OutVolumeCB = pCurrentVolume;
*RootPathName = uniFullPathName;
}
- AFSReleaseResource( pParentDirEntry->ObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock);
-
- //
- // Node name not found so get out
- //
-
- try_return( ntStatus); // while( pDirEntry == NULL)
+ try_return( ntStatus);
}
}
else
ASSERT( lCount >= 0);
- if( lCount <= 0)
+ if( lCount == 0)
{
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING|AFS_SUBSYSTEM_CLEANUP_PROCESSING,
*OutParentDirectoryCB = pParentDirEntry;
+ pParentDirEntry = NULL;
+
*OutDirectoryCB = NULL;
*OutVolumeCB = pCurrentVolume;
}
//
- // Decrement the previous parent
- //
-
- lCount = InterlockedDecrement( &pParentDirEntry->DirOpenReferenceCount);
-
- AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSLocateNameEntry Decrement5 count on Parent %wZ DE %p Ccb %p Cnt %d\n",
- &pParentDirEntry->NameInformation.FileName,
- pParentDirEntry,
- NULL,
- lCount);
-
- ASSERT( lCount >= 0);
-
- //
// If we ended up substituting a name in the component then update
// the full path and update the pointers
//
&uniSearchName,
&uniRemainingPath,
bRelativeOpen ||
- bAllocatedSymLinkBuffer ||
- bSubstitutedName);
+ bAllocatedSymLinkBuffer ||
+ bSubstitutedName);
if( !NT_SUCCESS( ntStatus))
{
ntStatus != STATUS_OBJECT_NAME_NOT_FOUND) ||
ntStatus == STATUS_REPARSE)
{
-
- if( pDirEntry != NULL)
- {
-
- lCount = InterlockedDecrement( &pDirEntry->DirOpenReferenceCount);
-
- AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSLocateNameEntry Decrement6 count on %wZ DE %p Ccb %p Cnt %d\n",
- &pDirEntry->NameInformation.FileName,
- pDirEntry,
- NULL,
- lCount);
-
- ASSERT( lCount >= 0);
- }
- else if( pParentDirEntry != NULL)
- {
-
- lCount = InterlockedDecrement( &pParentDirEntry->DirOpenReferenceCount);
-
- AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSLocateNameEntry Decrement7 count on %wZ DE %p Ccb %p Cnt %d\n",
- &pParentDirEntry->NameInformation.FileName,
- pParentDirEntry,
- NULL,
- lCount);
-
- ASSERT( lCount >= 0);
- }
-
if( RootPathName->Buffer != uniFullPathName.Buffer)
{
}
}
+ if( pDirEntry != NULL)
+ {
+
+ lCount = InterlockedDecrement( &pDirEntry->DirOpenReferenceCount);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSLocateNameEntry Decrement6 count on %wZ DE %p Ccb %p Cnt %d\n",
+ &pDirEntry->NameInformation.FileName,
+ pDirEntry,
+ NULL,
+ lCount);
+
+ ASSERT( lCount >= 0);
+ }
+
+ if( pParentDirEntry != NULL)
+ {
+
+ lCount = InterlockedDecrement( &pParentDirEntry->DirOpenReferenceCount);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSLocateNameEntry Decrement7 count on %wZ DE %p Ccb %p Cnt %d\n",
+ &pParentDirEntry->NameInformation.FileName,
+ pParentDirEntry,
+ NULL,
+ lCount);
+
+ ASSERT( lCount >= 0);
+ }
+
if( bReleaseCurrentVolume)
{