AFSCreate( IN PDEVICE_OBJECT LibDeviceObject,
IN PIRP Irp)
{
-
+ UNREFERENCED_PARAMETER(LibDeviceObject);
NTSTATUS ntStatus = STATUS_SUCCESS;
IO_STACK_LOCATION *pIrpSp;
FILE_OBJECT *pFileObject = NULL;
NOTHING;
}
- __except( AFSExceptionFilter( GetExceptionCode(), GetExceptionInformation()) )
+ __except( AFSExceptionFilter( __FUNCTION__, GetExceptionCode(), GetExceptionInformation()) )
{
AFSDbgLogMsg( 0,
"EXCEPTION - AFSCreate\n");
ntStatus = STATUS_ACCESS_DENIED;
+
+ AFSDumpTraceFilesFnc();
}
//
AFSDeviceExt *pDeviceExt = NULL;
BOOLEAN bOpenTargetDirectory = FALSE, bReleaseVolume = FALSE;
PACCESS_MASK pDesiredAccess = NULL;
- UNICODE_STRING uniComponentName, uniPathName, uniRootFileName, uniParsedFileName;
+ UNICODE_STRING uniComponentName, uniRootFileName, uniParsedFileName;
UNICODE_STRING uniSubstitutedPathName;
UNICODE_STRING uniRelativeName;
AFSNameArrayHdr *pNameArray = NULL;
AFSVolumeCB *pVolumeCB = NULL;
AFSDirectoryCB *pParentDirectoryCB = NULL, *pDirectoryCB = NULL;
ULONG ulParseFlags = 0;
- GUID stAuthGroup;
+ GUID stAuthGroup = {0};
ULONG ulNameProcessingFlags = 0;
BOOLEAN bOpenedReparsePoint = FALSE;
LONG lCount;
"AFSCommonCreate Failed to open root Status %08lX\n",
ntStatus);
- lCount = InterlockedDecrement( &AFSGlobalRoot->DirectoryCB->OpenReferenceCount);
+ lCount = InterlockedDecrement( &AFSGlobalRoot->DirectoryCB->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
AFSGlobalRoot->DirectoryCB,
NULL,
lCount);
+
+ ASSERT( lCount >= 0);
}
try_return( ntStatus);
// Perform in this order to prevent thrashing
//
- lCount = InterlockedIncrement( &pParentDirectoryCB->OpenReferenceCount);
+ lCount = InterlockedIncrement( &pParentDirectoryCB->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
//
// It is now safe to drop the Reference Count
//
- lCount = InterlockedDecrement( &pDirectoryCB->OpenReferenceCount);
+ lCount = InterlockedDecrement( &pDirectoryCB->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
pDirectoryCB,
NULL,
lCount);
+
+ ASSERT( lCount >= 0);
}
if( !NT_SUCCESS( ntStatus))
// Decrement the reference on the parent
//
- lCount = InterlockedDecrement( &pParentDirectoryCB->OpenReferenceCount);
+ lCount = InterlockedDecrement( &pParentDirectoryCB->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
pParentDirectoryCB,
NULL,
lCount);
+
+ ASSERT( lCount >= 0);
}
try_return( ntStatus);
&pDirectoryCB->NameInformation.FileName,
ntStatus);
- lCount = InterlockedDecrement( &pDirectoryCB->OpenReferenceCount);
+ lCount = InterlockedDecrement( &pDirectoryCB->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
pDirectoryCB,
NULL,
lCount);
+
+ ASSERT( lCount >= 0);
}
else
{
"AFSCommonCreate Object name collision on create Status %08lX\n",
ntStatus);
- InterlockedDecrement( &pParentDirectoryCB->OpenReferenceCount);
+ lCount = InterlockedDecrement( &pParentDirectoryCB->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
&pParentDirectoryCB->NameInformation.FileName,
pParentDirectoryCB,
NULL,
- pParentDirectoryCB->OpenReferenceCount);
+ lCount);
+
+ ASSERT( lCount >= 0);
}
try_return( ntStatus = STATUS_OBJECT_NAME_COLLISION);
// Dereference the parent entry
//
- lCount = InterlockedDecrement( &pParentDirectoryCB->OpenReferenceCount);
+ lCount = InterlockedDecrement( &pParentDirectoryCB->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
NULL,
lCount);
+ ASSERT( lCount >= 0);
+
try_return( ntStatus);
}
if( pDirectoryCB != NULL)
{
- lCount = InterlockedDecrement( &pDirectoryCB->OpenReferenceCount);
+ lCount = InterlockedDecrement( &pDirectoryCB->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
pDirectoryCB,
NULL,
lCount);
+
+ ASSERT( lCount >= 0);
}
else
{
- lCount = InterlockedDecrement( &pParentDirectoryCB->OpenReferenceCount);
+ lCount = InterlockedDecrement( &pParentDirectoryCB->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
pParentDirectoryCB,
NULL,
lCount);
+
+ ASSERT( lCount >= 0);
}
}
"AFSCommonCreate (%08lX) Attempt to open root as delete on close\n",
Irp);
- lCount = InterlockedDecrement( &pDirectoryCB->OpenReferenceCount);
+ lCount = InterlockedDecrement( &pDirectoryCB->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
NULL,
lCount);
+ ASSERT( lCount >= 0);
+
try_return( ntStatus = STATUS_CANNOT_DELETE);
}
"AFSCommonCreate (%08lX) Attempt to open root as target directory\n",
Irp);
- lCount = InterlockedDecrement( &pDirectoryCB->OpenReferenceCount);
+ lCount = InterlockedDecrement( &pDirectoryCB->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
NULL,
lCount);
+ ASSERT( lCount >= 0);
+
try_return( ntStatus = STATUS_INVALID_PARAMETER);
}
pVolumeCB->ObjectInformation.FileId.Volume,
ntStatus);
- lCount = InterlockedDecrement( &pDirectoryCB->OpenReferenceCount);
+ lCount = InterlockedDecrement( &pDirectoryCB->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
pDirectoryCB,
NULL,
lCount);
+
+ ASSERT( lCount >= 0);
}
try_return( ntStatus);
&pDirectoryCB->NameInformation.FileName,
ntStatus);
- lCount = InterlockedDecrement( &pDirectoryCB->OpenReferenceCount);
+ lCount = InterlockedDecrement( &pDirectoryCB->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
pDirectoryCB,
NULL,
lCount);
+
+ ASSERT( lCount >= 0);
}
try_return( ntStatus);
&pDirectoryCB->NameInformation.FileName,
ntStatus);
- lCount = InterlockedDecrement( &pDirectoryCB->OpenReferenceCount);
+ lCount = InterlockedDecrement( &pDirectoryCB->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
pDirectoryCB,
NULL,
lCount);
+
+ ASSERT( lCount >= 0);
}
try_exit:
if( pCcb != NULL)
{
+ AFSAcquireExcl( &pCcb->NPCcb->CcbLock,
+ TRUE);
+
RtlCopyMemory( &pCcb->AuthGroup,
&stAuthGroup,
sizeof( GUID));
&pCcb->DirectoryCB->NameInformation.FileName,
pCcb->DirectoryCB,
pCcb,
- pCcb->DirectoryCB->OpenReferenceCount);
+ lCount = pCcb->DirectoryCB->DirOpenReferenceCount);
- ASSERT( pCcb->DirectoryCB->OpenReferenceCount > 0);
+ ASSERT( lCount >= 0);
pCcb->CurrentDirIndex = 0;
pCcb->NameArray = pNameArray;
pNameArray = NULL;
+
+ AFSReleaseResource( &pCcb->NPCcb->CcbLock);
}
//
// For files perform additional processing
//
- if( pFcb->Header.NodeTypeCode == AFS_FILE_FCB)
+ switch( pFcb->Header.NodeTypeCode)
{
- pFileObject->SectionObjectPointer = &pFcb->NPFcb->SectionObjectPointers;
+
+ case AFS_FILE_FCB:
+ case AFS_IOCTL_FCB:
+ {
+
+ pFileObject->SectionObjectPointer = &pFcb->NPFcb->SectionObjectPointers;
+ }
}
//
if( uniSubstitutedPathName.Buffer != NULL)
{
- AFSExFreePool( uniSubstitutedPathName.Buffer);
+ AFSExFreePoolWithTag( uniSubstitutedPathName.Buffer, 0);
ClearFlag( ulParseFlags, AFS_PARSE_FLAG_FREE_FILE_BUFFER);
}
if( BooleanFlagOn( ulParseFlags, AFS_PARSE_FLAG_FREE_FILE_BUFFER))
{
- AFSExFreePool( uniRootFileName.Buffer);
+ AFSExFreePoolWithTag( uniRootFileName.Buffer, 0);
}
if( bReleaseVolume)
ntStatus = AFSValidateEntry( VolumeCB->DirectoryCB,
AuthGroup,
- FALSE);
+ FALSE,
+ TRUE);
if( !NT_SUCCESS( ntStatus))
{
PFILE_OBJECT pFileObject = NULL;
PIO_STACK_LOCATION pIrpSp = IoGetCurrentIrpStackLocation( Irp);
ULONG ulOptions = 0;
- ULONG ulShareMode = 0;
- ULONG ulAccess = 0;
ULONG ulAttributes = 0;
- LARGE_INTEGER liAllocationSize = {0,0};
BOOLEAN bFileCreated = FALSE, bReleaseFcb = FALSE, bAllocatedCcb = FALSE;
- BOOLEAN bAllocatedFcb = FALSE;
PACCESS_MASK pDesiredAccess = NULL;
USHORT usShareAccess;
AFSDirectoryCB *pDirEntry = NULL;
// We may have raced and the Fcb is already created
//
- if( pObjectInfo->Fcb != NULL)
- {
+ //
+ // Allocate and initialize the Fcb for the file.
+ //
- AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSProcessCreate (%08lX) Not allocating Fcb for file %wZ\n",
- Irp,
- FullFileName);
+ ntStatus = AFSInitFcb( pDirEntry);
- *Fcb = pObjectInfo->Fcb;
+ *Fcb = pObjectInfo->Fcb;
- AFSAcquireExcl( &(*Fcb)->NPFcb->Resource,
- TRUE);
- }
- else
+ if( !NT_SUCCESS( ntStatus))
{
- //
- // Allocate and initialize the Fcb for the file.
- //
-
- ntStatus = AFSInitFcb( pDirEntry);
-
- *Fcb = pObjectInfo->Fcb;
-
- if( !NT_SUCCESS( ntStatus))
- {
-
- AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
- AFS_TRACE_LEVEL_ERROR,
- "AFSProcessCreate (%08lX) Failed to initialize fcb %wZ Status %08lX\n",
- Irp,
- FullFileName,
- ntStatus);
-
- try_return( ntStatus);
- }
-
- if ( ntStatus != STATUS_REPARSE)
- {
-
- bAllocatedFcb = TRUE;
- }
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_ERROR,
+ "AFSProcessCreate (%08lX) Failed to initialize fcb %wZ Status %08lX\n",
+ Irp,
+ FullFileName,
+ ntStatus);
- ntStatus = STATUS_SUCCESS;
+ try_return( ntStatus);
}
+ ntStatus = STATUS_SUCCESS;
+
//
// Increment the open count on this Fcb
//
// Decrement the reference added during initialization of the DE
//
- lCount = InterlockedDecrement( &pDirEntry->OpenReferenceCount);
+ lCount = InterlockedDecrement( &pDirEntry->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
pDirEntry,
lCount);
+ ASSERT( lCount >= 0);
+
//
// Pull the directory entry from the parent
//
*Ccb);
}
- if( bAllocatedFcb)
- {
-
- AFSRemoveFcb( &pObjectInfo->Fcb);
- }
+ //
+ // Fcb will be freed by AFSPrimaryVolumeWorker thread
+ //
*Fcb = NULL;
OUT AFSFcb **Fcb,
OUT AFSCcb **Ccb)
{
-
+ UNREFERENCED_PARAMETER(VolumeCB);
NTSTATUS ntStatus = STATUS_SUCCESS;
PFILE_OBJECT pFileObject = NULL;
PIO_STACK_LOCATION pIrpSp = IoGetCurrentIrpStackLocation( Irp);
PACCESS_MASK pDesiredAccess = NULL;
USHORT usShareAccess;
BOOLEAN bAllocatedCcb = FALSE;
- BOOLEAN bReleaseFcb = FALSE, bAllocatedFcb = FALSE;
- AFSObjectInfoCB *pParentObject = NULL, *pTargetObject = NULL;
+ BOOLEAN bReleaseFcb = FALSE;
+ AFSObjectInfoCB *pParentObject = NULL;
UNICODE_STRING uniTargetName;
LONG lCount;
//
// Make sure we have an Fcb for the access
+
+ //
+ // Allocate and initialize the Fcb for the file.
//
- if( pParentObject->Fcb != NULL)
- {
+ ntStatus = AFSInitFcb( ParentDirectoryCB);
- *Fcb = pParentObject->Fcb;
+ *Fcb = pParentObject->Fcb;
- AFSAcquireExcl( &(*Fcb)->NPFcb->Resource,
- TRUE);
- }
- else
+ if( !NT_SUCCESS( ntStatus))
{
- //
- // Allocate and initialize the Fcb for the file.
- //
-
- ntStatus = AFSInitFcb( ParentDirectoryCB);
-
- *Fcb = pParentObject->Fcb;
-
- if( !NT_SUCCESS( ntStatus))
- {
-
- AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
- AFS_TRACE_LEVEL_ERROR,
- "AFSProcessCreate (%08lX) Failed to initialize fcb %wZ Status %08lX\n",
- Irp,
- &ParentDirectoryCB->NameInformation.FileName,
- ntStatus);
-
- try_return( ntStatus);
- }
-
- if ( ntStatus == STATUS_REPARSE)
- {
-
- bAllocatedFcb = TRUE;
- }
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_ERROR,
+ "AFSOpenTargetDirectory (%08lX) Failed to initialize fcb %wZ Status %08lX\n",
+ Irp,
+ &ParentDirectoryCB->NameInformation.FileName,
+ ntStatus);
- ntStatus = STATUS_SUCCESS;
+ try_return( ntStatus);
}
+ ntStatus = STATUS_SUCCESS;
+
//
// Increment the open count on this Fcb
//
*Ccb = NULL;
- if( bAllocatedFcb)
- {
-
- AFSRemoveFcb( &pParentObject->Fcb);
- }
+ //
+ // Fcb will be freed by AFSPrimaryVolumeWorker thread
+ //
*Fcb = NULL;
}
OUT AFSFcb **Fcb,
OUT AFSCcb **Ccb)
{
-
+ UNREFERENCED_PARAMETER(VolumeCB);
NTSTATUS ntStatus = STATUS_SUCCESS;
PFILE_OBJECT pFileObject = NULL;
PIO_STACK_LOCATION pIrpSp = IoGetCurrentIrpStackLocation( Irp);
PACCESS_MASK pDesiredAccess = NULL;
USHORT usShareAccess;
- BOOLEAN bAllocatedCcb = FALSE, bReleaseFcb = FALSE, bAllocatedFcb = FALSE;
- ULONG ulAdditionalFlags = 0, ulOptions = 0;
+ BOOLEAN bAllocatedCcb = FALSE, bReleaseFcb = FALSE;
+ ULONG ulOptions = 0;
AFSFileOpenCB stOpenCB;
AFSFileOpenResultCB stOpenResultCB;
ULONG ulResultLen = 0;
ntStatus = AFSValidateEntry( DirectoryCB,
AuthGroup,
- FALSE);
+ FALSE,
+ TRUE);
if( !NT_SUCCESS( ntStatus))
{
// Be sure we have an Fcb for the current object
//
- if( pObjectInfo->Fcb == NULL)
- {
-
- ntStatus = AFSInitFcb( DirectoryCB);
-
- if( !NT_SUCCESS( ntStatus))
- {
+ ntStatus = AFSInitFcb( DirectoryCB);
- AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
- AFS_TRACE_LEVEL_ERROR,
- "AFSProcessOpen (%08lX) Failed to init fcb on %wZ Status %08lX\n",
- Irp,
- &DirectoryCB->NameInformation.FileName,
- ntStatus);
+ if( !NT_SUCCESS( ntStatus))
+ {
- try_return( ntStatus);
- }
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_ERROR,
+ "AFSProcessOpen (%08lX) Failed to init fcb on %wZ Status %08lX\n",
+ Irp,
+ &DirectoryCB->NameInformation.FileName,
+ ntStatus);
- if ( ntStatus != STATUS_REPARSE)
- {
+ try_return( ntStatus);
+ }
- bAllocatedFcb = TRUE;
- }
+ ntStatus = STATUS_SUCCESS;
- ntStatus = STATUS_SUCCESS;
- }
- else
- {
+ //
+ // AFSInitFcb returns the Fcb resource held
+ //
- AFSAcquireExcl( pObjectInfo->Fcb->Header.Resource,
- TRUE);
- }
+ bReleaseFcb = TRUE;
//
// Increment the open count on this Fcb
pObjectInfo->Fcb,
lCount);
- bReleaseFcb = TRUE;
-
//
// Check access on the entry
//
BooleanFlagOn(ulOptions, FILE_DELETE_ON_CLOSE))
{
- if( !MmFlushImageSection( &pObjectInfo->Fcb->NPFcb->SectionObjectPointers,
- MmFlushForWrite))
+ BOOLEAN bMmFlushed;
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSProcessOpen Acquiring Fcb SectionObject lock %08lX EXCL %08lX\n",
+ &pObjectInfo->Fcb->NPFcb->SectionObjectResource,
+ PsGetCurrentThread());
+
+ AFSAcquireExcl( &pObjectInfo->Fcb->NPFcb->SectionObjectResource,
+ TRUE);
+
+ bMmFlushed = MmFlushImageSection( &pObjectInfo->Fcb->NPFcb->SectionObjectPointers,
+ MmFlushForWrite);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSProcessOpen Releasing Fcb SectionObject lock %08lX EXCL %08lX\n",
+ &pObjectInfo->Fcb->NPFcb->SectionObjectResource,
+ PsGetCurrentThread());
+
+ AFSReleaseResource( &pObjectInfo->Fcb->NPFcb->SectionObjectResource);
+
+ if ( !bMmFlushed)
{
ntStatus = BooleanFlagOn(ulOptions, FILE_DELETE_ON_CLOSE) ? STATUS_CANNOT_DELETE :
*Ccb = NULL;
- if( bAllocatedFcb)
- {
-
- AFSRemoveFcb( &pObjectInfo->Fcb);
- }
+ //
+ // Fcb will be freed by AFSPrimaryVolumeWorker thread
+ //
*Fcb = NULL;
}
OUT AFSFcb **Fcb,
OUT AFSCcb **Ccb)
{
-
+ UNREFERENCED_PARAMETER(DeviceObject);
NTSTATUS ntStatus = STATUS_SUCCESS;
PIO_STACK_LOCATION pIrpSp = IoGetCurrentIrpStackLocation( Irp);
PFILE_OBJECT pFileObject = NULL;
LARGE_INTEGER liZero = {0,0};
BOOLEAN bReleasePaging = FALSE, bReleaseFcb = FALSE;
ULONG ulAttributes = 0;
- LARGE_INTEGER liTime;
ULONG ulCreateDisposition = 0;
- BOOLEAN bAllocatedCcb = FALSE, bAllocatedFcb = FALSE;
+ BOOLEAN bAllocatedCcb = FALSE;
+ BOOLEAN bUserMapped = FALSE;
PACCESS_MASK pDesiredAccess = NULL;
USHORT usShareAccess;
AFSObjectInfoCB *pParentObjectInfo = NULL;
ntStatus = AFSValidateEntry( DirectoryCB,
AuthGroup,
- FALSE);
+ FALSE,
+ TRUE);
if( !NT_SUCCESS( ntStatus))
{
// Be sure we have an Fcb for the object block
//
- if( pObjectInfo->Fcb == NULL)
- {
-
- ntStatus = AFSInitFcb( DirectoryCB);
-
- *Fcb = pObjectInfo->Fcb;
+ ntStatus = AFSInitFcb( DirectoryCB);
- if( !NT_SUCCESS( ntStatus))
- {
-
- AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
- AFS_TRACE_LEVEL_ERROR,
- "AFSProcessOverwriteSupersede (%08lX) Failed to initialize fcb %wZ Status %08lX\n",
- Irp,
- &DirectoryCB->NameInformation.FileName,
- ntStatus);
-
- try_return( ntStatus);
- }
+ *Fcb = pObjectInfo->Fcb;
- if ( ntStatus != STATUS_REPARSE)
- {
+ if( !NT_SUCCESS( ntStatus))
+ {
- bAllocatedFcb = TRUE;
- }
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_ERROR,
+ "AFSProcessOverwriteSupersede (%08lX) Failed to initialize fcb %wZ Status %08lX\n",
+ Irp,
+ &DirectoryCB->NameInformation.FileName,
+ ntStatus);
- ntStatus = STATUS_SUCCESS;
+ try_return( ntStatus);
}
- else
- {
- AFSAcquireExcl( pObjectInfo->Fcb->Header.Resource,
- TRUE);
- }
+ ntStatus = STATUS_SUCCESS;
//
// Increment the open count on this Fcb.
}
}
+ AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSProcessOverwriteSupercede Acquiring Fcb SectionObject lock %08lX EXCL %08lX\n",
+ &pObjectInfo->Fcb->NPFcb->SectionObjectResource,
+ PsGetCurrentThread());
+
+ AFSAcquireExcl( &pObjectInfo->Fcb->NPFcb->SectionObjectResource,
+ TRUE);
+
//
// Before we actually truncate, check to see if the purge
// is going to fail.
//
- if( !MmCanFileBeTruncated( &pObjectInfo->Fcb->NPFcb->SectionObjectPointers,
- &liZero))
+ bUserMapped = !MmCanFileBeTruncated( &pObjectInfo->Fcb->NPFcb->SectionObjectPointers,
+ &liZero);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSProcessOverwriteSupercede Releasing Fcb SectionObject lock %08lX EXCL %08lX\n",
+ &pObjectInfo->Fcb->NPFcb->SectionObjectResource,
+ PsGetCurrentThread());
+
+ AFSReleaseResource( &pObjectInfo->Fcb->NPFcb->SectionObjectResource);
+
+ if( bUserMapped)
{
ntStatus = STATUS_USER_MAPPED_FILE;
*Ccb = NULL;
- if( bAllocatedFcb)
- {
-
- AFSRemoveFcb( &pObjectInfo->Fcb);
- }
+ //
+ // Fcb will be freed by AFSPrimaryVolumeWorker thread
+ //
*Fcb = NULL;
}
__Enter
{
- //
- // For now, jsut let the open happen
- //
-
- Irp->IoStatus.Information = FILE_OPENED;
+ if ( KernelMode == Irp->RequestorMode) {
+ //
+ // For now, just let the open happen
+ //
+ Irp->IoStatus.Information = FILE_OPENED;
+ }
+ else
+ {
+ //
+ // Not from usermode, All access must be via
+ // the FS component (which will do the
+ // security check)
+ //
+ ntStatus = STATUS_ACCESS_DENIED;
+ }
}
return ntStatus;
NTSTATUS ntStatus = STATUS_SUCCESS;
PFILE_OBJECT pFileObject = NULL;
PIO_STACK_LOCATION pIrpSp = IoGetCurrentIrpStackLocation( Irp);
- BOOLEAN bReleaseFcb = FALSE, bAllocatedCcb = FALSE, bAllocatedFcb = FALSE;
- UNICODE_STRING uniFullFileName;
+ BOOLEAN bReleaseFcb = FALSE, bAllocatedCcb = FALSE;
AFSPIOCtlOpenCloseRequestCB stPIOCtlOpen;
AFSFileID stFileID;
AFSObjectInfoCB *pParentObjectInfo = NULL;
}
}
- if( pParentObjectInfo->Specific.Directory.PIOCtlDirectoryCB->ObjectInformation->Fcb == NULL)
- {
-
- //
- // Allocate and initialize the Fcb for the file.
- //
-
- ntStatus = AFSInitFcb( pParentObjectInfo->Specific.Directory.PIOCtlDirectoryCB);
-
- *Fcb = pParentObjectInfo->Specific.Directory.PIOCtlDirectoryCB->ObjectInformation->Fcb;
-
- if( !NT_SUCCESS( ntStatus))
- {
-
- AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
- AFS_TRACE_LEVEL_ERROR,
- "AFSOpenIOCtlFcb (%08lX) Failed to initialize fcb Status %08lX\n",
- Irp,
- ntStatus);
-
- try_return( ntStatus);
- }
+ //
+ // Allocate and initialize the Fcb for the file.
+ //
- if ( ntStatus != STATUS_REPARSE)
- {
+ ntStatus = AFSInitFcb( pParentObjectInfo->Specific.Directory.PIOCtlDirectoryCB);
- bAllocatedFcb = TRUE;
- }
+ *Fcb = pParentObjectInfo->Specific.Directory.PIOCtlDirectoryCB->ObjectInformation->Fcb;
- ntStatus = STATUS_SUCCESS;
- }
- else
+ if( !NT_SUCCESS( ntStatus))
{
- *Fcb = pParentObjectInfo->Specific.Directory.PIOCtlDirectoryCB->ObjectInformation->Fcb;
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_ERROR,
+ "AFSOpenIOCtlFcb (%08lX) Failed to initialize fcb Status %08lX\n",
+ Irp,
+ ntStatus);
- AFSAcquireExcl( &(*Fcb)->NPFcb->Resource,
- TRUE);
+ try_return( ntStatus);
}
+ ntStatus = STATUS_SUCCESS;
+
//
// Increment the open reference and handle on the node
//
// Reference the directory entry
//
- lCount = InterlockedIncrement( &((*Ccb)->DirectoryCB->OpenReferenceCount));
+ lCount = InterlockedIncrement( &((*Ccb)->DirectoryCB->DirOpenReferenceCount));
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
// is already referenced
//
- lCount = InterlockedDecrement( &ParentDirCB->OpenReferenceCount);
+ lCount = InterlockedDecrement( &ParentDirCB->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
NULL,
lCount);
+ ASSERT( lCount >= 0);
+
//
// If we created the Fcb we need to release the resources
//
*Ccb = NULL;
- if( bAllocatedFcb)
- {
-
- //
- // Need to tear down this Fcb since it is not in the tree for the worker thread
- //
-
- AFSRemoveFcb( &pParentObjectInfo->Specific.Directory.PIOCtlDirectoryCB->ObjectInformation->Fcb);
- }
+ //
+ // Fcb will be freed by AFSPrimaryVolumeWorker thread
+ //
*Fcb = NULL;
}
// Need to tear down this Fcb since it is not in the tree for the worker thread
//
+ AFSAcquireExcl( &DirectoryCB->ObjectInformation->NonPagedInfo->ObjectInfoLock,
+ TRUE);
+
AFSRemoveFcb( &DirectoryCB->ObjectInformation->Fcb);
+
+ AFSReleaseResource( &DirectoryCB->ObjectInformation->NonPagedInfo->ObjectInfoLock);
}
*Fcb = NULL;