Author: ekohl
Date: Sat Jan 28 20:15:41 2012
New Revision: 55279
URL:
http://svn.reactos.org/svn/reactos?rev=55279&view=rev
Log:
[EVENTLOG]
- Log files which are opened when the eventlog service is started are permanent files and
will only be closed when the service is stopped. Other log files are closed when their
handle is closed.
- Opening a non existing backup log file must fail.
- Opening an existing backup log files opens the file for reading only.
Modified:
trunk/reactos/base/services/eventlog/eventlog.c
trunk/reactos/base/services/eventlog/eventlog.h
trunk/reactos/base/services/eventlog/file.c
trunk/reactos/base/services/eventlog/rpc.c
Modified: trunk/reactos/base/services/eventlog/eventlog.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/eventlog/eve…
==============================================================================
--- trunk/reactos/base/services/eventlog/eventlog.c [iso-8859-1] (original)
+++ trunk/reactos/base/services/eventlog/eventlog.c [iso-8859-1] Sat Jan 28 20:15:41 2012
@@ -327,7 +327,7 @@
DPRINT("%S -> %S\n", Buf, Expanded);
- Status = LogfCreate(&pLogf, LogName, &FileName);
+ Status = LogfCreate(&pLogf, LogName, &FileName, TRUE, FALSE);
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed to create %S! (Status %08lx)\n", Expanded, Status);
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 Jan 28 20:15:41 2012
@@ -92,6 +92,7 @@
PEVENT_OFFSET_INFO OffsetInfo;
ULONG OffsetInfoSize;
ULONG OffsetInfoNext;
+ BOOL Permanent;
LIST_ENTRY ListEntry;
} LOGFILE, *PLOGFILE;
@@ -157,9 +158,13 @@
NTSTATUS
LogfCreate(PLOGFILE *Logfile,
WCHAR * LogName,
- PUNICODE_STRING FileName);
-
-VOID LogfClose(PLOGFILE LogFile);
+ PUNICODE_STRING FileName,
+ BOOL Permanent,
+ BOOL Backup);
+
+VOID
+LogfClose(PLOGFILE LogFile,
+ BOOL ForceClose);
VOID LogfCloseAll(VOID);
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 Jan 28 20:15:41 2012
@@ -292,7 +292,9 @@
NTSTATUS
LogfCreate(PLOGFILE *LogFile,
WCHAR * LogName,
- PUNICODE_STRING FileName)
+ PUNICODE_STRING FileName,
+ BOOL Permanent,
+ BOOL Backup)
{
OBJECT_ATTRIBUTES ObjectAttributes;
IO_STATUS_BLOCK IoStatusBlock;
@@ -314,13 +316,13 @@
NULL);
Status = NtCreateFile(&pLogFile->hFile,
- GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE,
+ Backup ? (GENERIC_READ | SYNCHRONIZE) : (GENERIC_READ |
GENERIC_WRITE | SYNCHRONIZE),
&ObjectAttributes,
&IoStatusBlock,
NULL,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ,
- FILE_OPEN_IF,
+ Backup ? FILE_OPEN : FILE_OPEN_IF,
FILE_SYNCHRONOUS_IO_NONALERT,
NULL,
0);
@@ -371,6 +373,8 @@
pLogFile->OffsetInfoSize = 64;
+ pLogFile->Permanent = Permanent;
+
if (bCreateNew)
bResult = LogfInitializeNew(pLogFile);
else
@@ -411,9 +415,15 @@
return Status;
}
-VOID LogfClose(PLOGFILE LogFile)
+VOID
+LogfClose(PLOGFILE LogFile,
+ BOOL ForceClose)
{
if (LogFile == NULL)
+ return;
+
+ if ((ForceClose == FALSE) &&
+ (LogFile->Permanent == TRUE))
return;
RtlAcquireResourceExclusive(&LogFile->Lock, TRUE);
@@ -436,7 +446,7 @@
{
while (!IsListEmpty(&LogFileListHead))
{
- LogfClose(LogfListHead());
+ LogfClose(LogfListHead(), TRUE);
}
DeleteCriticalSection(&LogFileListCs);
Modified: trunk/reactos/base/services/eventlog/rpc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/eventlog/rpc…
==============================================================================
--- trunk/reactos/base/services/eventlog/rpc.c [iso-8859-1] (original)
+++ trunk/reactos/base/services/eventlog/rpc.c [iso-8859-1] Sat Jan 28 20:15:41 2012
@@ -158,7 +158,9 @@
/* Create the log file */
Status = LogfCreate(&lpLogHandle->LogFile,
NULL,
- FileName);
+ FileName,
+ FALSE,
+ TRUE);
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed to create the log file! (Status 0x%08lx)\n", Status);
@@ -210,9 +212,7 @@
if (!ElfGetLogHandleEntryByHandle(lpLogHandle))
return STATUS_INVALID_HANDLE;
- /* Close the log file if it is a backup file */
- if (lpLogHandle->Flags & LOG_HANDLE_BACKUP_FILE)
- LogfClose(lpLogHandle->LogFile);
+ LogfClose(lpLogHandle->LogFile, FALSE);
RemoveEntryList(&lpLogHandle->LogHandleListEntry);
HeapFree(GetProcessHeap(),0,lpLogHandle);