https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a1401a75772f489bb59c8…
commit a1401a75772f489bb59c895b33e1f192ebde5fc8
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Wed Oct 3 10:21:39 2018 +0200
Commit: Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Wed Oct 3 10:22:33 2018 +0200
[NTOSKRNL] Use faster internal helper to query name
This only applies if we're called from kernel mode
with a synchronous file.
---
ntoskrnl/include/internal/io.h | 10 ++++++++++
ntoskrnl/io/iomgr/file.c | 22 +++++++++++++++++-----
2 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/ntoskrnl/include/internal/io.h b/ntoskrnl/include/internal/io.h
index 29ecb808f9..95e3607bb5 100644
--- a/ntoskrnl/include/internal/io.h
+++ b/ntoskrnl/include/internal/io.h
@@ -1276,6 +1276,16 @@ IoComputeDesiredAccessFileObject(
IN PACCESS_MASK DesiredAccess
);
+NTSTATUS
+NTAPI
+IopGetFileInformation(
+ IN PFILE_OBJECT FileObject,
+ IN ULONG Length,
+ IN FILE_INFORMATION_CLASS FileInfoClass,
+ OUT PVOID Buffer,
+ OUT PULONG ReturnedLength
+);
+
//
// I/O Timer Routines
//
diff --git a/ntoskrnl/io/iomgr/file.c b/ntoskrnl/io/iomgr/file.c
index 4cbdb640a1..e877888c74 100644
--- a/ntoskrnl/io/iomgr/file.c
+++ b/ntoskrnl/io/iomgr/file.c
@@ -1941,11 +1941,23 @@ IopQueryNameInternal(IN PVOID ObjectBody,
FIELD_OFFSET(FILE_NAME_INFORMATION, FileName);
/* Query the File name */
- Status = IoQueryFileInformation(FileObject,
- FileNameInformation,
- LengthMismatch ? Length : FileLength,
- LocalFileInfo,
- &LocalReturnLength);
+ if (PreviousMode == KernelMode &&
+ BooleanFlagOn(FileObject->Flags, FO_SYNCHRONOUS_IO))
+ {
+ Status = IopGetFileInformation(FileObject,
+ LengthMismatch ? Length : FileLength,
+ FileNameInformation,
+ LocalFileInfo,
+ &LocalReturnLength);
+ }
+ else
+ {
+ Status = IoQueryFileInformation(FileObject,
+ FileNameInformation,
+ LengthMismatch ? Length : FileLength,
+ LocalFileInfo,
+ &LocalReturnLength);
+ }
if (NT_ERROR(Status))
{
/* Fail on errors only, allow warnings */