break;
}
+ case FileNormalizedNameInformation:
case FileNameInformation:
{
}
}
}
- __except( AFSExceptionFilter( GetExceptionCode(), GetExceptionInformation()) )
+ __except( AFSExceptionFilter( __FUNCTION__, GetExceptionCode(), GetExceptionInformation()) )
{
AFSDbgLogMsg( 0,
0,
"EXCEPTION - AFSQueryFileInfo\n");
+ AFSDumpTraceFilesFnc();
+
ntStatus = STATUS_UNSUCCESSFUL;
if( bReleaseMain)
}
}
}
- __except( AFSExceptionFilter( GetExceptionCode(), GetExceptionInformation()) )
+ __except( AFSExceptionFilter( __FUNCTION__, GetExceptionCode(), GetExceptionInformation()) )
{
AFSDbgLogMsg( 0,
0,
"EXCEPTION - AFSSetFileInfo\n");
+ AFSDumpTraceFilesFnc();
+
ntStatus = STATUS_UNSUCCESSFUL;
+
+ if( bReleaseMain)
+ {
+
+ AFSReleaseResource( &pFcb->NPFcb->Resource);
+ }
}
AFSCompleteRequest( Irp,
if( NT_SUCCESS( AFSRetrieveFileAttributes( pParentDirectoryCB,
DirectoryCB,
&uniParentPath,
- NULL,
+ pCcb->NameArray,
&pCcb->AuthGroup,
&stFileInfo)))
{
- ulFileAttribs = stFileInfo.FileAttributes;
- ulFileAttribs |= FILE_ATTRIBUTE_REPARSE_POINT;
+ if ( ulFileAttribs == FILE_ATTRIBUTE_NORMAL)
+ {
+
+ ulFileAttribs = FILE_ATTRIBUTE_REPARSE_POINT;
+ }
+ else
+ {
+
+ ulFileAttribs |= FILE_ATTRIBUTE_REPARSE_POINT;
+ }
+
+ if ( stFileInfo.FileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ {
+
+ ulFileAttribs |= FILE_ATTRIBUTE_DIRECTORY;
+ }
}
AFSAcquireShared( &pFcb->NPFcb->Resource,
if( NT_SUCCESS( AFSRetrieveFileAttributes( pParentDirectoryCB,
DirectoryCB,
&uniParentPath,
- NULL,
+ pCcb->NameArray,
&pCcb->AuthGroup,
&stFileInfo)))
{
- ulFileAttribs = stFileInfo.FileAttributes;
+
+ if ( ulFileAttribs == FILE_ATTRIBUTE_NORMAL)
+ {
+
+ ulFileAttribs = FILE_ATTRIBUTE_REPARSE_POINT;
+ }
+ else
+ {
+
+ ulFileAttribs |= FILE_ATTRIBUTE_REPARSE_POINT;
+ }
+
+ if ( stFileInfo.FileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ {
+
+ ulFileAttribs |= FILE_ATTRIBUTE_DIRECTORY;
+ }
}
AFSAcquireShared( &pFcb->NPFcb->Resource,
if( NT_SUCCESS( AFSRetrieveFileAttributes( pParentDirectoryCB,
DirectoryCB,
&uniParentPath,
- NULL,
+ pCcb->NameArray,
&pCcb->AuthGroup,
&stFileInfo)))
{
- ulFileAttribs = stFileInfo.FileAttributes;
- ulFileAttribs |= FILE_ATTRIBUTE_REPARSE_POINT;
+ if ( ulFileAttribs == FILE_ATTRIBUTE_NORMAL)
+ {
+
+ ulFileAttribs = FILE_ATTRIBUTE_REPARSE_POINT;
+ }
+ else
+ {
+
+ ulFileAttribs |= FILE_ATTRIBUTE_REPARSE_POINT;
+ }
+
+ if ( stFileInfo.FileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ {
+
+ ulFileAttribs |= FILE_ATTRIBUTE_DIRECTORY;
+ }
}
AFSAcquireShared( &pFcb->NPFcb->Resource,
if( NT_SUCCESS( AFSRetrieveFileAttributes( pParentDirectoryCB,
DirectoryCB,
&uniParentPath,
- NULL,
+ pCcb->NameArray,
&pCcb->AuthGroup,
&stFileInfo)))
{
- ulFileAttribs = stFileInfo.FileAttributes;
- ulFileAttribs |= FILE_ATTRIBUTE_REPARSE_POINT;
+ if ( ulFileAttribs == FILE_ATTRIBUTE_NORMAL)
+ {
+
+ ulFileAttribs = FILE_ATTRIBUTE_REPARSE_POINT;
+ }
+ else
+ {
+
+ ulFileAttribs |= FILE_ATTRIBUTE_REPARSE_POINT;
+ }
+
+ if ( stFileInfo.FileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ {
+
+ ulFileAttribs |= FILE_ATTRIBUTE_DIRECTORY;
+ }
}
AFSAcquireShared( &pFcb->NPFcb->Resource,
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 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
//
if( pFcb->NPFcb->SectionObjectPointers.DataSectionObject != NULL)
{
- CcPurgeCacheSection( &pFcb->NPFcb->SectionObjectPointers,
- NULL,
- 0,
- TRUE);
+ if ( !CcPurgeCacheSection( &pFcb->NPFcb->SectionObjectPointers,
+ NULL,
+ 0,
+ TRUE))
+ {
+
+ SetFlag( pFcb->Flags, AFS_FCB_FLAG_PURGE_ON_CLOSE);
+ }
}
}
-
- 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
{
{
NTSTATUS ntStatus = STATUS_SUCCESS;
+ AFSDeviceExt *pDeviceExt = (AFSDeviceExt *)AFSRDRDeviceObject->DeviceExtension;
PIO_STACK_LOCATION pIrpSp = IoGetCurrentIrpStackLocation( Irp);
IO_STATUS_BLOCK stIoSb = {0,0};
AFSFcb *pSrcFcb = NULL, *pTargetDcb = NULL, *pTargetFcb = NULL;
AFSCcb *pSrcCcb = NULL, *pTargetDirCcb = NULL;
PFILE_OBJECT pSrcFileObj = pIrpSp->FileObject;
PFILE_OBJECT pTargetFileObj = pIrpSp->Parameters.SetFile.FileObject;
+ PFILE_OBJECT pTargetParentFileObj = NULL;
PFILE_RENAME_INFORMATION pRenameInfo = NULL;
- UNICODE_STRING uniTargetName, uniSourceName;
+ UNICODE_STRING uniTargetName, uniSourceName, uniTargetParentName;
BOOLEAN bReplaceIfExists = FALSE;
UNICODE_STRING uniShortName;
AFSDirectoryCB *pTargetDirEntry = NULL;
AFSObjectInfoCB *pSrcParentObject = NULL, *pTargetParentObject = NULL;
AFSFileID stNewFid, stTmpTargetFid;
ULONG ulNotificationAction = 0, ulNotifyFilter = 0;
- UNICODE_STRING uniFullTargetPath;
+ UNICODE_STRING uniFullTargetName;
BOOLEAN bCommonParent = FALSE;
BOOLEAN bReleaseTargetDirLock = FALSE;
BOOLEAN bReleaseSourceDirLock = FALSE;
+ BOOLEAN bDereferenceTargetParentObject = FALSE;
PERESOURCE pSourceDirLock = NULL;
LONG lCount;
if( pTargetFileObj == NULL)
{
- //
- // This is a simple rename. Here the target directory is the same as the source parent directory
- // and the name is retrieved from the system buffer information
- //
-
pRenameInfo = (PFILE_RENAME_INFORMATION)Irp->AssociatedIrp.SystemBuffer;
- pTargetParentObject = pSrcParentObject;
+ if ( pRenameInfo->RootDirectory)
+ {
- pTargetDcb = pTargetParentObject->Fcb;
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_ERROR,
+ "AFSSetRenameInfo Handle provided but no FileObject ntStatus INVALID_PARAMETER\n");
- uniTargetName.Length = (USHORT)pRenameInfo->FileNameLength;
- uniTargetName.Buffer = (PWSTR)&pRenameInfo->FileName;
+ try_return( ntStatus = STATUS_INVALID_PARAMETER);
+ }
+ else
+ {
+
+ uniFullTargetName.Length = (USHORT)pRenameInfo->FileNameLength;
+
+ uniFullTargetName.Buffer = (PWSTR)&pRenameInfo->FileName;
+
+ AFSRetrieveFinalComponent( &uniFullTargetName,
+ &uniTargetName);
+
+ AFSRetrieveParentPath( &uniFullTargetName,
+ &uniTargetParentName);
+
+ if ( uniTargetParentName.Length == 0)
+ {
+
+ //
+ // This is a simple rename. Here the target directory is the same as the source parent directory
+ // and the name is retrieved from the system buffer information
+ //
+
+ pTargetParentObject = pSrcParentObject;
+ }
+ else
+ {
+ //
+ // uniTargetParentName contains the directory the renamed object
+ // will be moved to. Must obtain the TargetParentObject.
+ //
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_ERROR,
+ "AFSSetRenameInfo Attempt to move %wZ to %wZ -- not yet supported (NOT_SAME_DEVICE)\n",
+ &pSrcCcb->DirectoryCB->NameInformation.FileName,
+ &uniFullTargetName);
+
+ try_return( ntStatus = STATUS_NOT_SAME_DEVICE);
+ }
+ }
+
+ pTargetDcb = pTargetParentObject->Fcb;
}
else
{
if( pTargetParentObject != pSrcParentObject)
{
- AFSAcquireExcl( pSrcFcb->ObjectInformation->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock,
+ AFSAcquireExcl( pSrcParentObject->Specific.Directory.DirectoryNodeHdr.TreeLock,
TRUE);
bReleaseSourceDirLock = TRUE;
- pSourceDirLock = pSrcFcb->ObjectInformation->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock;
+ pSourceDirLock = pSrcParentObject->Specific.Directory.DirectoryNodeHdr.TreeLock;
}
AFSLocateCaseSensitiveDirEntry( pTargetParentObject->Specific.Directory.DirectoryNodeHdr.CaseSensitiveTreeHead,
&pTargetDirEntry);
}
- if( pTargetDirEntry == NULL && RtlIsNameLegalDOS8Dot3( &uniTargetName,
+ if ( !BooleanFlagOn( pDeviceExt->DeviceFlags, AFS_DEVICE_FLAG_DISABLE_SHORTNAMES) &&
+ pTargetDirEntry == NULL && RtlIsNameLegalDOS8Dot3( &uniTargetName,
NULL,
NULL))
{
pSrcCcb->DirectoryCB->CaseInsensitiveTreeEntry.HashIndex = AFSGenerateCRC( &pSrcCcb->DirectoryCB->NameInformation.FileName,
TRUE);
- if( pSrcCcb->DirectoryCB->NameInformation.ShortNameLength > 0 &&
+ if( !BooleanFlagOn( pDeviceExt->DeviceFlags, AFS_DEVICE_FLAG_DISABLE_SHORTNAMES) &&
+ pSrcCcb->DirectoryCB->NameInformation.ShortNameLength > 0 &&
!RtlIsNameLegalDOS8Dot3( &pSrcCcb->DirectoryCB->NameInformation.FileName,
NULL,
NULL))
}
}
+ if ( bDereferenceTargetParentObject)
+ {
+
+ ObDereferenceObject( pTargetParentFileObj);
+ }
+
return ntStatus;
}
//
// If this is a truncation we need to grab the paging IO resource.
//
+
AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSSetAllocationInfo Acquiring Fcb PagingIo lock %08lX EXCL %08lX\n",
bReleasePaging = TRUE;
+ //
+ // Must drop the Fcb Resource. When changing the file size
+ // a deadlock can occur with Trend Micro's filter if the file
+ // size is set to zero.
+ //
+
+ AFSReleaseResource( &pFcb->NPFcb->Resource);
pFcb->Header.AllocationSize = pBuffer->AllocationSize;
//
// Tell Cc if allocation is increased.
//
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSSetAllocationInfo Acquiring Fcb PagingIo lock %08lX EXCL %08lX\n",
+ &pFcb->NPFcb->PagingResource,
+ PsGetCurrentThread());
+
+ AFSAcquireExcl( &pFcb->NPFcb->PagingResource,
+ TRUE);
+
+ bReleasePaging = TRUE;
+
+ //
+ // Must drop the Fcb Resource. When changing the file size
+ // a deadlock can occur with Trend Micro's filter if the file
+ // size is set to zero.
+ //
+
+ AFSReleaseResource( &pFcb->NPFcb->Resource);
+
bTellCc = pBuffer->AllocationSize.QuadPart > pFcb->Header.AllocationSize.QuadPart;
pFcb->Header.AllocationSize = pBuffer->AllocationSize;
{
AFSReleaseResource( &pFcb->NPFcb->PagingResource);
+
+ AFSAcquireExcl( &pFcb->NPFcb->Resource,
+ TRUE);
}
return ntStatus;
}
else
{
+
//
// If this is a truncation we need to grab the paging
// IO resource.
bReleasePaging = TRUE;
+ //
+ // Must drop the Fcb Resource. When changing the file size
+ // a deadlock can occur with Trend Micro's filter if the file
+ // size is set to zero.
+ //
+
+ AFSReleaseResource( &pFcb->NPFcb->Resource);
+
pFcb->Header.AllocationSize = pBuffer->EndOfFile;
pFcb->Header.FileSize = pBuffer->EndOfFile;
}
else
{
+
//
// extending the file, move EOF
//
+ //
+ // If this is a truncation we need to grab the paging
+ // IO resource.
+ //
+ AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSSetAllocationInfo Acquiring Fcb PagingIo lock %08lX EXCL %08lX\n",
+ &pFcb->NPFcb->PagingResource,
+ PsGetCurrentThread());
+
+ AFSAcquireExcl( &pFcb->NPFcb->PagingResource,
+ TRUE);
+
+ bReleasePaging = TRUE;
+
+ //
+ // Must drop the Fcb Resource. When changing the file size
+ // a deadlock can occur with Trend Micro's filter if the file
+ // size is set to zero.
+ //
+
+ AFSReleaseResource( &pFcb->NPFcb->Resource);
+
pFcb->Header.FileSize = pBuffer->EndOfFile;
pFcb->ObjectInformation->EndOfFile = pBuffer->EndOfFile;
{
AFSReleaseResource( &pFcb->NPFcb->PagingResource);
+
+ AFSAcquireExcl( &pFcb->NPFcb->Resource,
+ TRUE);
}
return ntStatus;
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);
}
break;
}
+ case FileNormalizedNameInformation:
case FileNameInformation:
{