Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygencleanup.c
Go to the documentation of this file.
00001 /* 00002 * COPYRIGHT: See COPYING in the top level directory 00003 * PROJECT: ReactOS kernel 00004 * FILE: drivers/fs/vfat/cleanup.c 00005 * PURPOSE: VFAT Filesystem 00006 * PROGRAMMER: Jason Filby (jasonfilby@yahoo.com) 00007 */ 00008 00009 /* INCLUDES *****************************************************************/ 00010 00011 #define NDEBUG 00012 #include "vfat.h" 00013 00014 /* FUNCTIONS ****************************************************************/ 00015 00016 /* 00017 * FUNCTION: Cleans up after a file has been closed. 00018 */ 00019 static NTSTATUS 00020 VfatCleanupFile(PVFAT_IRP_CONTEXT IrpContext) 00021 { 00022 PVFATFCB pFcb; 00023 PFILE_OBJECT FileObject = IrpContext->FileObject; 00024 00025 DPRINT("VfatCleanupFile(DeviceExt %p, FileObject %p)\n", 00026 IrpContext->DeviceExt, FileObject); 00027 00028 /* FIXME: handle file/directory deletion here */ 00029 pFcb = (PVFATFCB) FileObject->FsContext; 00030 if (!pFcb) 00031 return STATUS_SUCCESS; 00032 00033 if (pFcb->Flags & FCB_IS_VOLUME) 00034 { 00035 pFcb->OpenHandleCount--; 00036 00037 if (pFcb->OpenHandleCount != 0) 00038 { 00039 IoRemoveShareAccess(FileObject, &pFcb->FCBShareAccess); 00040 } 00041 } 00042 else 00043 { 00044 if(!ExAcquireResourceExclusiveLite (&pFcb->MainResource, 00045 (BOOLEAN)(IrpContext->Flags & IRPCONTEXT_CANWAIT))) 00046 { 00047 return STATUS_PENDING; 00048 } 00049 if(!ExAcquireResourceExclusiveLite (&pFcb->PagingIoResource, 00050 (BOOLEAN)(IrpContext->Flags & IRPCONTEXT_CANWAIT))) 00051 { 00052 ExReleaseResourceLite (&pFcb->MainResource); 00053 return STATUS_PENDING; 00054 } 00055 00056 pFcb->OpenHandleCount--; 00057 00058 if (!(*pFcb->Attributes & FILE_ATTRIBUTE_DIRECTORY) && 00059 FsRtlAreThereCurrentFileLocks(&pFcb->FileLock)) 00060 { 00061 /* remove all locks this process have on this file */ 00062 FsRtlFastUnlockAll(&pFcb->FileLock, 00063 FileObject, 00064 IoGetRequestorProcess(IrpContext->Irp), 00065 NULL); 00066 } 00067 00068 if (pFcb->Flags & FCB_IS_DIRTY) 00069 { 00070 VfatUpdateEntry (pFcb); 00071 } 00072 00073 if (pFcb->Flags & FCB_DELETE_PENDING && 00074 pFcb->OpenHandleCount == 0) 00075 { 00076 PFILE_OBJECT tmpFileObject; 00077 tmpFileObject = pFcb->FileObject; 00078 if (tmpFileObject != NULL) 00079 { 00080 pFcb->FileObject = NULL; 00081 CcUninitializeCacheMap(tmpFileObject, NULL, NULL); 00082 ObDereferenceObject(tmpFileObject); 00083 } 00084 00085 CcPurgeCacheSection(FileObject->SectionObjectPointer, NULL, 0, FALSE); 00086 } 00087 00088 /* Uninitialize the cache (should be done even if caching was never initialized) */ 00089 CcUninitializeCacheMap(FileObject, &pFcb->RFCB.FileSize, NULL); 00090 00091 if (pFcb->OpenHandleCount != 0) 00092 { 00093 IoRemoveShareAccess(FileObject, &pFcb->FCBShareAccess); 00094 } 00095 00096 FileObject->Flags |= FO_CLEANUP_COMPLETE; 00097 00098 ExReleaseResourceLite (&pFcb->PagingIoResource); 00099 ExReleaseResourceLite (&pFcb->MainResource); 00100 } 00101 00102 return STATUS_SUCCESS; 00103 } 00104 00105 /* 00106 * FUNCTION: Cleans up after a file has been closed. 00107 */ 00108 NTSTATUS VfatCleanup(PVFAT_IRP_CONTEXT IrpContext) 00109 { 00110 NTSTATUS Status; 00111 00112 DPRINT("VfatCleanup(DeviceObject %p, Irp %p)\n", IrpContext->DeviceObject, IrpContext->Irp); 00113 00114 if (IrpContext->DeviceObject == VfatGlobalData->DeviceObject) 00115 { 00116 Status = STATUS_SUCCESS; 00117 goto ByeBye; 00118 } 00119 00120 if (!ExAcquireResourceExclusiveLite (&IrpContext->DeviceExt->DirResource, 00121 (BOOLEAN)(IrpContext->Flags & IRPCONTEXT_CANWAIT))) 00122 { 00123 return VfatQueueRequest (IrpContext); 00124 } 00125 00126 Status = VfatCleanupFile(IrpContext); 00127 00128 ExReleaseResourceLite (&IrpContext->DeviceExt->DirResource); 00129 00130 if (Status == STATUS_PENDING) 00131 { 00132 return VfatQueueRequest(IrpContext); 00133 } 00134 00135 ByeBye: 00136 IrpContext->Irp->IoStatus.Status = Status; 00137 IrpContext->Irp->IoStatus.Information = 0; 00138 00139 IoCompleteRequest (IrpContext->Irp, IO_NO_INCREMENT); 00140 VfatFreeIrpContext(IrpContext); 00141 return (Status); 00142 } 00143 00144 /* EOF */ Generated on Sat May 26 2012 04:19:57 for ReactOS by
1.7.6.1
|