mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 16:02:56 +00:00
-remove incorrect handle count check when deleting files
-reformat code svn path=/trunk/; revision=14181
This commit is contained in:
parent
f0bec76acd
commit
846dc1aebe
1 changed files with 47 additions and 51 deletions
|
@ -268,7 +268,6 @@ VfatSetDispositionInformation(PFILE_OBJECT FileObject,
|
||||||
PDEVICE_OBJECT DeviceObject,
|
PDEVICE_OBJECT DeviceObject,
|
||||||
PFILE_DISPOSITION_INFORMATION DispositionInfo)
|
PFILE_DISPOSITION_INFORMATION DispositionInfo)
|
||||||
{
|
{
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
|
||||||
#ifdef DBG
|
#ifdef DBG
|
||||||
PDEVICE_EXTENSION DeviceExt = DeviceObject->DeviceExtension;
|
PDEVICE_EXTENSION DeviceExt = DeviceObject->DeviceExtension;
|
||||||
#endif
|
#endif
|
||||||
|
@ -279,6 +278,21 @@ VfatSetDispositionInformation(PFILE_OBJECT FileObject,
|
||||||
ASSERT(DeviceExt->FatInfo.BytesPerCluster != 0);
|
ASSERT(DeviceExt->FatInfo.BytesPerCluster != 0);
|
||||||
ASSERT(FCB != NULL);
|
ASSERT(FCB != NULL);
|
||||||
|
|
||||||
|
if (!DispositionInfo->DeleteFile)
|
||||||
|
{
|
||||||
|
/* undelete the file */
|
||||||
|
FCB->Flags &= ~FCB_DELETE_PENDING;
|
||||||
|
FileObject->DeletePending = FALSE;
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FCB->Flags & FCB_DELETE_PENDING)
|
||||||
|
{
|
||||||
|
/* stream already marked for deletion. just update the file object */
|
||||||
|
FileObject->DeletePending = TRUE;
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
if (*FCB->Attributes & FILE_ATTRIBUTE_READONLY)
|
if (*FCB->Attributes & FILE_ATTRIBUTE_READONLY)
|
||||||
{
|
{
|
||||||
return STATUS_CANNOT_DELETE;
|
return STATUS_CANNOT_DELETE;
|
||||||
|
@ -292,45 +306,27 @@ VfatSetDispositionInformation(PFILE_OBJECT FileObject,
|
||||||
return STATUS_ACCESS_DENIED;
|
return STATUS_ACCESS_DENIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DispositionInfo->DeleteFile)
|
|
||||||
|
if (!MmFlushImageSection (FileObject->SectionObjectPointer, MmFlushForDelete))
|
||||||
{
|
{
|
||||||
if (MmFlushImageSection (FileObject->SectionObjectPointer, MmFlushForDelete))
|
/* can't delete a file if its mapped into a process */
|
||||||
{
|
|
||||||
if (FCB->OpenHandleCount > 1)
|
DPRINT("MmFlushImageSection returned FALSE\n");
|
||||||
{
|
return STATUS_CANNOT_DELETE;
|
||||||
DPRINT1("%d %x\n", FCB->OpenHandleCount, CcGetFileObjectFromSectionPtrs(FileObject->SectionObjectPointer));
|
|
||||||
Status = STATUS_ACCESS_DENIED;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (vfatFCBIsDirectory(FCB) && !VfatIsDirectoryEmpty(FCB))
|
||||||
{
|
{
|
||||||
|
/* can't delete a non-empty directory */
|
||||||
|
|
||||||
|
return STATUS_DIRECTORY_NOT_EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* all good */
|
||||||
FCB->Flags |= FCB_DELETE_PENDING;
|
FCB->Flags |= FCB_DELETE_PENDING;
|
||||||
FileObject->DeletePending = TRUE;
|
FileObject->DeletePending = TRUE;
|
||||||
}
|
|
||||||
}
|
return STATUS_SUCCESS;
|
||||||
else
|
|
||||||
{
|
|
||||||
DPRINT("MmFlushImageSection returned FALSE\n");
|
|
||||||
Status = STATUS_CANNOT_DELETE;
|
|
||||||
}
|
|
||||||
if (NT_SUCCESS(Status) && vfatFCBIsDirectory(FCB))
|
|
||||||
{
|
|
||||||
if (!VfatIsDirectoryEmpty(FCB))
|
|
||||||
{
|
|
||||||
Status = STATUS_DIRECTORY_NOT_EMPTY;
|
|
||||||
FCB->Flags &= ~FCB_DELETE_PENDING;
|
|
||||||
FileObject->DeletePending = FALSE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Status = STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FileObject->DeletePending = FALSE;
|
|
||||||
}
|
|
||||||
return Status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue