From 3db44bacd4b3ac3b9ed63bcf671b03f7f7eeb8af Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Mon, 2 Apr 2012 18:10:07 -0400 Subject: [PATCH] Windows: Name Array store mount point and volume root Modify the Name Array processing to store both the mount point object and the volume root directory object in the array. This is necessary for proper operation of AFSPopulateNameArrayFromRelatedArray when the DirectoryCB parameter is a mount point object. Modify AFSBackupEntry to remove two entries if a volume root directory entry is being removed. Remove AFSReplaceCurrentElement() as it is no longer used. Change-Id: Iaa0a4effc3448351d04bcdd72be9ee726ffe4e9a Reviewed-on: http://gerrit.openafs.org/7021 Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp | 86 ++++--------------- .../afsrdr/kernel/lib/AFSNameSupport.cpp | 7 +- .../afsrdr/kernel/lib/Include/AFSCommon.h | 4 - 3 files changed, 19 insertions(+), 78 deletions(-) diff --git a/src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp b/src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp index 5179da0a2..add53f144 100644 --- a/src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp +++ b/src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp @@ -5346,83 +5346,13 @@ try_exit: return ntStatus; } -void -AFSReplaceCurrentElement( IN AFSNameArrayHdr *NameArray, - IN AFSDirectoryCB *DirectoryCB) -{ - AFSNameArrayCB *pCurrentElement = NULL; - LONG lCount; - - AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_PROCESSING, - AFS_TRACE_LEVEL_VERBOSE, - "AFSReplaceCurrentElement [NA:%p] passed DE %p FID %08lX-%08lX-%08lX-%08lX %wZ Type %d\n", - NameArray, - DirectoryCB, - DirectoryCB->ObjectInformation->FileId.Cell, - DirectoryCB->ObjectInformation->FileId.Volume, - DirectoryCB->ObjectInformation->FileId.Vnode, - DirectoryCB->ObjectInformation->FileId.Unique, - &DirectoryCB->NameInformation.FileName, - DirectoryCB->ObjectInformation->FileType); - - ASSERT( NameArray->CurrentEntry != NULL); - - pCurrentElement = NameArray->CurrentEntry; - - AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_PROCESSING, - AFS_TRACE_LEVEL_VERBOSE, - "AFSReplaceCurrentElement [NA:%p] Replacing Element[%d] DE %p FID %08lX-%08lX-%08lX-%08lX %wZ Type %d\n", - NameArray, - NameArray->Count - 1, - pCurrentElement->DirectoryCB, - pCurrentElement->FileId.Cell, - pCurrentElement->FileId.Volume, - pCurrentElement->FileId.Vnode, - pCurrentElement->FileId.Unique, - &pCurrentElement->DirectoryCB->NameInformation.FileName, - pCurrentElement->DirectoryCB->ObjectInformation->FileType); - - lCount = InterlockedDecrement( &NameArray->CurrentEntry->DirectoryCB->OpenReferenceCount); - - AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING, - AFS_TRACE_LEVEL_VERBOSE, - "AFSReplaceCurrentElement Decrement count on %wZ DE %p Cnt %d\n", - &pCurrentElement->DirectoryCB->NameInformation.FileName, - pCurrentElement->DirectoryCB, - lCount); - - lCount = InterlockedIncrement( &DirectoryCB->OpenReferenceCount); - - AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING, - AFS_TRACE_LEVEL_VERBOSE, - "AFSReplaceCurrentElement Increment count on %wZ DE %p Cnt %d\n", - &DirectoryCB->NameInformation.FileName, - DirectoryCB, - lCount); - - pCurrentElement->DirectoryCB = DirectoryCB; - - pCurrentElement->Component = DirectoryCB->NameInformation.FileName; - - pCurrentElement->FileId = DirectoryCB->ObjectInformation->FileId; - - pCurrentElement->Flags = 0; - - if( pCurrentElement->FileId.Vnode == 1) - { - - SetFlag( pCurrentElement->Flags, AFS_NAME_ARRAY_FLAG_ROOT_ELEMENT); - } - - return; -} - AFSDirectoryCB * AFSBackupEntry( IN AFSNameArrayHdr *NameArray) { AFSDirectoryCB *pDirectoryCB = NULL; AFSNameArrayCB *pCurrentElement = NULL; + BOOLEAN bVolumeRoot = FALSE; LONG lCount; __Enter @@ -5468,6 +5398,9 @@ AFSBackupEntry( IN AFSNameArrayHdr *NameArray) } else { + + bVolumeRoot = BooleanFlagOn( NameArray->CurrentEntry->Flags, AFS_NAME_ARRAY_FLAG_ROOT_ELEMENT); + NameArray->CurrentEntry--; pCurrentElement = NameArray->CurrentEntry; @@ -5488,6 +5421,17 @@ AFSBackupEntry( IN AFSNameArrayHdr *NameArray) pCurrentElement->DirectoryCB->ObjectInformation->FileType); } + // + // If the entry we are removing is a volume root, + // we must remove the mount point entry as well. + // + + if ( bVolumeRoot) + { + + pDirectoryCB = AFSBackupEntry( NameArray); + } + try_exit: NOTHING; diff --git a/src/WINNT/afsrdr/kernel/lib/AFSNameSupport.cpp b/src/WINNT/afsrdr/kernel/lib/AFSNameSupport.cpp index 40da6eea2..18a291d5f 100644 --- a/src/WINNT/afsrdr/kernel/lib/AFSNameSupport.cpp +++ b/src/WINNT/afsrdr/kernel/lib/AFSNameSupport.cpp @@ -915,11 +915,12 @@ AFSLocateNameEntry( IN GUID *AuthGroup, ASSERT( pCurrentVolume->VolumeReferenceCount > 1); // - // Replace the current name for the mp with the volume root of the target + // The name array stores both the mount point and the target. + // Insert the target. // - AFSReplaceCurrentElement( pNameArray, - pCurrentVolume->DirectoryCB); + AFSInsertNextElement( pNameArray, + pCurrentVolume->DirectoryCB); // // We want to restart processing here on the new parent ... diff --git a/src/WINNT/afsrdr/kernel/lib/Include/AFSCommon.h b/src/WINNT/afsrdr/kernel/lib/Include/AFSCommon.h index 003b3a711..ab3eb8e7f 100644 --- a/src/WINNT/afsrdr/kernel/lib/Include/AFSCommon.h +++ b/src/WINNT/afsrdr/kernel/lib/Include/AFSCommon.h @@ -1253,10 +1253,6 @@ NTSTATUS AFSInsertNextElement( IN AFSNameArrayHdr *NameArray, IN AFSDirectoryCB *DirEntry); -void -AFSReplaceCurrentElement( IN AFSNameArrayHdr *NameArray, - IN AFSDirectoryCB *DirectoryCB); - AFSDirectoryCB * AFSBackupEntry( IN AFSNameArrayHdr *NameArray); -- 2.39.5