try_return( ntStatus);
}
+ else if( pFcb->Header.NodeTypeCode == AFS_INVALID_FCB)
+ {
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSQueryFileInfo request against Invalid Fcb\n");
+
+ try_return( ntStatus = STATUS_ACCESS_DENIED);
+ }
+
//
// Process the request
//
"AFSSetFileInfo Request failed due to read only volume\n",
Irp);
+ try_return( ntStatus = STATUS_MEDIA_WRITE_PROTECTED);
+ }
+
+ if( pFcb->Header.NodeTypeCode == AFS_INVALID_FCB &&
+ FileInformationClass != FileDispositionInformation)
+ {
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSSetFileInfo request against Invalid Fcb\n");
+
try_return( ntStatus = STATUS_ACCESS_DENIED);
}
if( NT_SUCCESS( AFSRetrieveFileAttributes( pParentDirectoryCB,
DirectoryCB,
&uniParentPath,
- NULL,
+ pCcb->NameArray,
&pCcb->AuthGroup,
&stFileInfo)))
{
if( NT_SUCCESS( AFSRetrieveFileAttributes( pParentDirectoryCB,
DirectoryCB,
&uniParentPath,
- NULL,
+ pCcb->NameArray,
&pCcb->AuthGroup,
&stFileInfo)))
{
if( NT_SUCCESS( AFSRetrieveFileAttributes( pParentDirectoryCB,
DirectoryCB,
&uniParentPath,
- NULL,
+ pCcb->NameArray,
&pCcb->AuthGroup,
&stFileInfo)))
{
if( NT_SUCCESS( AFSRetrieveFileAttributes( pParentDirectoryCB,
DirectoryCB,
&uniParentPath,
- NULL,
+ pCcb->NameArray,
&pCcb->AuthGroup,
&stFileInfo)))
{
if( BooleanFlagOn( DirectoryCB->ObjectInformation->FileAttributes, FILE_ATTRIBUTE_REPARSE_POINT))
{
- Buffer->ReparseTag = IO_REPARSE_TAG_OPENAFS_DFS;
+ Buffer->ReparseTag = IO_REPARSE_TAG_SURROGATE|IO_REPARSE_TAG_OPENAFS_DFS;
}
*Length -= sizeof( FILE_ATTRIBUTE_TAG_INFORMATION);
try_return( ntStatus = STATUS_DIRECTORY_NOT_EMPTY);
}
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSSetDispositionInfo Setting PENDING_DELETE on DirEntry %p Name %wZ\n",
+ DirectoryCB,
+ &DirectoryCB->NameInformation.FileName);
+
+ SetFlag( pCcb->DirectoryCB->Flags, AFS_DIR_ENTRY_PENDING_DELETE);
}
- else
+ else if( pFcb->Header.NodeTypeCode == AFS_FILE_FCB)
{
//
}
//
+ // Set PENDING_DELETE before CcPurgeCacheSection to avoid a
+ // deadlock with Trend Micro's Enterprise anti-virus product
+ // which attempts to open the file which is being deleted.
+ //
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSSetDispositionInfo Setting PENDING_DELETE on DirEntry %p Name %wZ\n",
+ DirectoryCB,
+ &DirectoryCB->NameInformation.FileName);
+
+ SetFlag( pCcb->DirectoryCB->Flags, AFS_DIR_ENTRY_PENDING_DELETE);
+
+ //
// Purge the cache as well
//
TRUE);
}
}
-
- AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSSetDispositionInfo Setting PENDING_DELETE on DirEntry %p Name %wZ\n",
- DirectoryCB,
- &DirectoryCB->NameInformation.FileName);
-
- SetFlag( pCcb->DirectoryCB->Flags, AFS_DIR_ENTRY_PENDING_DELETE);
}
else
{
BOOLEAN bReleaseTargetDirLock = FALSE;
BOOLEAN bReleaseSourceDirLock = FALSE;
PERESOURCE pSourceDirLock = NULL;
+ LONG lCount;
__Enter
{
pSrcCcb = (AFSCcb *)pSrcFileObj->FsContext2;
pSrcObject = pSrcFcb->ObjectInformation;
+ pSrcParentObject = pSrcFcb->ObjectInformation->ParentObjectInformation;
//
// Perform some basic checks to ensure FS integrity
try_return( ntStatus = STATUS_ACCESS_DENIED);
}
}
- else
- {
- if( pSrcFcb->OpenHandleCount > 1)
- {
+ //
+ // Extract off the final component name from the Fcb
+ //
- AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
- AFS_TRACE_LEVEL_ERROR,
- "AFSSetRenameInfo Attempt to rename directory with open references %wZ\n",
- &pSrcCcb->DirectoryCB->NameInformation.FileName);
+ uniSourceName.Length = (USHORT)pSrcCcb->DirectoryCB->NameInformation.FileName.Length;
+ uniSourceName.MaximumLength = uniSourceName.Length;
- try_return( ntStatus = STATUS_ACCESS_DENIED);
- }
- }
+ uniSourceName.Buffer = pSrcCcb->DirectoryCB->NameInformation.FileName.Buffer;
//
// Resolve the target fileobject
pRenameInfo = (PFILE_RENAME_INFORMATION)Irp->AssociatedIrp.SystemBuffer;
- pTargetParentObject = pSrcFcb->ObjectInformation->ParentObjectInformation;
+ pTargetParentObject = pSrcParentObject;
pTargetDcb = pTargetParentObject->Fcb;
}
//
+ // The quick check to see if they are not really performing a rename
+ // Do the names match? Only do this where the parent directories are
+ // the same
+ //
+
+ if( pTargetParentObject == pSrcParentObject)
+ {
+
+ if( FsRtlAreNamesEqual( &uniTargetName,
+ &uniSourceName,
+ FALSE,
+ NULL))
+ {
+ try_return( ntStatus = STATUS_SUCCESS);
+ }
+
+ bCommonParent = TRUE;
+ }
+ else
+ {
+
+ bCommonParent = FALSE;
+ }
+
+ //
// We do not allow cross-volume renames to occur
//
bReleaseTargetDirLock = TRUE;
- if( pTargetParentObject != pSrcFcb->ObjectInformation->ParentObjectInformation)
+ if( pTargetParentObject != pSrcParentObject)
{
AFSAcquireExcl( pSrcFcb->ObjectInformation->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock,
TRUE);
ASSERT( pTargetParentObject == pTargetDirEntry->ObjectInformation->ParentObjectInformation);
- InterlockedIncrement( &pTargetDirEntry->OpenReferenceCount);
+ lCount = InterlockedIncrement( &pTargetDirEntry->OpenReferenceCount);
if( !bReplaceIfExists)
{
}
//
- // Extract off the final component name from the Fcb
- //
-
- uniSourceName.Length = (USHORT)pSrcCcb->DirectoryCB->NameInformation.FileName.Length;
- uniSourceName.MaximumLength = uniSourceName.Length;
-
- uniSourceName.Buffer = pSrcCcb->DirectoryCB->NameInformation.FileName.Buffer;
-
- //
- // The quick check to see if they are not really performing a rename
- // Do the names match? Only do this where the parent directories are
- // the same
- //
-
- if( pTargetParentObject == pSrcFcb->ObjectInformation->ParentObjectInformation)
- {
-
- bCommonParent = TRUE;
-
- if( FsRtlAreNamesEqual( &uniTargetName,
- &uniSourceName,
- FALSE,
- NULL))
- {
- try_return( ntStatus = STATUS_SUCCESS);
- }
- }
- else
- {
-
- bCommonParent = FALSE;
- }
-
- //
// We need to remove the DirEntry from the parent node, update the index
// and reinsert it into the parent tree. Note that for entries with the
// same parent we do not pull the node from the enumeration list
else
{
- AFSInsertHashEntry( pSrcObject->VolumeCB->ObjectInfoTree.TreeHead,
- &pSrcObject->TreeEntry);
+ if ( !NT_SUCCESS( AFSInsertHashEntry( pSrcObject->VolumeCB->ObjectInfoTree.TreeHead,
+ &pSrcObject->TreeEntry)))
+ {
+
+ //
+ // Lost a race, an ObjectInfo object already exists for this FID.
+ // Let this copy be garbage collected.
+ //
+
+ ClearFlag( pSrcObject->Flags, AFS_OBJECT_INSERTED_HASH_TREE);
+ }
}
AFSReleaseResource( pSrcObject->VolumeCB->ObjectInfoTree.TreeLock);
if( pSrcCcb->DirectoryCB->ObjectInformation->ParentObjectInformation != pTargetParentObject)
{
- InterlockedDecrement( &pSrcCcb->DirectoryCB->ObjectInformation->ParentObjectInformation->Specific.Directory.ChildOpenHandleCount);
+ lCount = InterlockedDecrement( &pSrcCcb->DirectoryCB->ObjectInformation->ParentObjectInformation->Specific.Directory.ChildOpenHandleCount);
- InterlockedDecrement( &pSrcCcb->DirectoryCB->ObjectInformation->ParentObjectInformation->Specific.Directory.ChildOpenReferenceCount);
+ lCount = InterlockedDecrement( &pSrcCcb->DirectoryCB->ObjectInformation->ParentObjectInformation->Specific.Directory.ChildOpenReferenceCount);
- InterlockedIncrement( &pTargetParentObject->Specific.Directory.ChildOpenHandleCount);
+ lCount = InterlockedIncrement( &pTargetParentObject->Specific.Directory.ChildOpenHandleCount);
- InterlockedIncrement( &pTargetParentObject->Specific.Directory.ChildOpenReferenceCount);
+ lCount = InterlockedIncrement( &pTargetParentObject->Specific.Directory.ChildOpenReferenceCount);
pSrcCcb->DirectoryCB->ObjectInformation->ParentObjectInformation = pTargetParentObject;
ASSERT( pTargetDirEntry->OpenReferenceCount > 0);
- InterlockedDecrement( &pTargetDirEntry->OpenReferenceCount); // The count we added above
+ lCount = InterlockedDecrement( &pTargetDirEntry->OpenReferenceCount); // The count we added above
- if( pTargetDirEntry->OpenReferenceCount == 0)
+ if( lCount == 0)
{
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
if( pTargetDirEntry != NULL)
{
- InterlockedDecrement( &pTargetDirEntry->OpenReferenceCount);
+ lCount = InterlockedDecrement( &pTargetDirEntry->OpenReferenceCount);
}
if( bReleaseTargetDirLock)
pBasic->LastAccessTime.QuadPart = 0;
pBasic->ChangeTime.QuadPart = 0;
pBasic->LastWriteTime.QuadPart = 0;
- pBasic->FileAttributes = FILE_ATTRIBUTE_SYSTEM;
+ pBasic->FileAttributes = FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM;
*Length -= sizeof( FILE_BASIC_INFORMATION);
}