Author: ekohl
Date: Sat Feb 4 11:34:13 2012
New Revision: 55406
URL:
http://svn.reactos.org/svn/reactos?rev=55406&view=rev
Log:
[EVENTLOG]
- Change LogfInitializeNew and LogfInitializeExisting to return an NTSTATUS code instead
of a BOOL value.
- LogfInitializeExisting no longer calls LogfInitializeNew when reading a log file fails
but returns a proper status code instead.
Modified:
trunk/reactos/base/services/eventlog/eventlog.h
trunk/reactos/base/services/eventlog/file.c
Modified: trunk/reactos/base/services/eventlog/eventlog.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/eventlog/eve…
==============================================================================
--- trunk/reactos/base/services/eventlog/eventlog.h [iso-8859-1] (original)
+++ trunk/reactos/base/services/eventlog/eventlog.h [iso-8859-1] Sat Feb 4 11:34:13 2012
@@ -168,10 +168,6 @@
VOID LogfCloseAll(VOID);
-BOOL LogfInitializeNew(PLOGFILE LogFile);
-
-BOOL LogfInitializeExisting(PLOGFILE LogFile);
-
DWORD LogfGetOldestRecord(PLOGFILE LogFile);
DWORD LogfGetCurrentRecord(PLOGFILE LogFile);
Modified: trunk/reactos/base/services/eventlog/file.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/eventlog/fil…
==============================================================================
--- trunk/reactos/base/services/eventlog/file.c [iso-8859-1] (original)
+++ trunk/reactos/base/services/eventlog/file.c [iso-8859-1] Sat Feb 4 11:34:13 2012
@@ -18,7 +18,8 @@
/* FUNCTIONS ****************************************************************/
-BOOL LogfInitializeNew(PLOGFILE LogFile)
+static NTSTATUS
+LogfInitializeNew(PLOGFILE LogFile)
{
DWORD dwWritten;
EVENTLOGEOF EofRec;
@@ -46,7 +47,7 @@
NULL))
{
DPRINT1("WriteFile failed:%d!\n", GetLastError());
- return FALSE;
+ return STATUS_UNSUCCESSFUL;
}
EofRec.Ones = 0x11111111;
@@ -67,19 +68,21 @@
NULL))
{
DPRINT1("WriteFile failed:%d!\n", GetLastError());
- return FALSE;
+ return STATUS_UNSUCCESSFUL;
}
if (!FlushFileBuffers(LogFile->hFile))
{
DPRINT1("FlushFileBuffers failed:%d!\n", GetLastError());
- return FALSE;
- }
-
- return TRUE;
-}
-
-BOOL LogfInitializeExisting(PLOGFILE LogFile)
+ return STATUS_UNSUCCESSFUL;
+ }
+
+ return STATUS_SUCCESS;
+}
+
+
+static NTSTATUS
+LogfInitializeExisting(PLOGFILE LogFile)
{
DWORD dwRead;
DWORD dwRecordsNumber = 0;
@@ -94,7 +97,7 @@
INVALID_SET_FILE_POINTER)
{
DPRINT1("SetFilePointer failed! %d\n", GetLastError());
- return FALSE;
+ return STATUS_EVENTLOG_FILE_CORRUPT;
}
if (!ReadFile(LogFile->hFile,
@@ -104,34 +107,34 @@
NULL))
{
DPRINT1("ReadFile failed! %d\n", GetLastError());
- return FALSE;
+ return STATUS_EVENTLOG_FILE_CORRUPT;
}
if (dwRead != sizeof(EVENTLOGHEADER))
{
DPRINT("EventLog: Invalid file %S.\n", LogFile->FileName);
- return LogfInitializeNew(LogFile);
+ return STATUS_EVENTLOG_FILE_CORRUPT;
}
if (LogFile->Header.HeaderSize != sizeof(EVENTLOGHEADER) ||
LogFile->Header.EndHeaderSize != sizeof(EVENTLOGHEADER))
{
DPRINT("EventLog: Invalid header size in %S.\n",
LogFile->FileName);
- return LogfInitializeNew(LogFile);
+ return STATUS_EVENTLOG_FILE_CORRUPT;
}
if (LogFile->Header.Signature != LOGFILE_SIGNATURE)
{
DPRINT("EventLog: Invalid signature %x in %S.\n",
LogFile->Header.Signature, LogFile->FileName);
- return LogfInitializeNew(LogFile);
+ return STATUS_EVENTLOG_FILE_CORRUPT;
}
if (LogFile->Header.EndOffset > GetFileSize(LogFile->hFile, NULL) + 1)
{
DPRINT("EventLog: Invalid eof offset %x in %S.\n",
LogFile->Header.EndOffset, LogFile->FileName);
- return LogfInitializeNew(LogFile);
+ return STATUS_EVENTLOG_FILE_CORRUPT;
}
/* Set the read location to the oldest record */
@@ -139,7 +142,7 @@
if (dwFilePointer == INVALID_SET_FILE_POINTER)
{
DPRINT1("SetFilePointer failed! %d\n", GetLastError());
- return FALSE;
+ return STATUS_EVENTLOG_FILE_CORRUPT;
}
for (;;)
@@ -149,7 +152,7 @@
if (dwFilePointer == INVALID_SET_FILE_POINTER)
{
DPRINT1("SetFilePointer failed! %d\n", GetLastError());
- return FALSE;
+ return STATUS_EVENTLOG_FILE_CORRUPT;
}
/* If the EVENTLOGEOF info has been reached and the oldest record was not
immediately after the Header */
@@ -167,7 +170,7 @@
NULL))
{
DPRINT1("ReadFile failed! %d\n", GetLastError());
- return FALSE;
+ return STATUS_EVENTLOG_FILE_CORRUPT;
}
if (dwRead != sizeof(dwRecSize))
@@ -180,7 +183,7 @@
NULL))
{
DPRINT1("ReadFile() failed! %d\n", GetLastError());
- return FALSE;
+ return STATUS_EVENTLOG_FILE_CORRUPT;
}
if (dwRead != sizeof(dwRecSize))
@@ -199,22 +202,21 @@
FILE_CURRENT) == INVALID_SET_FILE_POINTER)
{
DPRINT1("SetFilePointer() failed! %d", GetLastError());
- return FALSE;
+ return STATUS_EVENTLOG_FILE_CORRUPT;
}
RecBuf = (PEVENTLOGRECORD) HeapAlloc(MyHeap, 0, dwRecSize);
-
- if (!RecBuf)
+ if (RecBuf == NULL)
{
DPRINT1("Can't allocate heap!\n");
- return FALSE;
+ return STATUS_NO_MEMORY;
}
if (!ReadFile(LogFile->hFile, RecBuf, dwRecSize, &dwRead, NULL))
{
DPRINT1("ReadFile() failed! %d\n", GetLastError());
HeapFree(MyHeap, 0, RecBuf);
- return FALSE;
+ return STATUS_EVENTLOG_FILE_CORRUPT;
}
if (dwRead != dwRecSize)
@@ -248,7 +250,7 @@
{
DPRINT1("LogfAddOffsetInformation() failed!\n");
HeapFree(MyHeap, 0, RecBuf);
- return FALSE;
+ return STATUS_EVENTLOG_FILE_CORRUPT;
}
HeapFree(MyHeap, 0, RecBuf);
@@ -266,7 +268,7 @@
INVALID_SET_FILE_POINTER)
{
DPRINT1("SetFilePointer() failed! %d\n", GetLastError());
- return FALSE;
+ return STATUS_EVENTLOG_FILE_CORRUPT;
}
if (!WriteFile(LogFile->hFile,
@@ -276,16 +278,16 @@
NULL))
{
DPRINT1("WriteFile failed! %d\n", GetLastError());
- return FALSE;
+ return STATUS_EVENTLOG_FILE_CORRUPT;
}
if (!FlushFileBuffers(LogFile->hFile))
{
DPRINT1("FlushFileBuffers failed! %d\n", GetLastError());
- return FALSE;
- }
-
- return TRUE;
+ return STATUS_EVENTLOG_FILE_CORRUPT;
+ }
+
+ return STATUS_SUCCESS;
}
@@ -299,7 +301,7 @@
OBJECT_ATTRIBUTES ObjectAttributes;
IO_STATUS_BLOCK IoStatusBlock;
PLOGFILE pLogFile;
- BOOL bResult, bCreateNew = FALSE;
+ BOOL bCreateNew = FALSE;
NTSTATUS Status = STATUS_SUCCESS;
pLogFile = (LOGFILE *) HeapAlloc(MyHeap, HEAP_ZERO_MEMORY, sizeof(LOGFILE));
@@ -376,15 +378,12 @@
pLogFile->Permanent = Permanent;
if (bCreateNew)
- bResult = LogfInitializeNew(pLogFile);
+ Status = LogfInitializeNew(pLogFile);
else
- bResult = LogfInitializeExisting(pLogFile);
-
- if (!bResult)
- {
- Status = STATUS_UNSUCCESSFUL;
+ Status = LogfInitializeExisting(pLogFile);
+
+ if (!NT_SUCCESS(Status))
goto fail;
- }
RtlInitializeResource(&pLogFile->Lock);
@@ -414,6 +413,7 @@
return Status;
}
+
VOID
LogfClose(PLOGFILE LogFile,