ppc64-diag
Macros | Functions
dump.c File Reference

Routines to handle platform dump and scanlog dump RTAS events. More...

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <librtas.h>
#include <librtasevent.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include "utils.h"
#include "rtas_errd.h"

Macros

#define DUMP_MAX_FNAME_LEN   40
 
#define DUMP_BUF_SZ   4096
 
#define EXTRACT_PLATDUMP_CMD   "/usr/sbin/extract_platdump"
 
#define SCANLOG_DUMP_FILE   "/proc/ppc64/scan-log-dump"
 
#define SCANLOG_DUMP_EXISTS   "/proc/device-tree/chosen/ibm,scan-log-data"
 
#define SYSID_FILE   "/proc/device-tree/system-id"
 
#define SCANLOG_MODULE   "scanlog"
 
#define MODPROBE_PROGRAM   "/sbin/modprobe"
 

Functions

static char * get_machine_serial ()
 Retrieve a machines serial number. More...
 
static int load_scanlog_module (int load)
 Load/Unload scanlog module. More...
 
void check_scanlog_dump (void)
 Check for new scanlog dumps. More...
 
void check_platform_dump (struct event *event)
 Check RTAS event for a platform dump. More...
 

Detailed Description

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

◆ DUMP_BUF_SZ

#define DUMP_BUF_SZ   4096

Referenced by check_scanlog_dump().

◆ DUMP_MAX_FNAME_LEN

#define DUMP_MAX_FNAME_LEN   40

Referenced by check_platform_dump().

◆ EXTRACT_PLATDUMP_CMD

#define EXTRACT_PLATDUMP_CMD   "/usr/sbin/extract_platdump"

Referenced by check_platform_dump().

◆ MODPROBE_PROGRAM

#define MODPROBE_PROGRAM   "/sbin/modprobe"

Referenced by load_scanlog_module().

◆ SCANLOG_DUMP_EXISTS

#define SCANLOG_DUMP_EXISTS   "/proc/device-tree/chosen/ibm,scan-log-data"

Referenced by check_scanlog_dump().

◆ SCANLOG_DUMP_FILE

#define SCANLOG_DUMP_FILE   "/proc/ppc64/scan-log-dump"

◆ SCANLOG_MODULE

#define SCANLOG_MODULE   "scanlog"

Referenced by load_scanlog_module().

◆ SYSID_FILE

#define SYSID_FILE   "/proc/device-tree/system-id"

Referenced by get_machine_serial().

Function Documentation

◆ check_platform_dump()

void check_platform_dump ( struct event event)

check_platform_dump Parses error information to determine if it indicates the availability of a platform dump. The platform dump is copied to the filesystem, and the error log is updated to indicate the path to the dump.

This should be invoked before the error information is written to LOG_FILE, because the error may need to be updated with the path to the dump.

Parameters
eventpointer to struct event

References event::addl_text, ADDL_TEXT_MAX, d_cfg, dbg, DUMP_MAX_FNAME_LEN, EXTRACT_PLATDUMP_CMD, log_msg(), ppc64_diag_config::platform_dump_path, platform_log_write(), RE_PLATDUMP_AVAIL, restore_sigchld_default(), event::rtas_event, and setup_sigchld_handler().

Referenced by handle_rtas_event().

◆ check_scanlog_dump()

void check_scanlog_dump ( void  )

check_scanlog_dump This routine checks to see if a new scanlog dump is available, and if so, copies it to the filesystem. The return value is the filename of the new scanlog dump, or NULL if one is not copied. This routine will malloc space for the returned string; it is up to the caller to free it.

This routine should be invoked once when the daemon is started.

References d_cfg, DUMP_BUF_SZ, get_machine_serial(), load_scanlog_module(), log_msg(), scanlog, SCANLOG_DUMP_EXISTS, SCANLOG_DUMP_FILE, and ppc64_diag_config::scanlog_dump_path.

Referenced by main().

◆ get_machine_serial()

static char* get_machine_serial ( )
static

get_machine_serial Return a string containing the machine's serial number, obtained from procfs (the file named SYSID_FILE). This routine mallocs a new string; it is the caller's responsibility to ensure that the string is freed.

Returns
pointer to (allocated) string, NULL on failure

References log_msg(), and SYSID_FILE.

Referenced by check_scanlog_dump().

◆ load_scanlog_module()

static int load_scanlog_module ( int  load)
static

load_scanlog_module Loads or unloads the scanlog module. The load parameter should be 1 to load the module, or 0 to unload it.

Parameters
loaddirective to load/unload module
Returns
0 on success, !0 on failure.

References log_msg(), MODPROBE_PROGRAM, SCANLOG_DUMP_FILE, and SCANLOG_MODULE.

Referenced by check_scanlog_dump().