From 641850501054c2cd04f187dce301e755206e9959 Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=A9=20van=20Geldorp?= Date: Sat, 31 Dec 2005 19:50:29 +0000 Subject: [PATCH 1/1] On FAT16 partitions smaller than 128MB, the cluster size is 2048, which is smaller than PAGE_SIZE. This caused creation of the paging file on such a partition to fail, which in turn made SMSS fail, blocking the boot process. Creation of paging file fixed, and failure to create it is no longer a blocker for the boot process (just try to run without paging file). svn path=/trunk/; revision=20493 --- reactos/ntoskrnl/mm/pagefile.c | 50 +++++++++++++++++++++++++-------- reactos/subsys/smss/initobdir.c | 6 ++-- reactos/subsys/smss/initpage.c | 14 +++++---- reactos/subsys/smss/print.c | 3 +- reactos/subsys/smss/smss.c | 3 -- 5 files changed, 51 insertions(+), 25 deletions(-) diff --git a/reactos/ntoskrnl/mm/pagefile.c b/reactos/ntoskrnl/mm/pagefile.c index 1303c0016de..91d8beb5689 100644 --- a/reactos/ntoskrnl/mm/pagefile.c +++ b/reactos/ntoskrnl/mm/pagefile.c @@ -809,13 +809,6 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName, PreviousMode = ExGetPreviousMode(); - Status = ProbeAndCaptureUnicodeString(&CapturedFileName, - PreviousMode, - FileName); - if (!NT_SUCCESS(Status)) - { - return(Status); - } if (PreviousMode != KernelMode) { _SEH_TRY @@ -831,8 +824,6 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName, if (!NT_SUCCESS(Status)) { - ReleaseCapturedUnicodeString(&CapturedFileName, - PreviousMode); return Status; } } @@ -842,6 +833,29 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName, SafeMaximumSize = *MaximumSize; } + /* Pagefiles can't be larger than 4GB and ofcourse the minimum should be + smaller than the maximum */ + if (0 != SafeInitialSize.u.HighPart) + { + return STATUS_INVALID_PARAMETER_2; + } + if (0 != SafeMaximumSize.u.HighPart) + { + return STATUS_INVALID_PARAMETER_3; + } + if (SafeMaximumSize.u.LowPart < SafeInitialSize.u.LowPart) + { + return STATUS_INVALID_PARAMETER_MIX; + } + + Status = ProbeAndCaptureUnicodeString(&CapturedFileName, + PreviousMode, + FileName); + if (!NT_SUCCESS(Status)) + { + return(Status); + } + InitializeObjectAttributes(&ObjectAttributes, &CapturedFileName, 0, @@ -881,12 +895,24 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName, return Status; } - BytesPerAllocationUnit = FsSizeInformation.SectorsPerAllocationUnit * FsSizeInformation.BytesPerSector; - if (BytesPerAllocationUnit % PAGE_SIZE) + BytesPerAllocationUnit = FsSizeInformation.SectorsPerAllocationUnit * + FsSizeInformation.BytesPerSector; + + /* We have to find a value which is a multiple of both PAGE_SIZE and + BytesPerAllocationUnit */ + SafeInitialSize.u.LowPart = ((SafeInitialSize.u.LowPart + PAGE_SIZE - 1) / + PAGE_SIZE) * PAGE_SIZE; + while (0 != (SafeInitialSize.u.LowPart % BytesPerAllocationUnit) && + SafeInitialSize.u.LowPart <= SafeMaximumSize.u.LowPart - PAGE_SIZE) + { + SafeInitialSize.u.LowPart += PAGE_SIZE; + } + if (0 != (SafeInitialSize.u.LowPart % BytesPerAllocationUnit)) { ZwClose(FileHandle); - return STATUS_UNSUCCESSFUL; + return STATUS_ALLOTTED_SPACE_EXCEEDED; } + ASSERT(0 == (SafeInitialSize.u.LowPart % PAGE_SIZE)); Status = ZwSetInformationFile(FileHandle, &IoStatus, diff --git a/reactos/subsys/smss/initobdir.c b/reactos/subsys/smss/initobdir.c index 1eb45a0d0ae..df65eca50d1 100644 --- a/reactos/subsys/smss/initobdir.c +++ b/reactos/subsys/smss/initobdir.c @@ -41,10 +41,8 @@ SmpObjectDirectoryQueryRoutine(PWSTR ValueName, HANDLE WindowsDirectory; NTSTATUS Status = STATUS_SUCCESS; -#ifndef NDEBUG - DbgPrint("ValueName '%S' Type %lu Length %lu\n", ValueName, ValueType, ValueLength); - DbgPrint("ValueData '%S'\n", (PWSTR)ValueData); -#endif + DPRINT("ValueName '%S' Type %lu Length %lu\n", ValueName, ValueType, ValueLength); + DPRINT("ValueData '%S'\n", (PWSTR)ValueData); if (ValueType != REG_SZ) { return(STATUS_SUCCESS); diff --git a/reactos/subsys/smss/initpage.c b/reactos/subsys/smss/initpage.c index 89b5f2bb363..bcc79bea773 100644 --- a/reactos/subsys/smss/initpage.c +++ b/reactos/subsys/smss/initpage.c @@ -1,5 +1,4 @@ -/* $Id$ - * +/* * initpage.c - * * ReactOS Operating System @@ -217,18 +216,23 @@ SmpPagingFilesQueryRoutine(PWSTR ValueName, MaximumSize.QuadPart = InitialSize.QuadPart; } - DPRINT1("SMSS: Created paging file %wZ with size %I64d KB\n", + DPRINT("Creating paging file %wZ with size %I64d KB\n", &FileName, InitialSize.QuadPart / 1024); Status = NtCreatePagingFile(&FileName, &InitialSize, &MaximumSize, 0); + if (! NT_SUCCESS(Status)) + { + PrintString("Creation of paging file %wZ with size %I64d KB failed (status 0x%x\n", + &FileName, InitialSize.QuadPart / 1024); + } Cleanup: RtlFreeUnicodeString(&FileName); - return Status; + return STATUS_SUCCESS; } @@ -238,7 +242,7 @@ SmCreatePagingFiles(VOID) RTL_QUERY_REGISTRY_TABLE QueryTable[2]; NTSTATUS Status; - DbgPrint("SM: creating system paging files\n"); + DPRINT("creating system paging files\n"); /* * Disable paging file on MiniNT/Live CD. */ diff --git a/reactos/subsys/smss/print.c b/reactos/subsys/smss/print.c index 4a8c4380717..9b27cf5cfcb 100644 --- a/reactos/subsys/smss/print.c +++ b/reactos/subsys/smss/print.c @@ -31,7 +31,7 @@ VOID STDCALL DisplayString(LPCWSTR lpwString) UNICODE_STRING us; RtlInitUnicodeString (&us, lpwString); - ZwDisplayString (&us); + NtDisplayString (&us); } VOID STDCALL PrintString (char* fmt, ...) @@ -44,6 +44,7 @@ VOID STDCALL PrintString (char* fmt, ...) va_start(ap, fmt); vsprintf(buffer, fmt, ap); va_end(ap); + DPRINT1("%s", buffer); RtlInitAnsiString (&AnsiString, buffer); RtlAnsiStringToUnicodeString (&UnicodeString, diff --git a/reactos/subsys/smss/smss.c b/reactos/subsys/smss/smss.c index 0258d7419eb..4aad777e836 100644 --- a/reactos/subsys/smss/smss.c +++ b/reactos/subsys/smss/smss.c @@ -41,9 +41,6 @@ NTSTATUS __cdecl _main(int argc, NTSTATUS Status = STATUS_SUCCESS; PROCESS_BASIC_INFORMATION PBI = {0}; - PrintString("ReactOS Session Manager (Build %s)\n", - KERNEL_VERSION_BUILD_STR); - /* Lookup yourself */ Status = NtQueryInformationProcess (NtCurrentProcess(), ProcessBasicInformation, -- 2.17.1