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

Routines for parsing the ppc64-diag.config file. 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 <sys/stat.h>
#include <sys/mman.h>
#include <sys/wait.h>
#include <librtas.h>
#include "config.h"

Macros

#define RTAS_PARAM_AUTO_RESTART   21
 

Functions

static char * get_token (char *str, char *str_end, char *tok, int *line_no)
 return the next token from the provided buffer. More...
 
static char * get_config_string (char *start, char *end, char *buf, int *line_no)
 retrieve a string associated with a configuration entry More...
 
static char * get_config_num (char *start, char *end, int *val, int *line_no)
 Retrieve a numeric value for a configuration entry. More...
 
static char * get_restart_policy_value (char *start, char *end, int *val, int *line_no)
 Retrieve Auto Restart Policy value. More...
 
static char * config_restart_policy (char *start, char *end, int *line_no, int update_param)
 Configure the Auto Restart Policy for this machine, if present. More...
 
static int parse_config_entries (char *buf, char *buf_end, int update_sysconfig)
 Parse the ppc64-diag config file entries. More...
 
static void init_d_cfg (void(*log_msg)(char *,...))
 initialize the ppc64-diag config structure More...
 
int diag_cfg (int update_sysconfig, void(*log_msg)(char *,...))
 read config components from ppc64-diag config file More...
 

Variables

char * config_file = "/etc/ppc64-diag/ppc64-diag.config"
 default ppc64-diag configuration file More...
 
struct ppc64_diag_config d_cfg
 ppc64-diag configuration structure 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

#define RTAS_PARAM_AUTO_RESTART   21

Referenced by config_restart_policy().

Function Documentation

static char* config_restart_policy ( char *  start,
char *  end,
int *  line_no,
int  update_param 
)
static

config_restart_policy Users can specify an AutoRestartPolicy=X entry in the ppc64-diag configuration file. This will read in that 'X' value and set the corresponding service policy. This is done either by setting the ibm,os-auto-restart parameter in NVRAM (older systems), or by setting the partition_auto_restart system parameter (more recent systems).

Parameters
startplace to start loking
endpointer to end of 'start' buffer
line_norefernece to the current line number
update_paramif zero, the param will not actually be updated
Returns
pointer to current position in the config file, or NULL on failure

References config_file, d_cfg, get_restart_policy_value(), ppc64_diag_config::log_msg, ppc64_diag_config::restart_policy, and RTAS_PARAM_AUTO_RESTART.

Referenced by parse_config_entries().

int diag_cfg ( int  update_sysconfig,
void(*)(char *,...)  log_msg 
)

diag_cfg The config file is in the format of variable=data. Comments in the file are lines beginning with '#' or everything after a '#' character in a line.

Parameters
update_sysconfigif 0, NVRAM will not be updated

References config_file, d_cfg, init_d_cfg(), ppc64_diag_config::log_msg, log_msg(), and parse_config_entries().

Referenced by main(), read_rtas_events(), and sighup_handler().

static char* get_config_num ( char *  start,
char *  end,
int *  val,
int *  line_no 
)
static

get_config_num

Parameters
startshould point to the '=' following an entry name
endend of buffer containing thevalue
valint reference into which the value is copied
line_noreference to the line number in the config file
Returns
pointer to where we stopped parsing or NULL on failure

References get_token().

Referenced by parse_config_entries().

static char* get_config_string ( char *  start,
char *  end,
char *  buf,
int *  line_no 
)
static

get_config_string For the purposes of parsing the ppc64-diag config file a string is considered everything that comes after the '=' character up to the newline ('
') character. Strings can span multiple lines if they end in a '\', but this is handled by get_token() and we only need to look for the newline character here.

Parameters
startshould point to the '=' following an entry name
endend of buffer containing the string
bufbuffer into which the string is copied
line_noreference to the line number in the config file
Returns
pointer to where we stopped parsing or NULL on failure

References get_token().

Referenced by parse_config_entries().

static char* get_restart_policy_value ( char *  start,
char *  end,
int *  val,
int *  line_no 
)
static

get_restart_policy_value Same as get_config_num(), except we handle 0 and negative values here.

References get_token().

Referenced by config_restart_policy().

static char* get_token ( char *  str,
char *  str_end,
char *  tok,
int *  line_no 
)
static

get_token This routine is modified parser/tokenizer for interpreting the ppc64-diag config file.

Parameters
strpoint at which to began looking for tokens
str_endend of token buffer
tokbuffer to be filled in with the found token
line_noreference to line number in the config file
Returns
pointer to where the tokenizer stopped in 'str'

Referenced by get_config_num(), get_config_string(), get_restart_policy_value(), and parse_config_entries().

static void init_d_cfg ( void(*)(char *,...)  log_msg)
static
static int parse_config_entries ( char *  buf,
char *  buf_end,
int  update_sysconfig 
)
static

parse_config_entries

Parameters
bufbuffer containg the ppc64-diag config file contents
buf_endpointer to the end of 'buf'
update_sysconfigif 0, configuration params (in NVRAM) will not update
Returns
0 on success, -1 on error

References config_restart_policy(), d_cfg, get_config_num(), get_config_string(), get_token(), ppc64_diag_config::log_msg, ppc64_diag_config::min_entitled_capacity, ppc64_diag_config::min_processors, ppc64_diag_config::platform_dump_path, and ppc64_diag_config::scanlog_dump_path.

Referenced by diag_cfg().

Variable Documentation

config_file = "/etc/ppc64-diag/ppc64-diag.config"
d_cfg