ppc64-diag
Macros | Functions | Variables
update.c File Reference

Routines to update RTAS evetns to the platform log. More...

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include "rtas_errd.h"

Macros

#define BM_ARRAY_SIZE   256
 Array size for Boyer-Moore algorithm. More...
 
#define RTAS_START   "RTAS event begin"
 
#define RTAS_END   "RTAS event end"
 

Functions

void setup_bc (char *str, int strlen, int *bc)
 Initalize the bad character array for a Boyer-Moore search. More...
 
char * find_event (char *str, int strlen, char *text, int textlen, int bad_char[])
 Find an RTAS event. More...
 
char * find_rtas_start (char *textstart, char *textend)
 Find the beginning of a RTAS event. More...
 
char * find_rtas_end (char *textstart, char *textend)
 Find the ending of a RTAS event. More...
 
int get_rtas_no (char *ptr)
 Retrieve an RTAS event numnber. More...
 
void update_rtas_msgs (void)
 Update RTAS messages in the platform log. More...
 

Variables

int bad_char_start [BM_ARRAY_SIZE] = {-1}
 Boyer-Moore bad character array for finding RTAS event starts. More...
 
int bad_char_end [BM_ARRAY_SIZE] = {-1}
 Boyer-Moore bad character array for finding RTAS event ends. More...
 
char * messages_log = NULL
 
static int msgs_log_fd = -1
 File descriptor for messages_log. More...
 

Detailed Description

In certain cases, we may need to get RTAS events from syslog and process them to /var/log/platform (i.e. an EPOW event that allows enough time for the RTAS event(s) to be written to syslog but not enough time for rtas_errd to run).

The search implemeted here checks the last RTAS event number in syslog and /var/log/platform. If they are not equal, we process RTAS events from syslog until they are equal.

Copyright (C) 2004 IBM Corporation

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Macro Definition Documentation

#define BM_ARRAY_SIZE   256

Referenced by setup_bc().

#define RTAS_END   "RTAS event end"

Referenced by find_rtas_end().

#define RTAS_START   "RTAS event begin"

Function Documentation

char* find_event ( char *  str,
int  strlen,
char *  text,
int  textlen,
int  bad_char[] 
)

find_event Search for a RTAS event in the given text. This uses a scaled down version of the Boyer-Moore algorithm. Since we know the search strings we also know there really isn't a good suffix worth looking for. Thus we do not use the good suffix rule for this search.

Parameters
strstring to search for
strlenlength of search string
texttext to search for string in
textlenlength of text to search
bad_charbad character array for Boyer-Moore search
Returns
pointer to string in text on success, NULL on failure

References MAX.

Referenced by find_rtas_end(), and find_rtas_start().

char* find_rtas_end ( char *  textstart,
char *  textend 
)

find_rtas_end

Parameters
textstartpointer to starting point of search
textendpointer to ending point of search
Returns
pointer to RTAS event end on success, NULL on failure.

References bad_char_end, find_event(), RTAS_END, and setup_bc().

Referenced by update_rtas_msgs().

char* find_rtas_start ( char *  textstart,
char *  textend 
)

find_rtas_start

Parameters
textstartpointer to starting point of search
textendpointer to ending point of search
Returns
pointer to RTAS event start on success, NULL on failure.

References bad_char_start, find_event(), RTAS_START, and setup_bc().

Referenced by update_rtas_msgs().

int get_rtas_no ( char *  ptr)

get_rtas_no Retrieve the RTAS event number from an RTAS event. NOTE: this routine assumes the pointer passed in is the result from a call to find_rtas_start()

Parameters
ptrpointer to RTAS event
Returns
event number on success, 0 on failure

Referenced by update_rtas_msgs().

void setup_bc ( char *  str,
int  strlen,
int *  bc 
)

setup_bc

Parameters
strsearch string to initialize the array with
strlensearch string length
bcbad character array to be initialized

References BM_ARRAY_SIZE.

Referenced by find_rtas_end(), and find_rtas_start().

void update_rtas_msgs ( void  )

update_rtas_msgs Update the file /var/log/platform with any RTAS events found in syslog that have not been handled by rtas_errd.

References dbg, event::event_buf, find_rtas_end(), find_rtas_start(), get_rtas_no(), handle_rtas_event(), log_msg(), messages_log, msgs_log_fd, platform_log, platform_log_fd, RTAS_ERROR_LOG_MAX, event::rtas_event, and RTAS_START.

Referenced by main().

Variable Documentation

bad_char_end = {-1}

Referenced by find_rtas_end().

bad_char_start = {-1}

Referenced by find_rtas_start().

char* messages_log = NULL

Used by update_rtas_msgs() to bring the platform log up to date with current RTAS events.

Referenced by main(), and update_rtas_msgs().

msgs_log_fd = -1
static

Referenced by update_rtas_msgs().