From d010ffc7dfbb7b063dc7c978804c3d0e8863272f Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Sun, 23 Nov 2014 15:49:24 +0000 Subject: [PATCH] [NTFS] - In NtfsQueryDirectory(), don't upcase name in dir search pattern, it can conflict with POSIX names. - In CompareFileName(), handle the fact that for Win32 & DOS we do case insensitive comparisons by upcasing name before match. Don't do it for POSIX names! This fixes name completion in cmd for POSIX. And doesn't break it for Win32 :-). svn path=/trunk/; revision=65462 --- reactos/drivers/filesystems/ntfs/dirctl.c | 9 +-------- reactos/drivers/filesystems/ntfs/mft.c | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/reactos/drivers/filesystems/ntfs/dirctl.c b/reactos/drivers/filesystems/ntfs/dirctl.c index ddf5662e80d..60c59a81566 100644 --- a/reactos/drivers/filesystems/ntfs/dirctl.c +++ b/reactos/drivers/filesystems/ntfs/dirctl.c @@ -348,14 +348,7 @@ NtfsQueryDirectory(PNTFS_IRP_CONTEXT IrpContext) return STATUS_INSUFFICIENT_RESOURCES; } - Status = RtlUpcaseUnicodeString(&Pattern, SearchPattern, FALSE); - if (!NT_SUCCESS(Status)) - { - DPRINT1("RtlUpcaseUnicodeString('%wZ') failed with status 0x%08lx\n", &Pattern, Status); - ExFreePoolWithTag(Ccb->DirectorySearchPattern, TAG_NTFS); - Ccb->DirectorySearchPattern = NULL; - return Status; - } + memcpy(Ccb->DirectorySearchPattern, SearchPattern->Buffer, SearchPattern->Length); Ccb->DirectorySearchPattern[SearchPattern->Length / sizeof(WCHAR)] = 0; } } diff --git a/reactos/drivers/filesystems/ntfs/mft.c b/reactos/drivers/filesystems/ntfs/mft.c index 3e83fe8efaa..3a3f00e0ab9 100644 --- a/reactos/drivers/filesystems/ntfs/mft.c +++ b/reactos/drivers/filesystems/ntfs/mft.c @@ -466,6 +466,7 @@ CompareFileName(PUNICODE_STRING FileName, PINDEX_ENTRY_ATTRIBUTE IndexEntry, BOOLEAN DirSearch) { + BOOLEAN Ret, Alloc = FALSE; UNICODE_STRING EntryName; EntryName.Buffer = IndexEntry->FileName.Name; @@ -474,7 +475,25 @@ CompareFileName(PUNICODE_STRING FileName, if (DirSearch) { - return FsRtlIsNameInExpression(FileName, &EntryName, (IndexEntry->FileName.NameType != NTFS_FILE_NAME_POSIX), NULL); + UNICODE_STRING IntFileName; + if (IndexEntry->FileName.NameType != NTFS_FILE_NAME_POSIX) + { + ASSERT(NT_SUCCESS(RtlUpcaseUnicodeString(&IntFileName, FileName, TRUE))); + Alloc = TRUE; + } + else + { + IntFileName = *FileName; + } + + Ret = FsRtlIsNameInExpression(&IntFileName, &EntryName, (IndexEntry->FileName.NameType != NTFS_FILE_NAME_POSIX), NULL); + + if (Alloc) + { + RtlFreeUnicodeString(&IntFileName); + } + + return Ret; } else {