https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5afb7ab003326eeaf3c40…
commit 5afb7ab003326eeaf3c40b2b8c19798225eeb8a2
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Tue Jun 4 17:09:56 2024 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Sun Jan 5 22:03:55 2025 +0100
[NTOS:IO] IoVolumeDeviceToDosName(): Some stylistic changes.
Minor formatting and comments improvements (typo fixes etc.)
---
ntoskrnl/io/iomgr/volume.c | 72 +++++++++++++++++++++-------------------------
1 file changed, 32 insertions(+), 40 deletions(-)
diff --git a/ntoskrnl/io/iomgr/volume.c b/ntoskrnl/io/iomgr/volume.c
index 024823636f5..600d899ce48 100644
--- a/ntoskrnl/io/iomgr/volume.c
+++ b/ntoskrnl/io/iomgr/volume.c
@@ -9,13 +9,13 @@
* Pierre Schweitzer (pierre.schweitzer(a)reactos.org)
*/
-/* INCLUDES *****************************************************************/
+/* INCLUDES ******************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <debug.h>
-/* GLOBALS ******************************************************************/
+/* GLOBALS *******************************************************************/
ERESOURCE IopDatabaseResource;
LIST_ENTRY IopDiskFileSystemQueueHead, IopNetworkFileSystemQueueHead;
@@ -1279,10 +1279,10 @@ NTAPI
IoVolumeDeviceToDosName(IN PVOID VolumeDeviceObject,
OUT PUNICODE_STRING DosName)
{
- PIRP Irp;
+ NTSTATUS Status;
ULONG Length;
KEVENT Event;
- NTSTATUS Status;
+ PIRP Irp;
PFILE_OBJECT FileObject;
PDEVICE_OBJECT DeviceObject;
IO_STATUS_BLOCK IoStatusBlock;
@@ -1290,10 +1290,10 @@ IoVolumeDeviceToDosName(IN PVOID VolumeDeviceObject,
MOUNTMGR_VOLUME_PATHS VolumePath;
PMOUNTMGR_VOLUME_PATHS VolumePathPtr;
/*
- * This variable with be required to query device name.
+ * This variable is used to query the device name.
* It's based on MOUNTDEV_NAME (mountmgr.h).
- * Doing it that way will prevent dyn memory allocation.
- * Device name won't be longer.
+ * Doing it this way prevents memory allocation.
+ * The device name won't be longer.
*/
struct
{
@@ -1303,10 +1303,11 @@ IoVolumeDeviceToDosName(IN PVOID VolumeDeviceObject,
PAGED_CODE();
- /* First step, getting device name */
+ /* First, retrieve the corresponding device name */
KeInitializeEvent(&Event, NotificationEvent, FALSE);
Irp = IoBuildDeviceIoControlRequest(IOCTL_MOUNTDEV_QUERY_DEVICE_NAME,
- VolumeDeviceObject, NULL, 0,
+ VolumeDeviceObject,
+ NULL, 0,
&DeviceName, sizeof(DeviceName),
FALSE, &Event, &IoStatusBlock);
if (!Irp)
@@ -1320,15 +1321,12 @@ IoVolumeDeviceToDosName(IN PVOID VolumeDeviceObject,
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
Status = IoStatusBlock.Status;
}
-
if (!NT_SUCCESS(Status))
{
return Status;
}
- /* Now that we have the device name, we can query the MountMgr
- * So, get its device object first.
- */
+ /* Now, query the MountMgr for the DOS path */
RtlInitUnicodeString(&MountMgrDevice, MOUNTMGR_DEVICE_NAME);
Status = IoGetDeviceObjectPointer(&MountMgrDevice, FILE_READ_ATTRIBUTES,
&FileObject, &DeviceObject);
@@ -1337,16 +1335,16 @@ IoVolumeDeviceToDosName(IN PVOID VolumeDeviceObject,
return Status;
}
- /* Then, use the proper IOCTL to query the DOS name */
KeInitializeEvent(&Event, NotificationEvent, FALSE);
Irp = IoBuildDeviceIoControlRequest(IOCTL_MOUNTMGR_QUERY_DOS_VOLUME_PATH,
- DeviceObject, &DeviceName,
sizeof(DeviceName),
+ DeviceObject,
+ &DeviceName, sizeof(DeviceName),
&VolumePath, sizeof(VolumePath),
FALSE, &Event, &IoStatusBlock);
if (!Irp)
{
Status = STATUS_INSUFFICIENT_RESOURCES;
- goto DereferenceFO;
+ goto Quit;
}
Status = IoCallDriver(DeviceObject, Irp);
@@ -1356,41 +1354,37 @@ IoVolumeDeviceToDosName(IN PVOID VolumeDeviceObject,
Status = IoStatusBlock.Status;
}
- /* Only tolerated failure here is buffer too small, which is
- * expected.
- */
- if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_OVERFLOW)
+ /* The only tolerated failure here is buffer too small, which is expected */
+ if (!NT_SUCCESS(Status) && (Status != STATUS_BUFFER_OVERFLOW))
{
- goto DereferenceFO;
+ goto Quit;
}
- /* Compute needed size to store DOS name.
- * Even if MOUNTMGR_VOLUME_PATHS allows bigger
- * name lengths than MAXUSHORT, we can't use
- * them, because we have to return this in an UNICODE_STRING
- * that stores length on USHORT.
- */
- Length = VolumePath.MultiSzLength + sizeof(VolumePath);
+ /* Compute the needed size to store the DOS name.
+ * Even if MOUNTMGR_VOLUME_PATHS allows bigger name lengths
+ * than MAXUSHORT, we can't use them, because we have to return
+ * this in an UNICODE_STRING that stores length in a USHORT. */
+ Length = sizeof(VolumePath) + VolumePath.MultiSzLength;
if (Length > MAXUSHORT)
{
Status = STATUS_INVALID_BUFFER_SIZE;
- goto DereferenceFO;
+ goto Quit;
}
- /* Reallocate memory, even in case of success, because
- * that's the buffer that will be returned to caller
- */
+ /* Reallocate the memory, even in case of success, because
+ * that's the buffer that will be returned to the caller */
VolumePathPtr = ExAllocatePoolWithTag(PagedPool, Length, 'D2d ');
if (!VolumePathPtr)
{
Status = STATUS_INSUFFICIENT_RESOURCES;
- goto DereferenceFO;
+ goto Quit;
}
- /* Requery DOS path with proper size */
+ /* Re-query the DOS path with the proper size */
KeInitializeEvent(&Event, NotificationEvent, FALSE);
Irp = IoBuildDeviceIoControlRequest(IOCTL_MOUNTMGR_QUERY_DOS_VOLUME_PATH,
- DeviceObject, &DeviceName,
sizeof(DeviceName),
+ DeviceObject,
+ &DeviceName, sizeof(DeviceName),
VolumePathPtr, Length,
FALSE, &Event, &IoStatusBlock);
if (!Irp)
@@ -1405,7 +1399,6 @@ IoVolumeDeviceToDosName(IN PVOID VolumeDeviceObject,
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
Status = IoStatusBlock.Status;
}
-
if (!NT_SUCCESS(Status))
{
goto ReleaseMemory;
@@ -1420,16 +1413,15 @@ IoVolumeDeviceToDosName(IN PVOID VolumeDeviceObject,
RtlMoveMemory(DosName->Buffer, VolumePathPtr->MultiSz,
VolumePathPtr->MultiSzLength);
DosName->Buffer[DosName->Length / sizeof(WCHAR)] = UNICODE_NULL;
- /* DON'T release buffer, just dereference FO, and return success */
+ /* Don't release the buffer, just dereference the FO and return success */
Status = STATUS_SUCCESS;
- goto DereferenceFO;
+ goto Quit;
ReleaseMemory:
ExFreePoolWithTag(VolumePathPtr, 'D2d ');
-DereferenceFO:
+Quit:
ObDereferenceObject(FileObject);
-
return Status;
}