mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 16:36:33 +00:00
[FASTFAT]
- Fix renaming files in case the target file already exists. - Plug a few reference count leaks on FCBs. CORE-8660 #comment fixed in r65140 #resolve CORE-8633 #comment fixed in r65140 #resolve CORE-4758 #comment fixed in r65140 #resolve svn path=/trunk/; revision=65140
This commit is contained in:
parent
f801abcacf
commit
3d37281ca2
3 changed files with 22 additions and 10 deletions
|
@ -92,6 +92,7 @@ VfatCleanupFile(
|
|||
pFcb->FileObject = NULL;
|
||||
CcUninitializeCacheMap(tmpFileObject, NULL, NULL);
|
||||
ObDereferenceObject(tmpFileObject);
|
||||
vfatReleaseFCB(IrpContext->DeviceExt, pFcb);
|
||||
}
|
||||
|
||||
CcPurgeCacheSection(FileObject->SectionObjectPointer, NULL, 0, FALSE);
|
||||
|
|
|
@ -365,7 +365,6 @@ VfatOpenFile(
|
|||
DPRINT("'%wZ'\n", &FileObject->RelatedFileObject->FileName);
|
||||
|
||||
*ParentFcb = FileObject->RelatedFileObject->FsContext;
|
||||
vfatGrabFCB(DeviceExt, *ParentFcb);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -396,30 +396,41 @@ vfatPrepareTargetForRename(
|
|||
/* If it exists */
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("Target file %wZ exists. FCB Flags %08x\n", NewName, TargetFcb->Flags);
|
||||
/* Check whether we are allowed to replace */
|
||||
if (ReplaceIfExists)
|
||||
{
|
||||
/* If that's a directory or a read-only file, we're not allowed */
|
||||
if (vfatFCBIsDirectory(TargetFcb) || ((*TargetFcb->Attributes & FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY));
|
||||
if (vfatFCBIsDirectory(TargetFcb) || ((*TargetFcb->Attributes & FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY))
|
||||
{
|
||||
DPRINT("And this is a readonly file!\n");
|
||||
vfatReleaseFCB(DeviceExt, *ParentFCB);
|
||||
*ParentFCB = NULL;
|
||||
vfatReleaseFCB(DeviceExt, TargetFcb);
|
||||
return STATUS_OBJECT_NAME_COLLISION;
|
||||
}
|
||||
|
||||
/* Attempt to flush (might close the file) */
|
||||
if (!MmFlushImageSection(TargetFcb->FileObject->SectionObjectPointer, MmFlushForDelete))
|
||||
|
||||
/* If we still have a file object, close it. */
|
||||
if (TargetFcb->FileObject)
|
||||
{
|
||||
vfatReleaseFCB(DeviceExt, *ParentFCB);
|
||||
*ParentFCB = NULL;
|
||||
vfatReleaseFCB(DeviceExt, TargetFcb);
|
||||
return STATUS_ACCESS_DENIED;
|
||||
if (!MmFlushImageSection(TargetFcb->FileObject->SectionObjectPointer, MmFlushForDelete))
|
||||
{
|
||||
DPRINT("MmFlushImageSection failed.\n");
|
||||
vfatReleaseFCB(DeviceExt, *ParentFCB);
|
||||
*ParentFCB = NULL;
|
||||
vfatReleaseFCB(DeviceExt, TargetFcb);
|
||||
return STATUS_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
TargetFcb->FileObject->DeletePending = TRUE;
|
||||
VfatCloseFile(DeviceExt, TargetFcb->FileObject);
|
||||
}
|
||||
|
||||
/* If we are, ensure the file isn't open by anyone! */
|
||||
/* If we are here, ensure the file isn't open by anyone! */
|
||||
if (TargetFcb->OpenHandleCount != 0)
|
||||
{
|
||||
DPRINT("There are still open handles for this file.\n");
|
||||
vfatReleaseFCB(DeviceExt, *ParentFCB);
|
||||
*ParentFCB = NULL;
|
||||
vfatReleaseFCB(DeviceExt, TargetFcb);
|
||||
|
@ -427,10 +438,11 @@ vfatPrepareTargetForRename(
|
|||
}
|
||||
|
||||
/* Effectively delete old file to allow renaming */
|
||||
DPRINT("Effectively deleting the file.\n");
|
||||
VfatDelEntry(DeviceExt, TargetFcb, NULL);
|
||||
vfatGrabFCB(DeviceExt, *ParentFCB);
|
||||
vfatReleaseFCB(DeviceExt, TargetFcb);
|
||||
*Deleted = TRUE;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue