From 749cb03e3c4b95c19803fc718d59ba79e8f8292f Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Thu, 19 Apr 2012 07:14:16 -0400 Subject: [PATCH] Windows: Add global root to name array if share name If the share name was resolved by querying the service instead of finding the entry in the root.afs root directory, construct a name array in AFSParseName() that includes the AFSGlobalRoot above the resolved share root directory. In AFSBackupEntry, check for the case where two volume root entries appear in sequence without an intervening mount point. Change-Id: Ied0e0dc8226b0460d85a1f3a8b389294cfdef34b Reviewed-on: http://gerrit.openafs.org/7252 Tested-by: BuildBot Tested-by: Jeffrey Altman Reviewed-by: Jeffrey Altman --- src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp | 22 +++--- .../afsrdr/kernel/lib/AFSNameSupport.cpp | 67 ++++++++++++++----- 2 files changed, 64 insertions(+), 25 deletions(-) diff --git a/src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp b/src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp index d38387c5a..7e1e96faf 100644 --- a/src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp +++ b/src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp @@ -5403,19 +5403,25 @@ AFSBackupEntry( IN AFSNameArrayHdr *NameArray) pCurrentElement->FileId.Unique, &pCurrentElement->DirectoryCB->NameInformation.FileName, pCurrentElement->DirectoryCB->ObjectInformation->FileType); - } - // - // If the entry we are removing is a volume root, - // we must remove the mount point entry as well. - // + // + // If the entry we are removing is a volume root, + // we must remove the mount point entry as well. + // If the NameArray was constructed by checking the + // share name via the service, the name array can + // contain two volume roots in sequence without a + // mount point separating them. + // - if ( bVolumeRoot) - { + if ( bVolumeRoot && + !BooleanFlagOn( NameArray->CurrentEntry->Flags, AFS_NAME_ARRAY_FLAG_ROOT_ELEMENT)) + { - pDirectoryCB = AFSBackupEntry( NameArray); + 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 1610e913b..743c3c560 100644 --- a/src/WINNT/afsrdr/kernel/lib/AFSNameSupport.cpp +++ b/src/WINNT/afsrdr/kernel/lib/AFSNameSupport.cpp @@ -3543,6 +3543,7 @@ AFSParseName( IN PIRP Irp, AFSReleaseResource( AFSGlobalRoot->ObjectInformation.Specific.Directory.DirectoryNodeHdr.TreeLock); } + // // Be sure we are starting from the correct volume // @@ -3557,6 +3558,38 @@ AFSParseName( IN PIRP Irp, pVolumeCB = pDirEntry->ObjectInformation->VolumeCB; + // + // Init our name array + // + + pNameArray = AFSInitNameArray( AFSGlobalRoot->DirectoryCB, + 0); + + if( pNameArray == NULL) + { + + AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING, + AFS_TRACE_LEVEL_VERBOSE, + "AFSParseName (%08lX) Failed to initialize name array\n", + Irp); + + try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES); + } + + ntStatus = AFSInsertNextElement( pNameArray, + pVolumeCB->DirectoryCB); + + if ( ntStatus) + { + + AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING, + AFS_TRACE_LEVEL_VERBOSE, + "AFSParseName (%08lX) Failed to insert name array element\n", + Irp); + + try_return( ntStatus); + } + // // In this case don't add back in the 'share' name since that is where we are // starting. Just put the leading slash back in @@ -3606,6 +3639,23 @@ AFSParseName( IN PIRP Irp, pVolumeCB = AFSGlobalRoot; + // + // Init our name array + // + + pNameArray = AFSInitNameArray( AFSGlobalRoot->DirectoryCB, + 0); + if( pNameArray == NULL) + { + + AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING, + AFS_TRACE_LEVEL_VERBOSE, + "AFSParseName (%08lX) Failed to initialize name array\n", + Irp); + + try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES); + } + // // Add back in the 'share' portion of the name since we will parse it out on return // @@ -3664,24 +3714,7 @@ AFSParseName( IN PIRP Irp, // *ParentDirectoryCB = pVolumeCB->DirectoryCB; - } - - // - // Init our name array - // - - pNameArray = AFSInitNameArray( pVolumeCB->DirectoryCB, - 0); - - if( pNameArray == NULL) - { - - AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING, - AFS_TRACE_LEVEL_VERBOSE, - "AFSParseName (%08lX) Failed to initialize name array\n", - Irp); - try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES); } // -- 2.39.5