[NTFS]
authorPierre Schweitzer <pierre@reactos.org>
Sun, 12 Oct 2014 11:48:42 +0000 (11:48 +0000)
committerPierre Schweitzer <pierre@reactos.org>
Sun, 12 Oct 2014 11:48:42 +0000 (11:48 +0000)
On opening, check the file found matches the requested dispositions from the caller

svn path=/trunk/; revision=64692

reactos/drivers/filesystems/ntfs/create.c

index e655406..858b489 100644 (file)
@@ -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