Author: mbosma
Date: Sat Dec 30 03:37:52 2006
New Revision: 25243
URL:
http://svn.reactos.org/svn/reactos?rev=25243&view=rev
Log:
Add changes from cc rewrite brunch. The driver still works under the old cc because it
makes use of the USE_ROS_CC_AND_FS define.
Modified:
trunk/reactos/drivers/filesystems/vfat/cleanup.c
trunk/reactos/drivers/filesystems/vfat/close.c
trunk/reactos/drivers/filesystems/vfat/create.c
Modified: trunk/reactos/drivers/filesystems/vfat/cleanup.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/vfat/c…
==============================================================================
--- trunk/reactos/drivers/filesystems/vfat/cleanup.c (original)
+++ trunk/reactos/drivers/filesystems/vfat/cleanup.c Sat Dec 30 03:37:52 2006
@@ -29,24 +29,50 @@
pFcb = (PVFATFCB) FileObject->FsContext;
if (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_VOLUME)
+ {
+ pFcb->OpenHandleCount--;
- if (pFcb->Flags & FCB_IS_DIRTY)
- {
- VfatUpdateEntry (pFcb);
- }
+ 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_DELETE_PENDING &&
- pFcb->OpenHandleCount == 1)
- {
+ 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);
PFILE_OBJECT tmpFileObject;
tmpFileObject = pFcb->FileObject;
if (tmpFileObject != NULL)
@@ -71,10 +97,21 @@
#ifdef USE_ROS_CC_AND_FS
CcRosReleaseFileCache (FileObject);
#else
- CcUninitializeCacheMap (FileObject, NULL, NULL);
+ if (FileObject->SectionObjectPointer->SharedCacheMap)
+ {
+ CcUninitializeCacheMap (FileObject, &pFcb->RFCB.FileSize, NULL);
+ }
#endif
- pFcb->OpenHandleCount--;
- IoRemoveShareAccess(FileObject, &pFcb->FCBShareAccess);
+ if (pFcb->OpenHandleCount != 0)
+ {
+ IoRemoveShareAccess(FileObject, &pFcb->FCBShareAccess);
+ }
+
+ FileObject->Flags |= FO_CLEANUP_COMPLETE;
+
+ ExReleaseResourceLite (&pFcb->PagingIoResource);
+ ExReleaseResourceLite (&pFcb->MainResource);
+ }
}
return STATUS_SUCCESS;
}
@@ -104,6 +141,11 @@
ExReleaseResourceLite (&IrpContext->DeviceExt->DirResource);
+ if (Status == STATUS_PENDING)
+ {
+ return VfatQueueRequest(IrpContext);
+ }
+
ByeBye:
IrpContext->Irp->IoStatus.Status = Status;
IrpContext->Irp->IoStatus.Information = 0;
Modified: trunk/reactos/drivers/filesystems/vfat/close.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/vfat/c…
==============================================================================
--- trunk/reactos/drivers/filesystems/vfat/close.c (original)
+++ trunk/reactos/drivers/filesystems/vfat/close.c Sat Dec 30 03:37:52 2006
@@ -30,6 +30,8 @@
pCcb = (PVFATCCB) (FileObject->FsContext2);
pFcb = (PVFATFCB) (FileObject->FsContext);
+ FileObject->FsContext2 = NULL;
+
if (pFcb == NULL)
{
return STATUS_SUCCESS;
@@ -43,7 +45,7 @@
}
else
{
- if (FileObject->DeletePending)
+// if (FileObject->DeletePending)
{
if (pFcb->Flags & FCB_DELETE_PENDING)
{
@@ -57,7 +59,6 @@
vfatReleaseFCB (DeviceExt, pFcb);
}
- FileObject->FsContext2 = NULL;
FileObject->FsContext = NULL;
FileObject->SectionObjectPointer = NULL;
Modified: trunk/reactos/drivers/filesystems/vfat/create.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/vfat/c…
==============================================================================
--- trunk/reactos/drivers/filesystems/vfat/create.c (original)
+++ trunk/reactos/drivers/filesystems/vfat/create.c Sat Dec 30 03:37:52 2006
@@ -656,7 +656,24 @@
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: