diff --git a/reactos/drivers/filesystems/vfat/cleanup.c b/reactos/drivers/filesystems/vfat/cleanup.c index 8c9109fb4fc..e9909bdc1d5 100644 --- a/reactos/drivers/filesystems/vfat/cleanup.c +++ b/reactos/drivers/filesystems/vfat/cleanup.c @@ -29,50 +29,24 @@ VfatCleanupFile(PVFAT_IRP_CONTEXT IrpContext) pFcb = (PVFATFCB) FileObject->FsContext; if (pFcb) { - if (pFcb->Flags & FCB_IS_VOLUME) - { - pFcb->OpenHandleCount--; + if (!(*pFcb->Attributes & FILE_ATTRIBUTE_DIRECTORY) && + FsRtlAreThereCurrentFileLocks(&pFcb->FileLock)) + { + /* remove all locks this process have on this file */ + FsRtlFastUnlockAll(&pFcb->FileLock, + FileObject, + IoGetRequestorProcess(IrpContext->Irp), + NULL); + } - if (pFcb->OpenHandleCount != 0) - { - IoRemoveShareAccess(FileObject, &pFcb->FCBShareAccess); - } - } - else - { - if(!ExAcquireResourceExclusiveLite (&pFcb->MainResource, - (BOOLEAN)(IrpContext->Flags & IRPCONTEXT_CANWAIT))) - { - return STATUS_PENDING; - } - if(!ExAcquireResourceExclusiveLite (&pFcb->PagingIoResource, - (BOOLEAN)(IrpContext->Flags & IRPCONTEXT_CANWAIT))) - { - ExReleaseResourceLite (&pFcb->MainResource); - return STATUS_PENDING; - } - - pFcb->OpenHandleCount--; + if (pFcb->Flags & FCB_IS_DIRTY) + { + VfatUpdateEntry (pFcb); + } - if (!(*pFcb->Attributes & FILE_ATTRIBUTE_DIRECTORY) && - FsRtlAreThereCurrentFileLocks(&pFcb->FileLock)) - { - /* remove all locks this process have on this file */ - FsRtlFastUnlockAll(&pFcb->FileLock, - FileObject, - IoGetRequestorProcess(IrpContext->Irp), - NULL); - } - - if (pFcb->Flags & FCB_IS_DIRTY) - { - VfatUpdateEntry (pFcb); - } - - if (pFcb->Flags & FCB_DELETE_PENDING && - pFcb->OpenHandleCount == 0) - { - DPRINT("'%wZ'\n", &pFcb->PathNameU); + if (pFcb->Flags & FCB_DELETE_PENDING && + pFcb->OpenHandleCount == 1) + { PFILE_OBJECT tmpFileObject; tmpFileObject = pFcb->FileObject; if (tmpFileObject != NULL) @@ -97,21 +71,10 @@ VfatCleanupFile(PVFAT_IRP_CONTEXT IrpContext) #ifdef USE_ROS_CC_AND_FS CcRosReleaseFileCache (FileObject); #else - if (FileObject->SectionObjectPointer->SharedCacheMap) - { - CcUninitializeCacheMap (FileObject, &pFcb->RFCB.FileSize, NULL); - } + CcUninitializeCacheMap (FileObject, NULL, NULL); #endif - if (pFcb->OpenHandleCount != 0) - { - IoRemoveShareAccess(FileObject, &pFcb->FCBShareAccess); - } - - FileObject->Flags |= FO_CLEANUP_COMPLETE; - - ExReleaseResourceLite (&pFcb->PagingIoResource); - ExReleaseResourceLite (&pFcb->MainResource); - } + pFcb->OpenHandleCount--; + IoRemoveShareAccess(FileObject, &pFcb->FCBShareAccess); } return STATUS_SUCCESS; } @@ -141,11 +104,6 @@ NTSTATUS VfatCleanup (PVFAT_IRP_CONTEXT IrpContext) ExReleaseResourceLite (&IrpContext->DeviceExt->DirResource); - if (Status == STATUS_PENDING) - { - return VfatQueueRequest(IrpContext); - } - ByeBye: IrpContext->Irp->IoStatus.Status = Status; IrpContext->Irp->IoStatus.Information = 0; diff --git a/reactos/drivers/filesystems/vfat/close.c b/reactos/drivers/filesystems/vfat/close.c index c37cb6ec391..b7d2a18a547 100644 --- a/reactos/drivers/filesystems/vfat/close.c +++ b/reactos/drivers/filesystems/vfat/close.c @@ -30,8 +30,6 @@ VfatCloseFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject) pCcb = (PVFATCCB) (FileObject->FsContext2); pFcb = (PVFATFCB) (FileObject->FsContext); - FileObject->FsContext2 = NULL; - if (pFcb == NULL) { return STATUS_SUCCESS; @@ -45,7 +43,7 @@ VfatCloseFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject) } else { -// if (FileObject->DeletePending) + if (FileObject->DeletePending) { if (pFcb->Flags & FCB_DELETE_PENDING) { @@ -59,6 +57,7 @@ VfatCloseFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject) vfatReleaseFCB (DeviceExt, pFcb); } + FileObject->FsContext2 = NULL; FileObject->FsContext = NULL; FileObject->SectionObjectPointer = NULL; diff --git a/reactos/drivers/filesystems/vfat/create.c b/reactos/drivers/filesystems/vfat/create.c index 6d570d821fd..acc2ac116ce 100644 --- a/reactos/drivers/filesystems/vfat/create.c +++ b/reactos/drivers/filesystems/vfat/create.c @@ -656,24 +656,7 @@ VfatCreateFile ( PDEVICE_OBJECT DeviceObject, PIRP Irp ) VfatCloseFile (DeviceExt, FileObject); return(STATUS_NOT_A_DIRECTORY); } -#ifndef USE_ROS_CC_AND_FS - if (!(*pFcb->Attributes & FILE_ATTRIBUTE_DIRECTORY)) - { - if (Stack->Parameters.Create.SecurityContext->DesiredAccess & FILE_WRITE_DATA || - RequestedDisposition == FILE_OVERWRITE || - RequestedDisposition == FILE_OVERWRITE_IF) - { - if (!MmFlushImageSection(&pFcb->SectionObjectPointers, MmFlushForWrite)) - { - DPRINT1("%wZ\n", &pFcb->PathNameU); - DPRINT1("%d %d %d\n", Stack->Parameters.Create.SecurityContext->DesiredAccess & FILE_WRITE_DATA, - RequestedDisposition == FILE_OVERWRITE, RequestedDisposition == FILE_OVERWRITE_IF); - VfatCloseFile (DeviceExt, FileObject); - return STATUS_SHARING_VIOLATION; - } - } - } -#endif + if (PagingFileCreate) { /* FIXME: