mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 21:23:05 +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,69 +268,65 @@ 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
|
||||||
|
|
||||||
DPRINT ("FsdSetDispositionInformation()\n");
|
DPRINT ("FsdSetDispositionInformation()\n");
|
||||||
|
|
||||||
ASSERT(DeviceExt != NULL);
|
ASSERT(DeviceExt != NULL);
|
||||||
ASSERT(DeviceExt->FatInfo.BytesPerCluster != 0);
|
ASSERT(DeviceExt->FatInfo.BytesPerCluster != 0);
|
||||||
ASSERT(FCB != NULL);
|
ASSERT(FCB != NULL);
|
||||||
|
|
||||||
if (*FCB->Attributes & FILE_ATTRIBUTE_READONLY)
|
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)
|
||||||
|
{
|
||||||
return STATUS_CANNOT_DELETE;
|
return STATUS_CANNOT_DELETE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vfatFCBIsRoot(FCB) ||
|
if (vfatFCBIsRoot(FCB) ||
|
||||||
(FCB->LongNameU.Length == sizeof(WCHAR) && FCB->LongNameU.Buffer[0] == L'.') ||
|
(FCB->LongNameU.Length == sizeof(WCHAR) && FCB->LongNameU.Buffer[0] == L'.') ||
|
||||||
(FCB->LongNameU.Length == 2 * sizeof(WCHAR) && FCB->LongNameU.Buffer[0] == L'.' && FCB->LongNameU.Buffer[1] == L'.'))
|
(FCB->LongNameU.Length == 2 * sizeof(WCHAR) && FCB->LongNameU.Buffer[0] == L'.' && FCB->LongNameU.Buffer[1] == L'.'))
|
||||||
{
|
{
|
||||||
// we cannot delete a '.', '..' or the root directory
|
// we cannot delete a '.', '..' or the root directory
|
||||||
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");
|
||||||
DPRINT1("%d %x\n", FCB->OpenHandleCount, CcGetFileObjectFromSectionPtrs(FileObject->SectionObjectPointer));
|
return STATUS_CANNOT_DELETE;
|
||||||
Status = STATUS_ACCESS_DENIED;
|
}
|
||||||
}
|
|
||||||
else
|
if (vfatFCBIsDirectory(FCB) && !VfatIsDirectoryEmpty(FCB))
|
||||||
{
|
{
|
||||||
FCB->Flags |= FCB_DELETE_PENDING;
|
/* can't delete a non-empty directory */
|
||||||
FileObject->DeletePending = TRUE;
|
|
||||||
}
|
return STATUS_DIRECTORY_NOT_EMPTY;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
/* all good */
|
||||||
DPRINT("MmFlushImageSection returned FALSE\n");
|
FCB->Flags |= FCB_DELETE_PENDING;
|
||||||
Status = STATUS_CANNOT_DELETE;
|
FileObject->DeletePending = TRUE;
|
||||||
}
|
|
||||||
if (NT_SUCCESS(Status) && vfatFCBIsDirectory(FCB))
|
return STATUS_SUCCESS;
|
||||||
{
|
|
||||||
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