[FASTFAT]
[reactos.git] / reactos / drivers / filesystems / fastfat / close.c
index b91b85b..b4e5fda 100644 (file)
@@ -25,6 +25,7 @@ VfatCloseFile(
 {
     PVFATFCB pFcb;
     PVFATCCB pCcb;
+    BOOLEAN IsVolume;
     NTSTATUS Status = STATUS_SUCCESS;
 
     DPRINT("VfatCloseFile(DeviceExt %p, FileObject %p)\n",
@@ -39,36 +40,14 @@ VfatCloseFile(
         return STATUS_SUCCESS;
     }
 
-    if (pFcb->Flags & FCB_IS_VOLUME)
+    IsVolume = BooleanFlagOn(pFcb->Flags, FCB_IS_VOLUME);
+    if (IsVolume)
     {
         DPRINT("Volume\n");
         FileObject->FsContext2 = NULL;
     }
     else
     {
-        if (FileObject->DeletePending)
-        {
-            if (pFcb->Flags & FCB_DELETE_PENDING)
-            {
-                VfatDelEntry(DeviceExt, pFcb, NULL);
-
-                FsRtlNotifyFullReportChange(DeviceExt->NotifySync,
-                                            &(DeviceExt->NotifyList),
-                                            (PSTRING)&pFcb->PathNameU,
-                                            pFcb->PathNameU.Length - pFcb->LongNameU.Length,
-                                            NULL,
-                                            NULL,
-                                            ((*pFcb->Attributes & FILE_ATTRIBUTE_DIRECTORY) ?
-                                            FILE_NOTIFY_CHANGE_DIR_NAME : FILE_NOTIFY_CHANGE_FILE_NAME),
-                                            FILE_ACTION_REMOVED,
-                                            NULL);
-            }
-            else
-            {
-                Status = STATUS_DELETE_PENDING;
-            }
-        }
-
         vfatReleaseFCB(DeviceExt, pFcb);
     }
 
@@ -81,6 +60,13 @@ VfatCloseFile(
         vfatDestroyCCB(pCcb);
     }
 
+#ifdef ENABLE_SWAPOUT
+    if (IsVolume && DeviceExt->OpenHandleCount == 0)
+    {
+        VfatCheckForDismount(DeviceExt, FALSE);
+    }
+#endif
+
     return Status;
 }
 
@@ -98,28 +84,18 @@ VfatClose(
     if (IrpContext->DeviceObject == VfatGlobalData->DeviceObject)
     {
         DPRINT("Closing file system\n");
-        Status = STATUS_SUCCESS;
-        goto ByeBye;
+        IrpContext->Irp->IoStatus.Information = 0;
+        return STATUS_SUCCESS;
     }
-#if 0
-    /* There occurs a dead look at the call to CcRosDeleteFileCache/ObDereferenceObject/VfatClose
-       in CmLazyCloseThreadMain if VfatClose is execute asynchronous in a worker thread. */
-    if (!ExAcquireResourceExclusiveLite(&IrpContext->DeviceExt->DirResource, IrpContext->Flags & IRPCONTEXT_CANWAIT))
-#else
-    if (!ExAcquireResourceExclusiveLite(&IrpContext->DeviceExt->DirResource, TRUE))
-#endif
+    if (!ExAcquireResourceExclusiveLite(&IrpContext->DeviceExt->DirResource, BooleanFlagOn(IrpContext->Flags, IRPCONTEXT_CANWAIT)))
     {
-        return VfatQueueRequest(IrpContext);
+        return VfatMarkIrpContextForQueue(IrpContext);
     }
 
     Status = VfatCloseFile(IrpContext->DeviceExt, IrpContext->FileObject);
     ExReleaseResourceLite(&IrpContext->DeviceExt->DirResource);
 
-ByeBye:
-    IrpContext->Irp->IoStatus.Status = Status;
     IrpContext->Irp->IoStatus.Information = 0;
-    IoCompleteRequest(IrpContext->Irp, IO_NO_INCREMENT);
-    VfatFreeIrpContext(IrpContext);
 
     return Status;
 }