From e8d374127e8caa78842005c91a232bfb1fc75a5f Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Sun, 12 Oct 2014 11:48:42 +0000 Subject: [PATCH] [NTFS] On opening, check the file found matches the requested dispositions from the caller svn path=/trunk/; revision=64692 --- reactos/drivers/filesystems/ntfs/create.c | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/reactos/drivers/filesystems/ntfs/create.c b/reactos/drivers/filesystems/ntfs/create.c index e65540659c1..858b48998f8 100644 --- a/reactos/drivers/filesystems/ntfs/create.c +++ b/reactos/drivers/filesystems/ntfs/create.c @@ -221,6 +221,30 @@ NtfsCreateFile(PDEVICE_OBJECT DeviceObject, FileObject->FileName.Buffer, &Fcb); + if (NT_SUCCESS(Status)) + { + if (RequestedDisposition == FILE_CREATE) + { + Irp->IoStatus.Information = FILE_EXISTS; + NtfsCloseFile(DeviceExt, FileObject); + return STATUS_OBJECT_NAME_COLLISION; + } + + if (RequestedOptions & FILE_NON_DIRECTORY_FILE && + NtfsFCBIsDirectory(Fcb)) + { + NtfsCloseFile(DeviceExt, FileObject); + return STATUS_FILE_IS_A_DIRECTORY; + } + + if (RequestedOptions & FILE_DIRECTORY_FILE && + !NtfsFCBIsDirectory(Fcb)) + { + NtfsCloseFile(DeviceExt, FileObject); + return STATUS_NOT_A_DIRECTORY; + } + } + /* * If the directory containing the file to open doesn't exist then * fail immediately