|
ppc64-diag
|
File Manipulation routines for files used by rtas_errd. More...
#include <stdio.h>#include <stdlib.h>#include <fcntl.h>#include <unistd.h>#include <errno.h>#include <time.h>#include <stdarg.h>#include <string.h>#include <ctype.h>#include <libgen.h>#include <sys/stat.h>#include <sys/mman.h>#include <sys/wait.h>#include "rtas_errd.h"Macros | |
| #define | RTAS_ERRD_LOGSZ 25000 |
| Maximum size of the rtas_errd_log. More... | |
Functions | |
| int | init_files (void) |
| Initialize files used by rtas_errd. More... | |
| void | close_files (void) |
| Close all the files used by rtas_errd. More... | |
| int | read_proc_error_log (char *buf, int buflen) |
| Read data from proc_error_log. More... | |
| int | reformat_msg (char *msg) |
| Re-format a log message to wrap at 80 characters. More... | |
| static void | _log_msg (struct event *event, const char *fmt, va_list ap) |
| The real routine to write messages to rtas_errd_log. More... | |
| void | cfg_log (char *fmt,...) |
| dummy interface for calls to diag_cfg More... | |
| void | log_msg (struct event *event, char *fmt,...) |
| Log messages to rtas_errd_log. More... | |
| void | _dbg (const char *fmt,...) |
| Write debug messages to stdout. More... | |
| int | print_rtas_event (struct event *event) |
| Print an RTAS event to the platform log. More... | |
| int | platform_log_write (char *fmt,...) |
| Write messages to the platform log. More... | |
| void | update_epow_status_file (int status) |
| Update the epow status file. More... | |
Variables | |
| char * | platform_log = "/var/log/platform" |
| int | platform_log_fd = -1 |
| char * | proc_error_log1 = "/proc/ppc64/rtas/error_log" |
| File to read RTAS events from. More... | |
| char * | proc_error_log2 = "/proc/ppc64/error_log" |
| Alternate file to read RTAS events from. More... | |
| static int | proc_error_log_fd = -1 |
| File descriptor for proc_error_log. More... | |
| char * | rtas_errd_log = "/var/log/rtas_errd.log" |
| Message log for the rtas_errd daemon. More... | |
| char * | rtas_errd_log0 = "/var/log/rtas_errd.log0" |
| Saved ("rolled over") messages log for rtas_errd daemon. More... | |
| static int | rtas_errd_log_fd = -1 |
| File descriptor for rtas_errd_log. More... | |
| static int | epow_status_fd = -1 |
| char * | epow_status_file = "/var/log/epow_status" |
| char * | scanlog = NULL |
| buffer to hold scanlog dump path More... | |
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.
| #define RTAS_ERRD_LOGSZ 25000 |
Referenced by _log_msg().
| void _dbg | ( | const char * | fmt, |
| ... | |||
| ) |
dbg Provide utility to print debug statements if the debug flag is specified.
| fmt | format string a la printf() |
| ... | args a la printf() |
References debug, reformat_msg(), and RTAS_ERROR_LOG_MAX.
Referenced by _log_msg().
|
static |
_log_msg This is a common routine for formatting messages that go to the /var/log/rtas_errd.log file. Users should pass in a reference to the rtas_event structure if this message is directly related a rtas event and a formatted message a la printf() style. Please make sure that the message passed in does not have any ending punctuation or ends with a newline. It should also not have any internal newlines.
This routine will do several things to the message before printing it out;
| event | reference to event |
| fmt | formatted string a la printf() |
| ... | additional args a la printf() |
References _dbg(), dbg, log_msg(), reformat_msg(), rtas_errd_log, rtas_errd_log0, rtas_errd_log_fd, RTAS_ERRD_LOGSZ, RTAS_ERROR_LOG_MAX, and event::seq_num.
| void cfg_log | ( | char * | fmt, |
| ... | |||
| ) |
cfg_log
| fmt | formatted string a la printf() |
| ... | additional args a la printf() |
References _log_msg().
Referenced by main(), read_rtas_events(), and sighup_handler().
| void close_files | ( | void | ) |
close_files Perform any file cleanup (i.e. close()) and possibly free()'ing buffers needed by rtas_errd before exiting.
References epow_status_fd, platform_log_fd, proc_error_log_fd, and rtas_errd_log_fd.
Referenced by main().
| int init_files | ( | void | ) |
init_files Open the following files needed by the rtas_errd daemon: rtas_errd_log proc_error_log platform_log epow_status
Note: This should only be called once before any rtas_events are read.
References debug, log_msg(), platform_log, platform_log_fd, proc_error_log1, proc_error_log2, proc_error_log_fd, rtas_errd_log, rtas_errd_log_fd, and update_epow_status_file().
Referenced by main().
| void log_msg | ( | struct event * | event, |
| char * | fmt, | ||
| ... | |||
| ) |
log_msg
| event | reference to event |
| fmt | formatted string a la printf() |
| ... | additional args a la printf() |
References _log_msg().
Referenced by _log_msg(), add_callout(), can_delete_lmb(), check_eeh(), check_epow(), check_platform_dump(), check_scanlog_dump(), diag_cfg(), get_dt_status(), get_event_date(), get_machine_serial(), guard_cpu(), guard_memlmb(), guard_mempage(), guard_spcpu(), handle_hotplug_event(), handle_resource_dealloc(), handle_rtas_event(), init_d_cfg(), init_files(), load_scanlog_module(), log_epow(), log_event(), main(), parse_epow(), parse_lparcfg(), print_rtas_event(), process_pre_v6(), process_v6(), read_proc_error_log(), read_rtas_events(), report_menugoal(), report_src(), report_srn(), restore_sigchld_default(), retrieve_drc_name(), run_drmgr(), set_srn_and_callouts(), setup_sigchld_handler(), update_epow_status_file(), and update_rtas_msgs().
| int platform_log_write | ( | char * | fmt, |
| ... | |||
| ) |
platform_log_write Provide a printf() style interface to write messages to platform_log. All messages are prepended with "ppc64-diag" to match the expected format of the platform log.
| fmt | format string a la printf() |
| ... | additional args a la printf() |
References platform_log_fd.
Referenced by check_eeh(), check_platform_dump(), guard_cpu(), guard_memlmb(), guard_spcpu(), and handle_rtas_event().
| int print_rtas_event | ( | struct event * | event | ) |
print_rtas_event Prints the binary hexdump of an RTAS event to the PLATFORM_LOG file.
| event | pointer to the struct event to print |
References dbg, event::event_buf, event::flags, log_msg(), platform_log, platform_log_fd, RE_SCANLOG_AVAIL, scanlog, and event::seq_num.
Referenced by handle_rtas_event().
| int read_proc_error_log | ( | char * | buf, |
| int | buflen | ||
| ) |
read_proc_error_log Read the data in from the /proc error log file. This routine also handles the debug case of reading in a test file that contains an ascii representation of a RTAS event.
| buf | buffer to read RTAS event in to. |
| buflen | length of buffer parameter |
References log_msg(), proc_error_log1, proc_error_log2, and proc_error_log_fd.
Referenced by read_rtas_events().
| int reformat_msg | ( | char * | msg | ) |
reformat_msg In order to ease the formatting of messages in the rtas_errd daemon this will automatically format the messages to wrap at 80 characters.
| msg | buffer containing the message to re-format |
References RTAS_ERROR_LOG_MAX.
Referenced by _dbg(), and _log_msg().
| void update_epow_status_file | ( | int | status | ) |
update_epow_status_file Used to write the current EPOW status (as defined in the parse_epow() function (epow.c) comment) to the epow_status file.
| status | value to update epow_status file to. |
References epow_status_fd, epow_status_file, and log_msg().
Referenced by check_epow(), epow_timer_handler(), and init_files().
|
static |
Referenced by close_files(), and update_epow_status_file().
| char* epow_status_file = "/var/log/epow_status" |
Referenced by main(), print_usage(), and update_epow_status_file().
| char* platform_log = "/var/log/platform" |
Referenced by handle_rtas_event(), init_files(), main(), print_rtas_event(), print_usage(), and update_rtas_msgs().
| int platform_log_fd = -1 |
Referenced by close_files(), init_files(), platform_log_write(), print_rtas_event(), and update_rtas_msgs().
| proc_error_log1 = "/proc/ppc64/rtas/error_log" |
Referenced by init_files(), main(), and read_proc_error_log().
| proc_error_log2 = "/proc/ppc64/error_log" |
Referenced by init_files(), main(), and read_proc_error_log().
|
static |
Referenced by close_files(), init_files(), and read_proc_error_log().
| rtas_errd_log = "/var/log/rtas_errd.log" |
Referenced by _log_msg(), init_files(), main(), and print_usage().
| rtas_errd_log0 = "/var/log/rtas_errd.log0" |
Referenced by _log_msg().
|
static |
Referenced by _log_msg(), close_files(), and init_files().
| scanlog = NULL |
This is a buffer that is allocated and filled when rtas_errd is initially exec()'ed via check_scanlog_dump(). The buffer will contain the path to a scanlog dump and is reported with the first RTAS event we receive from the kernel.
Referenced by check_scanlog_dump(), print_rtas_event(), and read_rtas_events().
1.8.13