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

Command to extract a platform dump and copy it to the filesystem. More...

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <getopt.h>
#include <stdarg.h>
#include <fcntl.h>
#include <errno.h>
#include <dirent.h>
#include <stdint.h>
#include <librtas.h>
#include <sys/stat.h>
#include "rtas_errd.h"
#include "platform.h"

Macros

#define DUMP_HDR_PREFIX_OFFSET   0x16 /* prefix size in dump header */
 
#define DUMP_HDR_FNAME_OFFSET   0x18 /* suggested filename in dump header */
 
#define DUMP_MAX_FNAME_LEN   40
 
#define TOKEN_PLATDUMP_MAXSIZE   32
 
#define DUMP_BUF_SZ   4096
 

Functions

void msg (char *fmt,...)
 Print message if verbose flag is set. More...
 
static void print_usage (const char *name)
 Print the usage message for this command. More...
 
static void handle_platform_dump_error (int e, char *err_buf, int sz)
 Interpret librtas return codes. More...
 
void remove_old_dumpfiles (char *dumpname, int prefix_size)
 if needed, remove any old dumpfiles More...
 
int extract_platform_dump (uint64_t dump_tag)
 Extract a platform dump with a given tag to the filesystem. More...
 
int main (int argc, char *argv[])
 

Variables

int flag_v = 0
 
static struct option long_options []
 

Detailed Description

Copyright (C) 2007 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 extract_platform_dump().

◆ DUMP_HDR_FNAME_OFFSET

#define DUMP_HDR_FNAME_OFFSET   0x18 /* suggested filename in dump header */

Referenced by extract_platform_dump().

◆ DUMP_HDR_PREFIX_OFFSET

#define DUMP_HDR_PREFIX_OFFSET   0x16 /* prefix size in dump header */

Referenced by extract_platform_dump().

◆ DUMP_MAX_FNAME_LEN

#define DUMP_MAX_FNAME_LEN   40

◆ TOKEN_PLATDUMP_MAXSIZE

#define TOKEN_PLATDUMP_MAXSIZE   32

Referenced by main().

Function Documentation

◆ extract_platform_dump()

int extract_platform_dump ( uint64_t  dump_tag)

extract_platform_dump

Parameters
dump_tagtag of the platform dump to extract
Returns
0 on success, 1 on failure

References d_cfg, DUMP_BUF_SZ, DUMP_HDR_FNAME_OFFSET, DUMP_HDR_PREFIX_OFFSET, DUMP_MAX_FNAME_LEN, handle_platform_dump_error(), msg(), ppc64_diag_config::platform_dump_path, remove_old_dumpfiles(), and RTAS_ERROR_LOG_MAX.

Referenced by main().

◆ handle_platform_dump_error()

static void handle_platform_dump_error ( int  e,
char *  err_buf,
int  sz 
)
static

handle_platform_dump_error Interpret a return code from librtas for any librtas specific messages.

Parameters
ereturn code from librtas
err_bufbuffer to write librtas message to
szsize of the err_buf parameter

Referenced by extract_platform_dump().

◆ main()

int main ( int  argc,
char *  argv[] 
)

◆ msg()

void msg ( char *  fmt,
  ... 
)

msg

Parameters
fmtformat string a la printf()
...additional args a la printf()

References flag_v.

Referenced by extract_platform_dump(), main(), process_v3_logs(), remove_old_dumpfiles(), report_menugoal(), and report_src().

◆ print_usage()

static void print_usage ( const char *  name)
static

print_usage

Parameters
namethe name of this executable

Referenced by main().

◆ remove_old_dumpfiles()

void remove_old_dumpfiles ( char *  dumpname,
int  prefix_size 
)

remove_old_dumpfiles Users can specify the number of old dumpfiles they wish to save via the config file PlatformDumpMax entry. This routine will search through and removeany dump files of the specified type if the count exceeds the maximum value.

Parameters
dumpnamesuggested filename of the platform dump
prefix_sizelength of the prefix

References d_cfg, DUMP_MAX_FNAME_LEN, msg(), and ppc64_diag_config::platform_dump_path.

Referenced by extract_platform_dump().

Variable Documentation

◆ flag_v

int flag_v = 0

Referenced by main(), and msg().

◆ long_options

struct option long_options[]
static
Initial value:
= {
{"help", no_argument, NULL, 'h'},
{"verbose", no_argument, NULL, 'v'},
{0,0,0,0}
}

Referenced by main().