[NTFS] - In the NtfsAddFilenameToDirectory() function, rename DirectoryContext parame...
[reactos.git] / drivers / filesystems / ntfs / rw.c
index 4db1c38..1cfdd7f 100644 (file)
@@ -165,7 +165,7 @@ NtfsReadFile(PDEVICE_EXTENSION DeviceExt,
         AllocatedBuffer = TRUE;
     }
 
-    DPRINT1("Effective read: %lu at %lu for stream '%S'\n", RealLength, RealReadOffset, Fcb->Stream);
+    DPRINT("Effective read: %lu at %lu for stream '%S'\n", RealLength, RealReadOffset, Fcb->Stream);
     RealLengthRead = ReadAttribute(DeviceExt, DataContext, RealReadOffset, (PCHAR)ReadBuffer, RealLength);
     if (RealLengthRead == 0)
     {
@@ -184,7 +184,7 @@ NtfsReadFile(PDEVICE_EXTENSION DeviceExt,
 
     *LengthRead = ToRead;
 
-    DPRINT1("%lu got read\n", *LengthRead);
+    DPRINT("%lu got read\n", *LengthRead);
 
     if (AllocatedBuffer)
     {
@@ -283,6 +283,10 @@ NtfsRead(PNTFS_IRP_CONTEXT IrpContext)
 * @param IrpFlags
 * TODO: flags are presently ignored in code.
 *
+* @param CaseSensitive
+* Boolean indicating if the function should operate in case-sensitive mode. This will be TRUE
+* if an application opened the file with the FILE_FLAG_POSIX_SEMANTICS flag.
+*
 * @param LengthWritten
 * Pointer to a ULONG. This ULONG will be set to the number of bytes successfully written.
 *
@@ -303,6 +307,7 @@ NTSTATUS NtfsWriteFile(PDEVICE_EXTENSION DeviceExt,
                        ULONG Length,
                        ULONG WriteOffset,
                        ULONG IrpFlags,
+                       BOOLEAN CaseSensitive,
                        PULONG LengthWritten)
 {
     NTSTATUS Status = STATUS_NOT_IMPLEMENTED;
@@ -312,7 +317,15 @@ NTSTATUS NtfsWriteFile(PDEVICE_EXTENSION DeviceExt,
     ULONG AttributeOffset;
     ULONGLONG StreamSize;
 
-    DPRINT("NtfsWriteFile(%p, %p, %p, %u, %u, %x, %p)\n", DeviceExt, FileObject, Buffer, Length, WriteOffset, IrpFlags, LengthWritten);
+    DPRINT("NtfsWriteFile(%p, %p, %p, %u, %u, %x, %s, %p)\n",
+           DeviceExt,
+           FileObject,
+           Buffer,
+           Length,
+           WriteOffset,
+           IrpFlags,
+           (CaseSensitive ? "TRUE" : "FALSE"),
+           LengthWritten);
 
     *LengthWritten = 0;
 
@@ -432,22 +445,6 @@ NTSTATUS NtfsWriteFile(PDEVICE_EXTENSION DeviceExt,
                 return Status;
             }
 
-            // at this point the record in DataContext may be stale, so we need to refresh it
-            ReleaseAttributeContext(DataContext);
-
-            Status = FindAttribute(DeviceExt,
-                                   FileRecord,
-                                   AttributeData,
-                                   Fcb->Stream,
-                                   wcslen(Fcb->Stream),
-                                   &DataContext,
-                                   &AttributeOffset);
-            if (!NT_SUCCESS(Status))
-            {
-                DPRINT1("DRIVER ERROR: Couldn't find $DATA attribute after setting size!\n");
-                return Status;
-            }
-
             // now we need to update this file's size in every directory index entry that references it
             // TODO: put this code in its own function and adapt it to work with every filename / hardlink
             // stored in the file record.
@@ -460,7 +457,13 @@ NTSTATUS NtfsWriteFile(PDEVICE_EXTENSION DeviceExt,
             filename.Length = fileNameAttribute->NameLength * sizeof(WCHAR);
             filename.MaximumLength = filename.Length;
 
-            Status = UpdateFileNameRecord(Fcb->Vcb, ParentMFTId, &filename, FALSE, DataSize.QuadPart, AllocationSize);
+            Status = UpdateFileNameRecord(Fcb->Vcb,
+                                          ParentMFTId,
+                                          &filename,
+                                          FALSE,
+                                          DataSize.QuadPart,
+                                          AllocationSize,
+                                          CaseSensitive);
 
         }
         else
@@ -683,6 +686,7 @@ NtfsWrite(PNTFS_IRP_CONTEXT IrpContext)
                            Length,
                            ByteOffset.LowPart,
                            Irp->Flags,
+                           (IrpContext->Stack->Flags & SL_CASE_SENSITIVE),
                            &ReturnedWriteLength);
 
     IrpContext->Irp->IoStatus.Status = Status;