BOOLEAN bAllocatedSymLinkBuffer = FALSE;
UNICODE_STRING uniRelativeName, uniNoOpName;
AFSObjectInfoCB *pCurrentObject = NULL;
+ AFSObjectInfoCB *pParentObjectInfo = NULL;
AFSVolumeCB *pCurrentVolume = *VolumeCB;
BOOLEAN bReleaseCurrentVolume = TRUE;
BOOLEAN bSubstitutedName = FALSE;
if( !NT_SUCCESS( ntStatus))
{
- AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
- AFS_TRACE_LEVEL_ERROR,
- "AFSLocateNameEntry (FO: %08lX) Failed to evaluate parent %wZ FID %08lX-%08lX-%08lX-%08lX Status %08lX\n",
- FileObject,
- &pDirEntry->NameInformation.FileName,
- pCurrentObject->FileId.Cell,
- pCurrentObject->FileId.Volume,
- pCurrentObject->FileId.Vnode,
- pCurrentObject->FileId.Unique,
- ntStatus);
+ if ( ntStatus == STATUS_NOT_A_DIRECTORY)
+ {
+
+ if ( pCurrentObject->ParentObjectInformation == NULL)
+ {
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_ERROR,
+ "AFSLocateNameEntry (FO: %08lX) Failed to evaluate object %wZ FID %08lX-%08lX-%08lX-%08lX PARENT NULL Status %08lX\n",
+ FileObject,
+ &pDirEntry->NameInformation.FileName,
+ pCurrentObject->FileId.Cell,
+ pCurrentObject->FileId.Volume,
+ pCurrentObject->FileId.Vnode,
+ pCurrentObject->FileId.Unique,
+ ntStatus);
+ }
+ else
+ {
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_ERROR,
+ "AFSLocateNameEntry (FO: %08lX) Failed to evaluate object %wZ FID %08lX-%08lX-%08lX-%08lX PARENT %08lX-%08lX-%08lX-%08lX Status %08lX\n",
+ FileObject,
+ &pDirEntry->NameInformation.FileName,
+ pCurrentObject->FileId.Cell,
+ pCurrentObject->FileId.Volume,
+ pCurrentObject->FileId.Vnode,
+ pCurrentObject->FileId.Unique,
+ pCurrentObject->ParentObjectInformation->FileId.Cell,
+ pCurrentObject->ParentObjectInformation->FileId.Volume,
+ pCurrentObject->ParentObjectInformation->FileId.Vnode,
+ pCurrentObject->ParentObjectInformation->FileId.Unique,
+ ntStatus);
+ }
+ }
+ else
+ {
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_ERROR,
+ "AFSLocateNameEntry (FO: %08lX) Failed to evaluate parent %wZ FID %08lX-%08lX-%08lX-%08lX Status %08lX\n",
+ FileObject,
+ &pDirEntry->NameInformation.FileName,
+ pCurrentObject->FileId.Cell,
+ pCurrentObject->FileId.Volume,
+ pCurrentObject->FileId.Vnode,
+ pCurrentObject->FileId.Unique,
+ ntStatus);
+ }
try_return( ntStatus);
}
try_return( ntStatus);
}
+ AFSAcquireExcl( pCurrentObject->Specific.Directory.DirectoryNodeHdr.TreeLock,
+ TRUE);
+
AFSAcquireExcl( &pDirEntry->NonPaged->Lock,
TRUE);
// Directory TreeLock should be exclusively held
//
- AFSAcquireExcl( pCurrentObject->Specific.Directory.DirectoryNodeHdr.TreeLock,
- TRUE);
-
ntStatus = AFSVerifyEntry( AuthGroup,
pDirEntry);
continue;
}
}
+ else
+ {
+
+ AFSReleaseResource( pCurrentObject->Specific.Directory.DirectoryNodeHdr.TreeLock);
+ }
//
// If we were given a zero length target name then deny access to the entry
if( pTmpBuffer != NULL)
{
- AFSExFreePool( pTmpBuffer);
+ AFSExFreePoolWithTag( pTmpBuffer, 0);
}
AFSReleaseResource( &pDirEntry->NonPaged->Lock);
if( pTmpBuffer != NULL)
{
- AFSExFreePool( pTmpBuffer);
+ AFSExFreePoolWithTag( pTmpBuffer, 0);
}
AFSReleaseResource( &pDirEntry->NonPaged->Lock);
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 ...
uniSearchName.Buffer != NULL)
{
- AFSExFreePool( uniSearchName.Buffer);
+ AFSExFreePoolWithTag( uniSearchName.Buffer, 0);
bSubstituteName = FALSE;
// a lookup in the short name tree
//
- if( RtlIsNameLegalDOS8Dot3( &uniSearchName,
+ if( !BooleanFlagOn( pDevExt->DeviceFlags, AFS_DEVICE_FLAG_DISABLE_SHORTNAMES) &&
+ RtlIsNameLegalDOS8Dot3( &uniSearchName,
NULL,
NULL))
{
if( bSubstituteName)
{
- AFSExFreePool( uniSearchName.Buffer);
+ AFSExFreePoolWithTag( uniSearchName.Buffer, 0);
uniSearchName = uniComponentName;
// on the entry
//
- ASSERT( pCurrentObject->ParentObjectInformation != NULL);
+ pParentObjectInfo = pCurrentObject->ParentObjectInformation;
+
+ ASSERT( pParentObjectInfo != NULL);
- AFSAcquireExcl( pCurrentObject->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock,
+ AFSAcquireExcl( pParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock,
TRUE);
AFSAcquireExcl( pCurrentObject->VolumeCB->ObjectInfoTree.TreeLock,
// Remove and delete the directory entry from the parent list
//
- AFSDeleteDirEntry( pCurrentObject->ParentObjectInformation,
+ AFSDeleteDirEntry( pParentObjectInfo,
pDirEntry);
- if( pCurrentObject->ObjectReferenceCount == 0)
+ AFSAcquireShared( &pCurrentObject->NonPagedInfo->ObjectInfoLock,
+ TRUE);
+
+ if( pCurrentObject->ObjectReferenceCount <= 0)
{
if( BooleanFlagOn( pCurrentObject->Flags, AFS_OBJECT_INSERTED_HASH_TREE))
ClearFlag( pCurrentObject->Flags, AFS_OBJECT_INSERTED_HASH_TREE);
}
}
+
+ AFSReleaseResource( &pCurrentObject->NonPagedInfo->ObjectInfoLock);
}
else
{
SetFlag( pDirEntry->Flags, AFS_DIR_ENTRY_DELETED);
- AFSRemoveNameEntry( pCurrentObject->ParentObjectInformation,
+ AFSRemoveNameEntry( pParentObjectInfo,
pDirEntry);
}
- AFSReleaseResource( pCurrentObject->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock);
+ AFSReleaseResource( pParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock);
AFSReleaseResource( pCurrentObject->VolumeCB->ObjectInfoTree.TreeLock);
if( RootPathName->Buffer != uniFullPathName.Buffer)
{
- AFSExFreePool( uniFullPathName.Buffer);
+ AFSExFreePoolWithTag( uniFullPathName.Buffer, 0);
}
}
else
uniSearchName.Buffer != NULL)
{
- AFSExFreePool( uniSearchName.Buffer);
+ AFSExFreePoolWithTag( uniSearchName.Buffer, 0);
}
}
if( BooleanFlagOn( DirEntry->Flags, AFS_DIR_RELEASE_NAME_BUFFER))
{
- AFSExFreePool( DirEntry->NameInformation.FileName.Buffer);
+ AFSExFreePoolWithTag( DirEntry->NameInformation.FileName.Buffer, 0);
}
if( BooleanFlagOn( DirEntry->Flags, AFS_DIR_RELEASE_TARGET_NAME_BUFFER))
{
- AFSExFreePool( DirEntry->NameInformation.TargetName.Buffer);
+ AFSExFreePoolWithTag( DirEntry->NameInformation.TargetName.Buffer, 0);
}
//
ASSERT( DirEntry->ObjectInformation->ObjectReferenceCount > 0);
- lCount = InterlockedDecrement( &DirEntry->ObjectInformation->ObjectReferenceCount);
-
- if( lCount == 0)
- {
- SetFlag( DirEntry->ObjectInformation->Flags, AFS_OBJECT_FLAGS_DELETED);
- }
+ lCount = AFSObjectInfoDecrement( DirEntry->ObjectInformation);
AFSDbgLogMsg( AFS_SUBSYSTEM_OBJECT_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSDeleteDirEntry Decrement count on object %08lX Cnt %d\n",
DirEntry->ObjectInformation,
- DirEntry->ObjectInformation->ObjectReferenceCount);
+ lCount);
+
+ if( BooleanFlagOn( DirEntry->Flags, AFS_DIR_ENTRY_DELETED))
+ {
+
+ SetFlag( DirEntry->ObjectInformation->Flags, AFS_OBJECT_FLAGS_DELETED);
+ }
ExDeleteResourceLite( &DirEntry->NonPaged->Lock);
- AFSExFreePool( DirEntry->NonPaged);
+ AFSExFreePoolWithTag( DirEntry->NonPaged, AFS_DIR_ENTRY_NP_TAG);
//
// Free up the dir entry
//
- AFSExFreePool( DirEntry);
+ AFSExFreePoolWithTag( DirEntry, AFS_DIR_ENTRY_TAG);
}
return ntStatus;
"AFSParseName (%08lX) Failed to initialize name array\n",
Irp);
- AFSExFreePool( uniFullName.Buffer);
+ AFSExFreePoolWithTag( uniFullName.Buffer, 0);
try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES);
}
"AFSParseName (%08lX) Failed to initialize name array\n",
Irp);
- AFSExFreePool( uniFullName.Buffer);
+ AFSExFreePoolWithTag( uniFullName.Buffer, 0);
try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES);
}
"AFSParseName (%08lX) Failed to populate name array\n",
Irp);
- AFSExFreePool( uniFullName.Buffer);
+ AFSExFreePoolWithTag( uniFullName.Buffer, 0);
try_return( ntStatus);
}
// a lookup in the short name tree
//
- if( RtlIsNameLegalDOS8Dot3( &uniComponentName,
+ if( !BooleanFlagOn( pDeviceExt->DeviceFlags, AFS_DEVICE_FLAG_DISABLE_SHORTNAMES) &&
+ RtlIsNameLegalDOS8Dot3( &uniComponentName,
NULL,
NULL))
{
AFSReleaseResource( AFSGlobalRoot->ObjectInformation.Specific.Directory.DirectoryNodeHdr.TreeLock);
}
+
//
// Be sure we are starting from the correct volume
//
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
//
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
//
//
*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);
}
//
if( !NT_SUCCESS( ntStatus))
{
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_WARNING,
+ "AFSCheckCellName entry %wZ does not exist parent FID %08lX-%08lX-%08lX-%08lX Status %08lX\n",
+ CellName,
+ AFSGlobalRoot->ObjectInformation.FileId.Cell,
+ AFSGlobalRoot->ObjectInformation.FileId.Volume,
+ AFSGlobalRoot->ObjectInformation.FileId.Vnode,
+ AFSGlobalRoot->ObjectInformation.FileId.Unique,
+ ntStatus);
+
try_return( ntStatus);
}
if( pDirEnumEntry != NULL)
{
- AFSExFreePool( pDirEnumEntry);
+ AFSExFreePoolWithTag( pDirEnumEntry, AFS_GENERIC_MEMORY_31_TAG);
}
}
AFSVolumeCB *pVolumeCB = NULL;
AFSFileID stTargetFileID;
LONG lCount;
+ BOOLEAN bReleaseVolumeLock = FALSE;
__Enter
{
try_return( ntStatus);
}
- }
- else
- {
//
- // Check if this volume has been deleted or taken offline
+ // pVolumeCB->VolumeLock held exclusive and
+ // pVolumeCB->VolumeReferenceCount has been incremented
+ // pVolumeCB->RootFcb == NULL
//
- if( BooleanFlagOn( pVolumeCB->Flags, AFS_VOLUME_FLAGS_OFFLINE))
- {
-
- AFSReleaseResource( &pDevExt->Specific.RDR.VolumeTreeLock);
-
- try_return( ntStatus = STATUS_FILE_IS_OFFLINE);
- }
+ bReleaseVolumeLock = TRUE;
+ }
+ else
+ {
//
- // Just to ensure that things don't get torn down AND we don't create a
- // deadlock with invalidation
+ // AFSInitVolume returns with a VolumeReferenceCount
+ // obtain one to match
//
lCount = InterlockedIncrement( &pVolumeCB->VolumeReferenceCount);
- AFSReleaseResource( &pDevExt->Specific.RDR.VolumeTreeLock);
-
- AFSAcquireExcl( pVolumeCB->VolumeLock,
- TRUE);
+ AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSBuildMountPointTarget Increment count on volume %08lX Cnt %d\n",
+ pVolumeCB,
+ lCount);
- lCount = InterlockedDecrement( &pVolumeCB->VolumeReferenceCount);
+ AFSReleaseResource( &pDevExt->Specific.RDR.VolumeTreeLock);
}
if( pVolumeCB->RootFcb == NULL)
{
+ if ( bReleaseVolumeLock == FALSE)
+ {
+
+ AFSAcquireExcl( pVolumeCB->VolumeLock,
+ TRUE);
+
+ bReleaseVolumeLock = TRUE;
+ }
+
//
// Initialize the root fcb for this volume
//
if( !NT_SUCCESS( ntStatus))
{
+ lCount = InterlockedDecrement( &pVolumeCB->VolumeReferenceCount);
+
AFSReleaseResource( pVolumeCB->VolumeLock);
try_return( ntStatus);
AFSReleaseResource( &pVolumeCB->RootFcb->NPFcb->Resource);
}
+ if ( bReleaseVolumeLock == TRUE)
+ {
+
+ AFSReleaseResource( pVolumeCB->VolumeLock);
+ }
+
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE_2,
"AFSBuildMountPointTarget Evaluated target of %wZ FID %08lX-%08lX-%08lX-%08lX as root volume\n",
pVolumeCB->ObjectInformation.FileId.Vnode,
pVolumeCB->ObjectInformation.FileId.Unique);
- lCount = InterlockedIncrement( &pVolumeCB->VolumeReferenceCount);
-
- AFSReleaseResource( pVolumeCB->VolumeLock);
-
- AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSBuildMountPointTarget Increment count on volume %08lX Cnt %d\n",
- pVolumeCB,
- lCount);
-
*TargetVolumeCB = pVolumeCB;
try_exit:
if( pDirEntry)
{
- AFSExFreePool( pDirEntry);
+ AFSExFreePoolWithTag( pDirEntry, AFS_GENERIC_MEMORY_2_TAG);
}
}
ULONGLONG ullIndex = 0;
AFSVolumeCB *pVolumeCB = NULL;
LONG lCount;
+ BOOLEAN bReleaseVolumeLock = FALSE;
__Enter
{
try_return( ntStatus);
}
+
+ //
+ // pVolumeCB->VolumeLock is held exclusive
+ // pVolumeCB->VolumeReferenceCount has been incremented
+ // pVolumeCB->RootFcb == NULL
+ //
+
+ bReleaseVolumeLock = TRUE;
}
else
{
//
- // Just to ensure that things don't get torn down AND we don't create a
- // deadlock with invalidation
+ // AFSInitVolume returns with a VolumeReferenceCount
+ // obtain one to match
//
lCount = InterlockedIncrement( &pVolumeCB->VolumeReferenceCount);
- AFSReleaseResource( &pDevExt->Specific.RDR.VolumeTreeLock);
-
- AFSAcquireExcl( pVolumeCB->VolumeLock,
- TRUE);
+ AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSBuildRootVolume Increment count on volume %08lX Cnt %d\n",
+ pVolumeCB,
+ lCount);
- lCount = InterlockedDecrement( &pVolumeCB->VolumeReferenceCount);
+ AFSReleaseResource( &pDevExt->Specific.RDR.VolumeTreeLock);
}
if( pVolumeCB->RootFcb == NULL)
{
+ if ( bReleaseVolumeLock == FALSE)
+ {
+
+ AFSAcquireExcl( pVolumeCB->VolumeLock,
+ TRUE);
+
+ bReleaseVolumeLock = TRUE;
+ }
+
//
// Initialize the root fcb for this volume
//
if( !NT_SUCCESS( ntStatus))
{
+ lCount = InterlockedDecrement( &pVolumeCB->VolumeReferenceCount);
+
AFSReleaseResource( pVolumeCB->VolumeLock);
try_return( ntStatus);
AFSReleaseResource( &pVolumeCB->RootFcb->NPFcb->Resource);
}
+ if ( bReleaseVolumeLock == TRUE)
+ {
+
+ AFSReleaseResource( pVolumeCB->VolumeLock);
+ }
+
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE_2,
"AFSBuildRootVolume Evaluated target of %wZ FID %08lX-%08lX-%08lX-%08lX as root volume\n",
pVolumeCB->ObjectInformation.FileId.Vnode,
pVolumeCB->ObjectInformation.FileId.Unique);
- lCount = InterlockedIncrement( &pVolumeCB->VolumeReferenceCount);
-
- AFSReleaseResource( pVolumeCB->VolumeLock);
-
- AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSBuildRootVolume Increment count on volume %08lX Cnt %d\n",
- pVolumeCB,
- lCount);
-
*TargetVolumeCB = pVolumeCB;
try_exit:
if( FileObject->FileName.Buffer != NULL)
{
- AFSExFreePool( FileObject->FileName.Buffer);
+ AFSExFreePoolWithTag( FileObject->FileName.Buffer, 0);
}
FileObject->FileName = uniReparseName;
if ( pDirEntry)
{
- AFSExFreePool( pDirEntry);
+ AFSExFreePoolWithTag( pDirEntry, AFS_GENERIC_MEMORY_2_TAG);
}
}