https://git.reactos.org/?p=reactos.git;a=commitdiff;h=39a06fae0dcc928341e104...
commit 39a06fae0dcc928341e104ccbac7cacc5d7b4298 Author: Trevor Thompson tmt256@email.vccs.edu AuthorDate: Tue Jul 4 22:34:17 2017 +0000
[NTFS] - Add some fixes and improvements to create.c, dirctl.c and fcb.c from CR-123: -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 | 4 ++-- drivers/filesystems/ntfs/dirctl.c | 3 ++- drivers/filesystems/ntfs/fcb.c | 10 +++++----- drivers/filesystems/ntfs/ntfs.h | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/drivers/filesystems/ntfs/create.c b/drivers/filesystems/ntfs/create.c index 4da9470a6b..3c8ba81f02 100644 --- a/drivers/filesystems/ntfs/create.c +++ b/drivers/filesystems/ntfs/create.c @@ -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)) { diff --git a/drivers/filesystems/ntfs/dirctl.c b/drivers/filesystems/ntfs/dirctl.c index c3bcdb43cb..c41688ea2b 100644 --- a/drivers/filesystems/ntfs/dirctl.c +++ b/drivers/filesystems/ntfs/dirctl.c @@ -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 diff --git a/drivers/filesystems/ntfs/fcb.c b/drivers/filesystems/ntfs/fcb.c index 851234c4fe..5497b8001d 100644 --- a/drivers/filesystems/ntfs/fcb.c +++ b/drivers/filesystems/ntfs/fcb.c @@ -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;
diff --git a/drivers/filesystems/ntfs/ntfs.h b/drivers/filesystems/ntfs/ntfs.h index 3e01f469a4..eb4d6f3f9f 100644 --- a/drivers/filesystems/ntfs/ntfs.h +++ b/drivers/filesystems/ntfs/ntfs.h @@ -840,7 +840,7 @@ NTSTATUS NtfsGetFCBForFile(PNTFS_VCB Vcb, PNTFS_FCB *pParentFCB, PNTFS_FCB *pFCB, - const PWSTR pFileName, + PCWSTR pFileName, BOOLEAN CaseSensitive);
NTSTATUS