[NTFS] - Add some fixes and improvements to create.c, dirctl.c and fcb.c from CR...
authorTrevor Thompson <tmt256@email.vccs.edu>
Tue, 4 Jul 2017 22:34:17 +0000 (22:34 +0000)
committerThomas Faber <thomas.faber@reactos.org>
Sun, 10 Dec 2017 10:14:53 +0000 (11:14 +0100)
-NtfsOpenFile() - Replace an ExFreePool() with ExFreePoolWithTag().
-NtfsCreateFile() - Fix broken cast with BooleanFlagOn() macro.
-NtfsAddFilenameToDirectory() - Remove an extra cast. Return an error if we fail to allocate I30IndexRoot.
-NtfsGetNextPathElement(), NtfsWSubString(), NtfsGetFCBForFile() - Use PCWSTR in place of const PWCHAR or PWCHAR  where it makes sense.

svn path=/branches/GSoC_2016/NTFS/; revision=75281

drivers/filesystems/ntfs/create.c
drivers/filesystems/ntfs/dirctl.c
drivers/filesystems/ntfs/fcb.c
drivers/filesystems/ntfs/ntfs.h

index 4da9470..3c8ba81 100644 (file)
@@ -304,7 +304,7 @@ NtfsOpenFile(PDEVICE_EXTENSION DeviceExt,
             DPRINT("Could not make a new FCB, status: %x\n", Status);
 
             if (AbsFileName)
-                ExFreePool(AbsFileName);
+                ExFreePoolWithTag(AbsFileName, TAG_NTFS);
 
             return Status;
         }
@@ -572,7 +572,7 @@ NtfsCreateFile(PDEVICE_OBJECT DeviceObject,
             // Create the file record on disk
             Status = NtfsCreateFileRecord(DeviceExt,
                                           FileObject,
-                                          (Stack->Flags & SL_CASE_SENSITIVE),
+                                          BooleanFlagOn(Stack->Flags, SL_CASE_SENSITIVE),
                                           BooleanFlagOn(IrpContext->Flags,IRPCONTEXT_CANWAIT));
             if (!NT_SUCCESS(Status))
             {
index c3bcdb4..c41688e 100644 (file)
@@ -138,12 +138,13 @@ NtfsAddFilenameToDirectory(PDEVICE_EXTENSION DeviceExt,
 
     // Allocate memory for the index root data
     I30IndexRootLength = AttributeDataLength(&IndexRootContext->Record);
-    I30IndexRoot = (PINDEX_ROOT_ATTRIBUTE)ExAllocatePoolWithTag(NonPagedPool, I30IndexRootLength, TAG_NTFS);
+    I30IndexRoot = ExAllocatePoolWithTag(NonPagedPool, I30IndexRootLength, TAG_NTFS);
     if (!I30IndexRoot)
     {
         DPRINT1("ERROR: Couldn't allocate memory for index root attribute!\n");
         ReleaseAttributeContext(IndexRootContext);
         ExFreePoolWithTag(ParentFileRecord, TAG_NTFS);
+        return STATUS_INSUFFICIENT_RESOURCES;
     }
 
     // Read the Index Root
index 851234c..5497b80 100644 (file)
@@ -35,8 +35,8 @@
 /* FUNCTIONS ****************************************************************/
 
 static
-PWCHAR
-NtfsGetNextPathElement(PWCHAR FileName)
+PCWSTR
+NtfsGetNextPathElement(PCWSTR FileName)
 {
     if (*FileName == L'\0')
     {
@@ -55,7 +55,7 @@ NtfsGetNextPathElement(PWCHAR FileName)
 static
 VOID
 NtfsWSubString(PWCHAR pTarget,
-               const PWCHAR pSource,
+               PCWSTR pSource,
                size_t pLength)
 {
     wcsncpy(pTarget, pSource, pLength);
@@ -593,13 +593,13 @@ NTSTATUS
 NtfsGetFCBForFile(PNTFS_VCB Vcb,
                   PNTFS_FCB *pParentFCB,
                   PNTFS_FCB *pFCB,
-                  const PWSTR pFileName,
+                  PCWSTR pFileName,
                   BOOLEAN CaseSensitive)
 {
     NTSTATUS Status;
     WCHAR pathName [MAX_PATH];
     WCHAR elementName [MAX_PATH];
-    PWCHAR currentElement;
+    PCWSTR currentElement;
     PNTFS_FCB FCB;
     PNTFS_FCB parentFCB;
 
index 3e01f46..eb4d6f3 100644 (file)
@@ -840,7 +840,7 @@ NTSTATUS
 NtfsGetFCBForFile(PNTFS_VCB Vcb,
                   PNTFS_FCB *pParentFCB,
                   PNTFS_FCB *pFCB,
-                  const PWSTR pFileName,
+                  PCWSTR pFileName,
                   BOOLEAN CaseSensitive);
 
 NTSTATUS