https://git.reactos.org/?p=reactos.git;a=commitdiff;h=86eebc2a311b30590d8cc…
commit 86eebc2a311b30590d8ccf349910bd162f94b109
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sat Nov 27 01:36:56 2021 +0100
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Sun Nov 28 00:26:45 2021 +0100
[NTVDM] disk.c: Simplify some code; unmount only present disks during cleanup (avoids
useless debug-print errors).
---
subsystems/mvdm/ntvdm/hardware/disk.c | 45 +++++++++++++++--------------------
1 file changed, 19 insertions(+), 26 deletions(-)
diff --git a/subsystems/mvdm/ntvdm/hardware/disk.c
b/subsystems/mvdm/ntvdm/hardware/disk.c
index 7f448a6f81b..b2ccb65be96 100644
--- a/subsystems/mvdm/ntvdm/hardware/disk.c
+++ b/subsystems/mvdm/ntvdm/hardware/disk.c
@@ -186,7 +186,7 @@ static DISK_GEO DiskGeometryList[] =
{2880, 36, 2, 80, 6},
};
-BOOLEAN
+static BOOLEAN
MountFDI(IN PDISK_IMAGE DiskImage,
IN HANDLE hFile)
{
@@ -242,7 +242,7 @@ MountFDI(IN PDISK_IMAGE DiskImage,
// Secondary Master Drive, Secondary Slave Drive.
static DISK_IMAGE XDCHardDrive[4];
-BOOLEAN
+static BOOLEAN
MountHDD(IN PDISK_IMAGE DiskImage,
IN HANDLE hFile)
{
@@ -525,26 +525,13 @@ MountDisk(IN DISK_TYPE DiskType,
/* Try to open the file */
SetLastError(0); // For debugging purposes
- if (ReadOnly)
- {
- hFile = CreateFileW(FileName,
- GENERIC_READ,
- FILE_SHARE_READ,
- NULL,
- OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
- }
- else
- {
- hFile = CreateFileW(FileName,
- GENERIC_READ | GENERIC_WRITE,
- 0, // No sharing access
- NULL,
- OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
- }
+ hFile = CreateFileW(FileName,
+ GENERIC_READ | (ReadOnly ? 0 : GENERIC_WRITE),
+ (ReadOnly ? FILE_SHARE_READ : 0),
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
DPRINT1("File '%S' opening %s ; GetLastError() = %u\n",
FileName, hFile != INVALID_HANDLE_VALUE ? "succeeded" :
"failed", GetLastError());
@@ -638,13 +625,19 @@ VOID DiskCtrlCleanup(VOID)
{
ULONG DiskNumber;
- /* Unmount all the floppy disk drives */
+ /* Unmount all the present floppy disk drives */
for (DiskNumber = 0; DiskNumber < DiskMountInfo[FLOPPY_DISK].NumDisks;
++DiskNumber)
- UnmountDisk(FLOPPY_DISK, DiskNumber);
+ {
+ if (IsDiskPresent(&DiskMountInfo[FLOPPY_DISK].DiskArray[DiskNumber]))
+ UnmountDisk(FLOPPY_DISK, DiskNumber);
+ }
- /* Unmount all the hard disk drives */
+ /* Unmount all the present hard disk drives */
for (DiskNumber = 0; DiskNumber < DiskMountInfo[HARD_DISK].NumDisks;
++DiskNumber)
- UnmountDisk(HARD_DISK, DiskNumber);
+ {
+ if (IsDiskPresent(&DiskMountInfo[HARD_DISK].DiskArray[DiskNumber]))
+ UnmountDisk(HARD_DISK, DiskNumber);
+ }
}
/* EOF */