BOOLEAN bAllocatedSymLinkBuffer = FALSE;
UNICODE_STRING uniRelativeName, uniNoOpName;
AFSObjectInfoCB *pCurrentObject = NULL;
+ AFSObjectInfoCB *pParentObjectInfo = NULL;
AFSVolumeCB *pCurrentVolume = *VolumeCB;
BOOLEAN bReleaseCurrentVolume = TRUE;
BOOLEAN bSubstitutedName = FALSE;
+ LONG lCount;
__Enter
{
uniSearchName.Length = uniSearchName.MaximumLength = 0;
uniSearchName.Buffer = NULL;
- ASSERT( pCurrentVolume->VolumeReferenceCount > 1);
-
while( TRUE)
{
+ ASSERT( pCurrentVolume->VolumeReferenceCount > 1);
+
+ ASSERT( pDirEntry->DirOpenReferenceCount > 0);
+
//
// Check our total link count for this name array
//
pCurrentObject->FileId.Volume,
pCurrentObject->FileId.Vnode,
pCurrentObject->FileId.Unique,
- ntStatus);
+ STATUS_FILE_DELETED);
try_return( ntStatus = STATUS_FILE_DELETED);
}
pCurrentObject->FileId.Volume,
pCurrentObject->FileId.Vnode,
pCurrentObject->FileId.Unique,
- ntStatus);
+ STATUS_DELETE_PENDING);
try_return( ntStatus = STATUS_DELETE_PENDING);
}
pCurrentObject->FileId.Vnode,
pCurrentObject->FileId.Unique);
+ //
+ // Directory TreeLock should be exclusively held
+ //
+
+ AFSAcquireExcl( pCurrentObject->Specific.Directory.DirectoryNodeHdr.TreeLock,
+ TRUE);
+
ntStatus = AFSVerifyEntry( AuthGroup,
pDirEntry);
+ AFSReleaseResource( pCurrentObject->Specific.Directory.DirectoryNodeHdr.TreeLock);
+
if( !NT_SUCCESS( ntStatus))
{
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);
pCurrentObject->FileId.Vnode,
pCurrentObject->FileId.Unique);
+ //
+ // Directory TreeLock should be exclusively held
+ //
+
ntStatus = AFSVerifyEntry( AuthGroup,
pDirEntry);
+ AFSReleaseResource( pCurrentObject->Specific.Directory.DirectoryNodeHdr.TreeLock);
+
if( !NT_SUCCESS( ntStatus))
{
continue;
}
}
+ else
+ {
+
+ AFSReleaseResource( pCurrentObject->Specific.Directory.DirectoryNodeHdr.TreeLock);
+ }
//
// If we were given a zero length target name then deny access to the entry
if( pDirEntry->NameInformation.TargetName.Length == 0)
{
- ntStatus = STATUS_ACCESS_DENIED;
+ ntStatus = STATUS_REPARSE_POINT_NOT_RESOLVED;
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
if( pTmpBuffer != NULL)
{
- AFSExFreePool( pTmpBuffer);
+ AFSExFreePoolWithTag( pTmpBuffer, 0);
}
AFSReleaseResource( &pDirEntry->NonPaged->Lock);
// Dereference the current entry ..
//
- InterlockedDecrement( &pDirEntry->OpenReferenceCount);
+ lCount = InterlockedDecrement( &pDirEntry->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
&pDirEntry->NameInformation.FileName,
pDirEntry,
NULL,
- pDirEntry->OpenReferenceCount);
+ lCount);
+
+ ASSERT( lCount >= 0);
//
// OK, need to back up one entry for the correct parent since the current
// Increment our reference on this dir entry
//
- InterlockedIncrement( &pDirEntry->OpenReferenceCount);
+ lCount = InterlockedIncrement( &pDirEntry->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
&pDirEntry->NameInformation.FileName,
pDirEntry,
NULL,
- pDirEntry->OpenReferenceCount);
+ lCount);
if( BooleanFlagOn( pDirEntry->ObjectInformation->Flags, AFS_OBJECT_ROOT_VOLUME))
{
pCurrentObject->FileId.Vnode,
pCurrentObject->FileId.Unique);
+ if ( !AFSIsAbsoluteAFSName( &pDirEntry->NameInformation.TargetName))
+ {
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_ERROR,
+ "AFSLocateNameEntry Name %wZ contains invalid server name\n",
+ &pDirEntry->NameInformation.TargetName);
+
+ //
+ // The correct response would be STATUS_OBJECT_PATH_INVALID
+ // but that prevents cmd.exe from performing a recursive
+ // directory enumeration when opening a directory entry
+ // that represents a symlink to an invalid path is discovered.
+ //
+
+ AFSReleaseResource( &pDirEntry->NonPaged->Lock);
+
+ try_return( ntStatus = STATUS_OBJECT_PATH_NOT_FOUND);
+ }
+
//
// We'll substitute this name into the current process name
// starting at where we sit in the path
//
RtlCopyMemory( uniTempName.Buffer,
- pDirEntry->NameInformation.TargetName.Buffer,
- pDirEntry->NameInformation.TargetName.Length);
+ &pDirEntry->NameInformation.TargetName.Buffer[ AFSMountRootName.Length/sizeof( WCHAR)],
+ pDirEntry->NameInformation.TargetName.Length - AFSMountRootName.Length);
- uniTempName.Length = pDirEntry->NameInformation.TargetName.Length;
+ uniTempName.Length = pDirEntry->NameInformation.TargetName.Length - AFSMountRootName.Length;
//
// And now any remaining portion of the name
if( pTmpBuffer != NULL)
{
- AFSExFreePool( pTmpBuffer);
+ AFSExFreePoolWithTag( pTmpBuffer, 0);
}
AFSReleaseResource( &pDirEntry->NonPaged->Lock);
pCurrentObject->FileId.Vnode,
pCurrentObject->FileId.Unique);
- InterlockedDecrement( &pCurrentVolume->VolumeReferenceCount);
+ lCount = InterlockedDecrement( &pCurrentVolume->VolumeReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSLocateNameEntry Decrement count on volume %08lX Cnt %d\n",
pCurrentVolume,
- pCurrentVolume->VolumeReferenceCount);
-
- AFSReleaseResource( pCurrentVolume->VolumeLock);
+ lCount);
pCurrentVolume = AFSGlobalRoot;
- AFSAcquireShared( pCurrentVolume->VolumeLock,
- TRUE);
-
- InterlockedIncrement( &pCurrentVolume->VolumeReferenceCount);
+ lCount = InterlockedIncrement( &pCurrentVolume->VolumeReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSLocateNameEntry Increment count on volume %08lX Cnt %d\n",
pCurrentVolume,
- pCurrentVolume->VolumeReferenceCount);
+ lCount);
}
//
// Dereference our current dir entry
//
- InterlockedDecrement( &pDirEntry->OpenReferenceCount);
+ lCount = InterlockedDecrement( &pDirEntry->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
&pDirEntry->NameInformation.FileName,
pDirEntry,
NULL,
- pDirEntry->OpenReferenceCount);
+ lCount);
+
+ ASSERT( lCount >= 0);
pDirEntry = pCurrentVolume->DirectoryCB;
// Reference the new dir entry
//
- InterlockedIncrement( &pDirEntry->OpenReferenceCount);
+ lCount = InterlockedIncrement( &pDirEntry->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
&pDirEntry->NameInformation.FileName,
pDirEntry,
NULL,
- pDirEntry->OpenReferenceCount);
+ lCount);
//
// Reset the name array
pNameArray->LinkCount = lLinkCount;
- //
- // Process over the \\<Global root> portion of the name
- //
-
- FsRtlDissectName( uniPathName,
- &uniComponentName,
- &uniRemainingPath);
-
- if( RtlCompareUnicodeString( &uniComponentName,
- &AFSServerName,
- TRUE) != 0)
- {
-
- AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
- AFS_TRACE_LEVEL_ERROR,
- "AFSLocateNameEntry Name %wZ contains invalid server name\n",
- &uniPathName);
-
- //
- // The correct response would be STATUS_OBJECT_PATH_INVALID
- // but that prevents cmd.exe from performing a recursive
- // directory enumeration when opening a directory entry
- // that represents a symlink to an invalid path is discovered.
- //
- try_return( ntStatus = STATUS_OBJECT_PATH_NOT_FOUND);
- }
-
- uniPathName = uniRemainingPath;
-
pParentDirEntry = NULL;
}
// Increment our link count
//
- InterlockedIncrement( &pNameArray->LinkCount);
+ lCount = InterlockedIncrement( &pNameArray->LinkCount);
continue;
}
ASSERT( pCurrentVolume->VolumeReferenceCount > 1);
- InterlockedDecrement( &pCurrentVolume->VolumeReferenceCount);
+ lCount = InterlockedDecrement( &pCurrentVolume->VolumeReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSLocateNameEntry Decrement2 count on volume %08lX Cnt %d\n",
pCurrentVolume,
- pCurrentVolume->VolumeReferenceCount);
-
- AFSReleaseResource( pCurrentVolume->VolumeLock);
+ lCount);
ntStatus = AFSBuildMountPointTarget( AuthGroup,
pDirEntry,
bReleaseCurrentVolume = FALSE;
- try_return( ntStatus = STATUS_ACCESS_DENIED);
+ try_return( ntStatus);
}
ASSERT( pCurrentVolume->VolumeReferenceCount > 1);
- ASSERT( ExIsResourceAcquiredLite( pCurrentVolume->VolumeLock));
-
- //
- // Replace the current name for the mp with the volume root of the target
- //
-
- AFSReplaceCurrentElement( pNameArray,
- pCurrentVolume->DirectoryCB);
-
//
// We want to restart processing here on the new parent ...
// Deref and ref count the entries
//
- InterlockedDecrement( &pDirEntry->OpenReferenceCount);
+ lCount = InterlockedDecrement( &pDirEntry->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
&pDirEntry->NameInformation.FileName,
pDirEntry,
NULL,
- pDirEntry->OpenReferenceCount);
+ lCount);
+
+ ASSERT( lCount >= 0);
pDirEntry = pCurrentVolume->DirectoryCB;
- InterlockedIncrement( &pDirEntry->OpenReferenceCount);
+ lCount = InterlockedIncrement( &pDirEntry->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
&pDirEntry->NameInformation.FileName,
pDirEntry,
NULL,
- pDirEntry->OpenReferenceCount);
+ lCount);
+
+ //
+ // The name array stores both the mount point and the target.
+ // Insert the target.
+ //
+
+ AFSInsertNextElement( pNameArray,
+ pDirEntry);
pParentDirEntry = NULL;
// Increment our link count
//
- InterlockedIncrement( &pNameArray->LinkCount);
+ lCount = InterlockedIncrement( &pNameArray->LinkCount);
continue;
}
uniSearchName.Buffer != NULL)
{
- AFSExFreePool( uniSearchName.Buffer);
+ AFSExFreePoolWithTag( uniSearchName.Buffer, 0);
bSubstituteName = FALSE;
//
// Need to back up one entry in the name array
//
-
- InterlockedDecrement( &pDirEntry->OpenReferenceCount);
+ lCount = InterlockedDecrement( &pDirEntry->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
&pDirEntry->NameInformation.FileName,
pDirEntry,
NULL,
- pDirEntry->OpenReferenceCount);
+ lCount);
+
+ ASSERT( lCount >= 0);
pDirEntry = AFSBackupEntry( NameArray);
try_return(ntStatus = STATUS_OBJECT_PATH_INVALID);
}
- InterlockedIncrement( &pDirEntry->OpenReferenceCount);
+ lCount = InterlockedIncrement( &pDirEntry->DirOpenReferenceCount);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSLocateNameEntry Increment4 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))
{
ASSERT( pParentDirEntry != pDirEntry);
}
- AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSLocateNameEntry Increment4 count on %wZ DE %p Ccb %p Cnt %d\n",
- &pDirEntry->NameInformation.FileName,
- pDirEntry,
- NULL,
- pDirEntry->OpenReferenceCount);
-
uniPathName = uniRemainingPath;
continue;
// a lookup in the short name tree
//
- if( RtlIsNameLegalDOS8Dot3( &uniSearchName,
+ if( !BooleanFlagOn( pDevExt->DeviceFlags, AFS_DEVICE_FLAG_DISABLE_SHORTNAMES) &&
+ RtlIsNameLegalDOS8Dot3( &uniSearchName,
NULL,
NULL))
{
&pDirEntry);
}
+ if ( pDirEntry == NULL &&
+ pParentDirEntry->ObjectInformation->VolumeCB == AFSGlobalRoot)
+ {
+
+ //
+ // Check with the service to see if this is a valid cell name
+ // that can be automatically resolved. Drop the shared TreeLock
+ // since AFSCheckCellName must acquire it exclusively.
+ //
+
+ AFSReleaseResource( pParentDirEntry->ObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock);
+
+ ntStatus = AFSCheckCellName( AuthGroup,
+ &uniSearchName,
+ &pDirEntry);
+
+ AFSAcquireShared( pParentDirEntry->ObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock,
+ TRUE);
+ }
+
if( pDirEntry == NULL)
{
if( bSubstituteName)
{
- AFSExFreePool( uniSearchName.Buffer);
+ AFSExFreePoolWithTag( uniSearchName.Buffer, 0);
uniSearchName = uniComponentName;
pDirEntry->CaseInsensitiveList.fLink != NULL)
{
+ //
+ // Increment our dir entry ref count since we will decrement it on exit
+ //
+
+ lCount = InterlockedIncrement( &pDirEntry->DirOpenReferenceCount);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSLocateNameEntry Increment5 count on %wZ DE %p Ccb %p Cnt %d\n",
+ &pDirEntry->NameInformation.FileName,
+ pDirEntry,
+ NULL,
+ lCount);
+
AFSReleaseResource( pParentDirEntry->ObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock);
try_return(ntStatus = STATUS_OBJECT_NAME_COLLISION);
pParentDirEntry->ObjectInformation->FileId.Vnode,
pParentDirEntry->ObjectInformation->FileId.Unique);
+ //
+ // Directory TreeLock should be exclusively held
+ //
+
+ AFSAcquireExcl( pParentDirEntry->ObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock,
+ TRUE);
+
ntStatus = AFSVerifyEntry( AuthGroup,
pParentDirEntry);
+ AFSReleaseResource( pParentDirEntry->ObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock);
+
if( !NT_SUCCESS( ntStatus))
{
// Increment our dir entry ref count
//
- InterlockedIncrement( &pDirEntry->OpenReferenceCount);
+ lCount = InterlockedIncrement( &pDirEntry->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
&pDirEntry->NameInformation.FileName,
pDirEntry,
NULL,
- pDirEntry->OpenReferenceCount);
+ lCount);
}
AFSReleaseResource( pParentDirEntry->ObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock);
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
- "AFSLocateNameEntry (FO: %08lX) Deleted parent %wZ FID %08lX-%08lX-%08lX-%08lX\n",
+ "AFSLocateNameEntry (FO: %08lX) Deleted entry %wZ FID %08lX-%08lX-%08lX-%08lX\n",
FileObject,
&pDirEntry->NameInformation.FileName,
pCurrentObject->FileId.Cell,
// 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,
TRUE);
- if( InterlockedDecrement( &pDirEntry->OpenReferenceCount) == 0)
+ lCount = InterlockedDecrement( &pDirEntry->DirOpenReferenceCount);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSLocateNameEntry Decrement count on %wZ DE %p Ccb %p Cnt %d\n",
+ &pDirEntry->NameInformation.FileName,
+ pDirEntry,
+ NULL,
+ lCount);
+
+ ASSERT( lCount >= 0);
+
+ if( lCount <= 0)
{
- AFSDbgLogMsg( AFS_SUBSYSTEM_CLEANUP_PROCESSING,
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING|AFS_SUBSYSTEM_CLEANUP_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSLocateNameEntry Deleting dir entry %08lX (%08lX) for %wZ\n",
pDirEntry,
// 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);
// Decrement the previous parent
//
- InterlockedDecrement( &pParentDirEntry->OpenReferenceCount);
+ lCount = InterlockedDecrement( &pParentDirEntry->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
&pParentDirEntry->NameInformation.FileName,
pParentDirEntry,
NULL,
- pParentDirEntry->OpenReferenceCount);
+ lCount);
+
+ ASSERT( lCount >= 0);
//
// If we ended up substituting a name in the component then update
//
if( pCurrentObject->FileType == AFS_FILE_TYPE_SYMLINK &&
- pCurrentObject->TargetFileId.Vnode == 0 &&
- pCurrentObject->TargetFileId.Unique == 0 &&
- pDirEntry->NameInformation.TargetName.Length == 0)
+ ( pCurrentObject->TargetFileId.Vnode == 0 ||
+ pDirEntry->NameInformation.TargetName.Length == 0))
{
ntStatus = AFSValidateSymLink( AuthGroup,
if( pDirEntry != NULL)
{
- InterlockedDecrement( &pDirEntry->OpenReferenceCount);
+ lCount = InterlockedDecrement( &pDirEntry->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
&pDirEntry->NameInformation.FileName,
pDirEntry,
NULL,
- pDirEntry->OpenReferenceCount);
+ lCount);
+
+ ASSERT( lCount >= 0);
}
else if( pParentDirEntry != NULL)
{
- InterlockedDecrement( &pParentDirEntry->OpenReferenceCount);
+ lCount = InterlockedDecrement( &pParentDirEntry->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
&pParentDirEntry->NameInformation.FileName,
pParentDirEntry,
NULL,
- pParentDirEntry->OpenReferenceCount);
+ lCount);
+
+ ASSERT( lCount >= 0);
}
if( bReleaseCurrentVolume)
ASSERT( pCurrentVolume->VolumeReferenceCount > 1);
- ASSERT( ExIsResourceAcquiredLite( pCurrentVolume->VolumeLock));
-
- InterlockedDecrement( &pCurrentVolume->VolumeReferenceCount);
+ lCount = InterlockedDecrement( &pCurrentVolume->VolumeReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSLocateNameEntry Decrement3 count on volume %08lX Cnt %d\n",
pCurrentVolume,
- pCurrentVolume->VolumeReferenceCount);
-
- AFSReleaseResource( pCurrentVolume->VolumeLock);
+ lCount);
}
if( RootPathName->Buffer != uniFullPathName.Buffer)
{
- AFSExFreePool( uniFullPathName.Buffer);
+ AFSExFreePoolWithTag( uniFullPathName.Buffer, 0);
}
}
else
&(*ParentDirectoryCB)->NameInformation.FileName,
*ParentDirectoryCB,
NULL,
- (*ParentDirectoryCB)->OpenReferenceCount);
+ (*ParentDirectoryCB)->DirOpenReferenceCount);
}
if( *DirectoryCB != NULL)
&(*DirectoryCB)->NameInformation.FileName,
*DirectoryCB,
NULL,
- (*DirectoryCB)->OpenReferenceCount);
+ (*DirectoryCB)->DirOpenReferenceCount);
}
}
uniSearchName.Buffer != NULL)
{
- AFSExFreePool( uniSearchName.Buffer);
+ AFSExFreePoolWithTag( uniSearchName.Buffer, 0);
}
}
AFSDirectoryCB *pDirNode = NULL, *pExistingDirNode = NULL;
UNICODE_STRING uniShortName;
LARGE_INTEGER liFileSize = {0,0};
+ LONG lCount;
__Enter
{
if( pExistingDirNode != NULL)
{
+ if (AFSIsEqualFID( &pDirNode->ObjectInformation->FileId,
+ &pExistingDirNode->ObjectInformation->FileId))
+ {
- AFSDeleteDirEntry( ParentObjectInfo,
- pDirNode);
+ AFSDeleteDirEntry( ParentObjectInfo,
+ pDirNode);
- InterlockedIncrement( &pExistingDirNode->OpenReferenceCount);
+ lCount = InterlockedIncrement( &pExistingDirNode->DirOpenReferenceCount);
- AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSCreateDirEntry Increment count on %wZ DE %p Cnt %d\n",
- &pExistingDirNode->NameInformation.FileName,
- pExistingDirNode,
- pExistingDirNode->OpenReferenceCount);
+ AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSCreateDirEntry Increment count on %wZ DE %p Cnt %d\n",
+ &pExistingDirNode->NameInformation.FileName,
+ pExistingDirNode,
+ lCount);
- *DirEntry = pExistingDirNode;
+ *DirEntry = pExistingDirNode;
- AFSReleaseResource( ParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock);
+ AFSReleaseResource( ParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock);
- try_return( ntStatus = STATUS_SUCCESS);
+ try_return( ntStatus = STATUS_SUCCESS);
+ }
+ else
+ {
+
+ //
+ // Need to tear down this entry and rebuild it below
+ //
+
+ if( pExistingDirNode->DirOpenReferenceCount <= 0)
+ {
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSCreateDirEntry Different FIDs - Deleting DE %p for %wZ Old FID %08lX-%08lX-%08lX-%08lX New FID %08lX-%08lX-%08lX-%08lX\n",
+ pExistingDirNode,
+ &pExistingDirNode->NameInformation.FileName,
+ pExistingDirNode->ObjectInformation->FileId.Cell,
+ pExistingDirNode->ObjectInformation->FileId.Volume,
+ pExistingDirNode->ObjectInformation->FileId.Vnode,
+ pExistingDirNode->ObjectInformation->FileId.Unique,
+ pDirNode->ObjectInformation->FileId.Cell,
+ pDirNode->ObjectInformation->FileId.Volume,
+ pDirNode->ObjectInformation->FileId.Vnode,
+ pDirNode->ObjectInformation->FileId.Unique);
+
+ AFSDeleteDirEntry( ParentObjectInfo,
+ pExistingDirNode);
+ }
+ else
+ {
+
+ SetFlag( pExistingDirNode->Flags, AFS_DIR_ENTRY_DELETED);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSCreateDirEntry Different FIDs - Removing DE %p for %wZ Old FID %08lX-%08lX-%08lX-%08lX New FID %08lX-%08lX-%08lX-%08lX\n",
+ pExistingDirNode,
+ &pExistingDirNode->NameInformation.FileName,
+ pExistingDirNode->ObjectInformation->FileId.Cell,
+ pExistingDirNode->ObjectInformation->FileId.Volume,
+ pExistingDirNode->ObjectInformation->FileId.Vnode,
+ pExistingDirNode->ObjectInformation->FileId.Unique,
+ pDirNode->ObjectInformation->FileId.Cell,
+ pDirNode->ObjectInformation->FileId.Volume,
+ pDirNode->ObjectInformation->FileId.Vnode,
+ pDirNode->ObjectInformation->FileId.Unique);
+
+ AFSRemoveNameEntry( ParentObjectInfo,
+ pExistingDirNode);
+ }
+
+ }
}
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
pDirNode,
TRUE);
- InterlockedIncrement( &pDirNode->OpenReferenceCount);
+ lCount = InterlockedIncrement( &pDirNode->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSCreateDirEntry Increment2 count on %wZ DE %p Cnt %d\n",
&pDirNode->NameInformation.FileName,
pDirNode,
- pDirNode->OpenReferenceCount);
+ lCount);
//
// Pass back the dir entry
IN BOOLEAN InsertInEnumList)
{
+ LONG lCount;
+
__Enter
{
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSInsertDirectoryNode Inserting entry %08lX %wZ FID %08lX-%08lX-%08lX-%08lXStatus %08lX\n",
+ "AFSInsertDirectoryNode Inserting entry %08lX %wZ FID %08lX-%08lX-%08lX-%08lX\n",
DirEntry,
&DirEntry->NameInformation.FileName,
DirEntry->ObjectInformation->FileId.Cell,
SetFlag( DirEntry->Flags, AFS_DIR_ENTRY_INSERTED_ENUM_LIST);
- InterlockedIncrement( &ParentObjectInfo->Specific.Directory.DirectoryNodeCount);
+ lCount = InterlockedIncrement( &ParentObjectInfo->Specific.Directory.DirectoryNodeCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIR_NODE_COUNT,
AFS_TRACE_LEVEL_VERBOSE,
"AFSInsertDirectoryNode Adding entry %wZ Inc Count %d to parent FID %08lX-%08lX-%08lX-%08lX\n",
- &DirEntry->NameInformation.FileName,
- ParentObjectInfo->Specific.Directory.DirectoryNodeCount,
- ParentObjectInfo->FileId.Cell,
- ParentObjectInfo->FileId.Volume,
- ParentObjectInfo->FileId.Vnode,
- ParentObjectInfo->FileId.Unique);
+ &DirEntry->NameInformation.FileName,
+ lCount,
+ ParentObjectInfo->FileId.Cell,
+ ParentObjectInfo->FileId.Volume,
+ ParentObjectInfo->FileId.Vnode,
+ ParentObjectInfo->FileId.Unique);
}
}
{
NTSTATUS ntStatus = STATUS_SUCCESS;
+ LONG lCount;
__Enter
{
- AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING | AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSDeleteDirEntry Deleting dir entry in parent %08lX Entry %08lX %wZ FID %08lX-%08lX-%08lX-%08lX\n",
+ "AFSDeleteDirEntry Deleting dir entry in parent %08lX Entry %08lX %wZ FID %08lX-%08lX-%08lX-%08lX RefCount %08lX\n",
ParentObjectInfo,
DirEntry,
&DirEntry->NameInformation.FileName,
DirEntry->ObjectInformation->FileId.Cell,
DirEntry->ObjectInformation->FileId.Volume,
DirEntry->ObjectInformation->FileId.Vnode,
- DirEntry->ObjectInformation->FileId.Unique);
+ DirEntry->ObjectInformation->FileId.Unique,
+ DirEntry->DirOpenReferenceCount);
+
+ ASSERT( DirEntry->DirOpenReferenceCount == 0);
AFSRemoveDirNodeFromParent( ParentObjectInfo,
DirEntry,
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);
- if( InterlockedDecrement( &DirEntry->ObjectInformation->ObjectReferenceCount) == 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) &&
+ DirEntry->ObjectInformation->Links == 0)
+ {
+
+ 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;
{
NTSTATUS ntStatus = STATUS_SUCCESS;
+ LONG lCount;
__Enter
{
ASSERT( ParentObjectInfo->Specific.Directory.DirectoryNodeCount > 0);
- InterlockedDecrement( &ParentObjectInfo->Specific.Directory.DirectoryNodeCount);
+ lCount = InterlockedDecrement( &ParentObjectInfo->Specific.Directory.DirectoryNodeCount);
ClearFlag( DirEntry->Flags, AFS_DIR_ENTRY_INSERTED_ENUM_LIST);
AFS_TRACE_LEVEL_VERBOSE,
"AFSRemoveDirNodeFromParent Removing entry %wZ Dec Count %d to parent FID %08lX-%08lX-%08lX-%08lX\n",
&DirEntry->NameInformation.FileName,
- ParentObjectInfo->Specific.Directory.DirectoryNodeCount,
+ lCount,
ParentObjectInfo->FileId.Cell,
ParentObjectInfo->FileId.Volume,
ParentObjectInfo->FileId.Vnode,
AFSFcb *pRelatedFcb = NULL;
BOOLEAN bReleaseTreeLock = FALSE;
BOOLEAN bIsAllShare = FALSE;
+ LONG lCount;
__Enter
{
*FileName = pIrpSp->FileObject->FileName;
//
- // Grab the root node exclusive before returning
+ // Grab the root node while checking state
//
- AFSAcquireExcl( pVolumeCB->VolumeLock,
- TRUE);
+ AFSAcquireShared( pVolumeCB->VolumeLock,
+ TRUE);
if( BooleanFlagOn( pVolumeCB->ObjectInformation.Flags, AFS_OBJECT_FLAGS_OBJECT_INVALID) ||
BooleanFlagOn( pVolumeCB->Flags, AFS_VOLUME_FLAGS_OFFLINE))
}
}
- AFSConvertToShared( pVolumeCB->VolumeLock);
+ AFSReleaseResource( pVolumeCB->VolumeLock);
if( BooleanFlagOn( pDirEntry->ObjectInformation->Flags, AFS_OBJECT_FLAGS_VERIFY))
{
pDirEntry->ObjectInformation->FileId.Vnode,
pDirEntry->ObjectInformation->FileId.Unique);
+ //
+ // Directory TreeLock should be exclusively held
+ //
+
+ AFSAcquireExcl( pDirEntry->ObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock,
+ TRUE);
+
ntStatus = AFSVerifyEntry( AuthGroup,
pDirEntry);
+ AFSReleaseResource( pDirEntry->ObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock);
+
if( !NT_SUCCESS( ntStatus))
{
pDirEntry->ObjectInformation->FileId.Unique,
ntStatus);
- AFSReleaseResource( pVolumeCB->VolumeLock);
-
try_return( ntStatus);
}
}
"AFSParseName (%08lX) Failed to allocate full name buffer\n",
Irp);
- AFSReleaseResource( pVolumeCB->VolumeLock);
-
try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES);
}
"AFSParseName (%08lX) Failed to initialize name array\n",
Irp);
- AFSExFreePool( uniFullName.Buffer);
-
- AFSReleaseResource( pVolumeCB->VolumeLock);
+ AFSExFreePoolWithTag( uniFullName.Buffer, 0);
try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES);
}
"AFSParseName (%08lX) Failed to initialize name array\n",
Irp);
- AFSExFreePool( uniFullName.Buffer);
-
- AFSReleaseResource( pVolumeCB->VolumeLock);
+ AFSExFreePoolWithTag( uniFullName.Buffer, 0);
try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES);
}
"AFSParseName (%08lX) Failed to populate name array\n",
Irp);
- AFSExFreePool( uniFullName.Buffer);
-
- AFSReleaseResource( pVolumeCB->VolumeLock);
+ AFSExFreePoolWithTag( uniFullName.Buffer, 0);
try_return( ntStatus);
}
// Increment our volume reference count
//
- InterlockedIncrement( &pVolumeCB->VolumeReferenceCount);
+ lCount = InterlockedIncrement( &pVolumeCB->VolumeReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSParseName Increment count on volume %08lX Cnt %d\n",
pVolumeCB,
- pVolumeCB->VolumeReferenceCount);
+ lCount);
*ParentDirectoryCB = pDirEntry;
- InterlockedIncrement( &pDirEntry->OpenReferenceCount);
+ lCount = InterlockedIncrement( &pDirEntry->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
&pDirEntry->NameInformation.FileName,
pDirEntry,
NULL,
- pDirEntry->OpenReferenceCount);
+ lCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE_2,
}
}
+ if( FsRtlDoesNameContainWildCards( &uniFullName))
+ {
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_ERROR,
+ "AFSParseName (%08lX) Component %wZ contains wild cards\n",
+ Irp,
+ &uniFullName);
+
+ try_return( ntStatus = STATUS_OBJECT_NAME_INVALID);
+ }
+
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE_2,
"AFSParseName (%08lX) Processing full name %wZ\n",
// Be sure we are online and ready to go
//
- AFSAcquireExcl( AFSGlobalRoot->VolumeLock,
- TRUE);
+ AFSAcquireShared( AFSGlobalRoot->VolumeLock,
+ TRUE);
if( BooleanFlagOn( AFSGlobalRoot->ObjectInformation.Flags, AFS_OBJECT_FLAGS_OBJECT_INVALID) ||
BooleanFlagOn( AFSGlobalRoot->Flags, AFS_VOLUME_FLAGS_OFFLINE))
}
}
+ AFSReleaseResource( AFSGlobalRoot->VolumeLock);
+
if( !BooleanFlagOn( AFSGlobalRoot->ObjectInformation.Flags, AFS_OBJECT_FLAGS_DIRECTORY_ENUMERATED))
{
Irp,
ntStatus);
- AFSReleaseResource( AFSGlobalRoot->VolumeLock);
-
try_return( ntStatus);
}
}
"AFSParseName (%08lX) Returning global root access\n",
Irp);
- InterlockedIncrement( &AFSGlobalRoot->DirectoryCB->OpenReferenceCount);
+ lCount = InterlockedIncrement( &AFSGlobalRoot->DirectoryCB->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
&AFSGlobalRoot->DirectoryCB->NameInformation.FileName,
AFSGlobalRoot->DirectoryCB,
NULL,
- AFSGlobalRoot->DirectoryCB->OpenReferenceCount);
-
- AFSReleaseResource( AFSGlobalRoot->VolumeLock);
+ lCount);
*VolumeCB = NULL;
&uniComponentName,
&uniRemainingPath);
+ if( FsRtlDoesNameContainWildCards( &uniFullName))
+ {
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_ERROR,
+ "AFSParseName (%08lX) Component %wZ contains wild cards\n",
+ Irp,
+ &uniComponentName);
+
+ try_return( ntStatus = STATUS_OBJECT_NAME_INVALID);
+ }
+
//
// If this is the ALL access then perform some additional processing
//
- if( RtlCompareUnicodeString( &uniComponentName,
+ if( uniComponentName.Length == 0 ||
+ RtlCompareUnicodeString( &uniComponentName,
&AFSGlobalRootName,
TRUE) == 0)
{
"AFSParseName (%08lX) Returning global root access\n",
Irp);
- InterlockedIncrement( &AFSGlobalRoot->DirectoryCB->OpenReferenceCount);
+ lCount = InterlockedIncrement( &AFSGlobalRoot->DirectoryCB->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
&AFSGlobalRoot->DirectoryCB->NameInformation.FileName,
AFSGlobalRoot->DirectoryCB,
NULL,
- AFSGlobalRoot->DirectoryCB->OpenReferenceCount);
-
- AFSReleaseResource( AFSGlobalRoot->VolumeLock);
+ lCount);
*VolumeCB = NULL;
"AFSParseName (%08lX) Returning root PIOCtl access\n",
Irp);
- InterlockedIncrement( &AFSGlobalRoot->DirectoryCB->OpenReferenceCount);
+ lCount = InterlockedIncrement( &AFSGlobalRoot->DirectoryCB->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
&AFSGlobalRoot->DirectoryCB->NameInformation.FileName,
AFSGlobalRoot->DirectoryCB,
NULL,
- AFSGlobalRoot->DirectoryCB->OpenReferenceCount);
-
- AFSReleaseResource( AFSGlobalRoot->VolumeLock);
+ lCount);
ClearFlag( *ParseFlags, AFS_PARSE_FLAG_ROOT_ACCESS);
Irp,
&uniComponentName);
- AFSReleaseResource( AFSGlobalRoot->VolumeLock);
-
//
// Add in the full share name to pass back
//
ClearFlag( *ParseFlags, AFS_PARSE_FLAG_ROOT_ACCESS);
- InterlockedIncrement( &pDirEntry->OpenReferenceCount);
+ lCount = InterlockedIncrement( &pDirEntry->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
&pDirEntry->NameInformation.FileName,
pDirEntry,
NULL,
- pDirEntry->OpenReferenceCount);
+ lCount);
try_return( ntStatus = STATUS_SUCCESS);
}
// a lookup in the short name tree
//
- if( RtlIsNameLegalDOS8Dot3( &uniComponentName,
+ if( !BooleanFlagOn( pDeviceExt->DeviceFlags, AFS_DEVICE_FLAG_DISABLE_SHORTNAMES) &&
+ RtlIsNameLegalDOS8Dot3( &uniComponentName,
NULL,
NULL))
{
if( !NT_SUCCESS( ntStatus))
{
- AFSReleaseResource( AFSGlobalRoot->VolumeLock);
if ( bIsAllShare &&
uniRemainingPath.Length == 0 &&
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
//
uniRemainingPath.Length += sizeof( WCHAR);
uniRemainingPath.MaximumLength += sizeof( WCHAR);
- InterlockedIncrement( &pVolumeCB->DirectoryCB->OpenReferenceCount);
+ lCount = InterlockedIncrement( &pVolumeCB->DirectoryCB->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
&pVolumeCB->DirectoryCB->NameInformation.FileName,
pVolumeCB->DirectoryCB,
NULL,
- pVolumeCB->DirectoryCB->OpenReferenceCount);
+ lCount);
//
// Pass back the parent being the volume root
//
*ParentDirectoryCB = pVolumeCB->DirectoryCB;
- }
-
- //
- // We only need the volume shared at this point
- //
-
- AFSConvertToShared( pVolumeCB->VolumeLock);
-
- //
- // 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);
-
- AFSReleaseResource( pVolumeCB->VolumeLock);
-
- try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES);
}
//
// Increment our reference on the volume
//
- InterlockedIncrement( &pVolumeCB->VolumeReferenceCount);
+ lCount = InterlockedIncrement( &pVolumeCB->VolumeReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSParseName Increment2 count on global volume %08lX Cnt %d\n",
pVolumeCB,
- pVolumeCB->VolumeReferenceCount);
+ lCount);
try_exit:
&(*ParentDirectoryCB)->NameInformation.FileName,
*ParentDirectoryCB,
NULL,
- (*ParentDirectoryCB)->OpenReferenceCount);
+ (*ParentDirectoryCB)->DirOpenReferenceCount);
}
}
if( *VolumeCB != NULL)
{
-
ASSERT( (*VolumeCB)->VolumeReferenceCount > 1);
}
NTSTATUS ntStatus = STATUS_SUCCESS;
UNICODE_STRING uniName;
- AFSFileID stFileID;
AFSDirEnumEntry *pDirEnumEntry = NULL;
AFSDeviceExt *pDevExt = (AFSDeviceExt *)AFSRDRDeviceObject->DeviceExtension;
AFSDirHdr *pDirHdr = &AFSGlobalRoot->ObjectInformation.Specific.Directory.DirectoryNodeHdr;
AFSDirectoryCB *pDirNode = NULL;
UNICODE_STRING uniDirName, uniTargetName;
AFSVolumeCB *pVolumeCB = NULL;
+ LONG lCount;
__Enter
{
// OK, ask the CM about this component name
//
- stFileID = AFSGlobalRoot->ObjectInformation.FileId;
-
ntStatus = AFSEvaluateTargetByName( AuthGroup,
- &stFileID,
+ &AFSGlobalRoot->ObjectInformation,
CellName,
&pDirEnumEntry);
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);
}
{
//
- // We have the global root on entry so drop it now
- //
-
- AFSReleaseResource( AFSGlobalRoot->VolumeLock);
-
- //
// Build the root volume entry
//
if( !NT_SUCCESS( ntStatus))
{
-
- //
- // On failure this routine is expecting to hold the global root
- //
-
- AFSAcquireShared( AFSGlobalRoot->VolumeLock,
- TRUE);
-
try_return( ntStatus);
}
*ShareDirEntry = pVolumeCB->DirectoryCB;
- InterlockedIncrement( &pVolumeCB->DirectoryCB->OpenReferenceCount);
+ lCount = InterlockedIncrement( &pVolumeCB->DirectoryCB->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
&pVolumeCB->DirectoryCB->NameInformation.FileName,
pVolumeCB->DirectoryCB,
NULL,
- pVolumeCB->DirectoryCB->OpenReferenceCount);
+ lCount);
+
+ lCount = InterlockedDecrement( &pVolumeCB->VolumeReferenceCount);
- InterlockedDecrement( &pVolumeCB->VolumeReferenceCount);
+ AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSCheckCellName Increment count on volume %08lX Cnt %d\n",
+ pVolumeCB,
+ lCount);
}
else
{
+ lCount = InterlockedIncrement( &pDirHdr->ContentIndex);
+
pDirNode = AFSInitDirEntry( &AFSGlobalRoot->ObjectInformation,
&uniDirName,
&uniTargetName,
pDirEnumEntry,
- (ULONG)InterlockedIncrement( &pDirHdr->ContentIndex));
+ (ULONG)lCount);
if( pDirNode == NULL)
{
SetFlag( pDirNode->Flags, AFS_DIR_ENTRY_INSERTED_ENUM_LIST);
- InterlockedIncrement( &AFSGlobalRoot->ObjectInformation.Specific.Directory.DirectoryNodeCount);
+ lCount = InterlockedIncrement( &AFSGlobalRoot->ObjectInformation.Specific.Directory.DirectoryNodeCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIR_NODE_COUNT,
AFS_TRACE_LEVEL_VERBOSE,
"AFSCheckCellName Adding entry %wZ Inc Count %d to parent FID %08lX-%08lX-%08lX-%08lX\n",
- &pDirNode->NameInformation.FileName,
- AFSGlobalRoot->ObjectInformation.Specific.Directory.DirectoryNodeCount,
- AFSGlobalRoot->ObjectInformation.FileId.Cell,
- AFSGlobalRoot->ObjectInformation.FileId.Volume,
- AFSGlobalRoot->ObjectInformation.FileId.Vnode,
- AFSGlobalRoot->ObjectInformation.FileId.Unique);
+ &pDirNode->NameInformation.FileName,
+ lCount,
+ AFSGlobalRoot->ObjectInformation.FileId.Cell,
+ AFSGlobalRoot->ObjectInformation.FileId.Volume,
+ AFSGlobalRoot->ObjectInformation.FileId.Vnode,
+ AFSGlobalRoot->ObjectInformation.FileId.Unique);
- InterlockedIncrement( &pDirNode->OpenReferenceCount);
+ lCount = InterlockedIncrement( &pDirNode->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
&pDirNode->NameInformation.FileName,
pDirNode,
NULL,
- pDirNode->OpenReferenceCount);
+ lCount);
AFSReleaseResource( AFSGlobalRoot->ObjectInformation.Specific.Directory.DirectoryNodeHdr.TreeLock);
if( pDirEnumEntry != NULL)
{
- AFSExFreePool( pDirEnumEntry);
+ AFSExFreePoolWithTag( pDirEnumEntry, AFS_GENERIC_MEMORY_31_TAG);
}
}
ULONGLONG ullIndex = 0;
AFSVolumeCB *pVolumeCB = NULL;
AFSFileID stTargetFileID;
+ LONG lCount;
+ BOOLEAN bReleaseVolumeLock = FALSE;
__Enter
{
DirectoryCB->ObjectInformation->FileId.Vnode,
DirectoryCB->ObjectInformation->FileId.Unique);
- try_return( ntStatus = STATUS_ACCESS_DENIED);
+ try_return( ntStatus = STATUS_REPARSE_POINT_NOT_RESOLVED);
}
AFSAcquireExcl( &DirectoryCB->NonPaged->Lock,
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
//
- InterlockedIncrement( &pVolumeCB->VolumeReferenceCount);
-
- AFSReleaseResource( &pDevExt->Specific.RDR.VolumeTreeLock);
+ lCount = InterlockedIncrement( &pVolumeCB->VolumeReferenceCount);
- 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);
- 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);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSBuildMountPoint Decrement count on volume %08lX Cnt %d\n",
+ pVolumeCB,
+ lCount);
+
AFSReleaseResource( pVolumeCB->VolumeLock);
try_return( ntStatus);
AFSReleaseResource( &pVolumeCB->RootFcb->NPFcb->Resource);
}
- AFSConvertToShared( pVolumeCB->VolumeLock);
+ if ( bReleaseVolumeLock == TRUE)
+ {
+
+ AFSReleaseResource( pVolumeCB->VolumeLock);
+ }
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE_2,
pVolumeCB->ObjectInformation.FileId.Vnode,
pVolumeCB->ObjectInformation.FileId.Unique);
- InterlockedIncrement( &pVolumeCB->VolumeReferenceCount);
-
- AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSBuildMountPointTarget Increment count on volume %08lX Cnt %d\n",
- pVolumeCB,
- pVolumeCB->VolumeReferenceCount);
-
*TargetVolumeCB = pVolumeCB;
try_exit:
if( pDirEntry)
{
- AFSExFreePool( pDirEntry);
+ AFSExFreePoolWithTag( pDirEntry, AFS_GENERIC_MEMORY_2_TAG);
}
}
UNICODE_STRING uniDirName, uniTargetName;
ULONGLONG ullIndex = 0;
AFSVolumeCB *pVolumeCB = NULL;
+ LONG lCount;
+ BOOLEAN bReleaseVolumeLock = FALSE;
__Enter
{
//
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
- AFS_TRACE_LEVEL_VERBOSE_2,
+ AFS_TRACE_LEVEL_VERBOSE_2,
"AFSBuildRootVolume Initializing root for FID %08lX-%08lX-%08lX-%08lX\n",
FileId->Cell,
FileId->Volume,
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
//
- InterlockedIncrement( &pVolumeCB->VolumeReferenceCount);
+ 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);
- 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);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSBuildRootVolume Decrement count on volume %08lX Cnt %d\n",
+ pVolumeCB,
+ lCount);
+
AFSReleaseResource( pVolumeCB->VolumeLock);
try_return( ntStatus);
AFSReleaseResource( &pVolumeCB->RootFcb->NPFcb->Resource);
}
- AFSConvertToShared( pVolumeCB->VolumeLock);
+ if ( bReleaseVolumeLock == TRUE)
+ {
+
+ AFSReleaseResource( pVolumeCB->VolumeLock);
+ }
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE_2,
pVolumeCB->ObjectInformation.FileId.Vnode,
pVolumeCB->ObjectInformation.FileId.Unique);
- InterlockedIncrement( &pVolumeCB->VolumeReferenceCount);
-
- AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSBuildRootVolume Increment count on volume %08lX Cnt %d\n",
- pVolumeCB,
- pVolumeCB->VolumeReferenceCount);
-
*TargetVolumeCB = pVolumeCB;
try_exit:
NTSTATUS ntStatus = STATUS_INVALID_DEVICE_REQUEST;
UNICODE_STRING uniReparseName;
UNICODE_STRING uniMUPDeviceName;
+ UNICODE_STRING uniIOMgrDeviceName;
AFSDirEnumEntry *pDirEntry = NULL;
__Enter
RtlInitUnicodeString( &uniMUPDeviceName,
L"\\Device\\MUP");
+ RtlInitUnicodeString( &uniIOMgrDeviceName,
+ L"\\??\\");
+
uniReparseName.Length = 0;
uniReparseName.Buffer = NULL;
if( NT_SUCCESS( ntStatus))
{
- ntStatus = STATUS_ACCESS_DENIED;
+ ntStatus = STATUS_REPARSE_POINT_NOT_RESOLVED;
}
try_return( ntStatus);
// Start building the name
//
- RtlCopyMemory( uniReparseName.Buffer,
- uniMUPDeviceName.Buffer,
- uniMUPDeviceName.Length);
+ if ( DirEntry->NameInformation.TargetName.Buffer[ 0] != L'\\' &&
+ DirEntry->NameInformation.TargetName.Buffer[ 1] == L':')
+ {
- uniReparseName.Length = uniMUPDeviceName.Length;
+ RtlCopyMemory( uniReparseName.Buffer,
+ uniIOMgrDeviceName.Buffer,
+ uniIOMgrDeviceName.Length);
- if( DirEntry->NameInformation.TargetName.Buffer[ 0] != L'\\')
+ uniReparseName.Length = uniIOMgrDeviceName.Length;
+ }
+ else
{
- uniReparseName.Buffer[ uniReparseName.Length/sizeof( WCHAR)] = L'\\';
+ RtlCopyMemory( uniReparseName.Buffer,
+ uniMUPDeviceName.Buffer,
+ uniMUPDeviceName.Length);
+
+ uniReparseName.Length = uniMUPDeviceName.Length;
- uniReparseName.Length += sizeof( WCHAR);
+ if( DirEntry->NameInformation.TargetName.Buffer[ 0] != L'\\')
+ {
+
+ uniReparseName.Buffer[ uniReparseName.Length/sizeof( WCHAR)] = L'\\';
+
+ uniReparseName.Length += sizeof( WCHAR);
+ }
}
RtlCopyMemory( &uniReparseName.Buffer[ uniReparseName.Length/sizeof( WCHAR)],
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);
}
}