beautypg.com

Sun Microsystems Netra CP2500 User Manual

Page 21

background image

Chapter 1

Watchdog Timer

7

#define WATCHDOG_DISARMED "disarmed"

/*

* data structure that will be passed as argument to

* picl_walk_tree_by_class callback function

*/

typedef struct {

int start_index;

int max_index;

char **list;

char *name;

char *action;

char *op;

int32_t timeout;

int error_code;

} wdadm_args_t;

static char *prog;

static picl_nodehdl_t rooth;

static int count = 0;

/*

* Error mesage texts

*/

static char *err_msg[] = {

/* program usage */

USAGE_STR, /* 0 */

/* picl call failed messages */

"picl_initialize failed: %s\n", /* 1 */

"picl_get_root failed: %s\n", /* 2 */

"picl_get_propval_by_name failed: %s\n" /* 3 */

};

#define NUM_ERROR_CODES 7

/* mapping between picl error codes and errno */

static int error_map[][2] = {

{PICL_SUCCESS, 0}, { PICL_FAILURE, -1}, {PICL_VALUETOOBIG, E2BIG},

{PICL_NODENOTFOUND, ENODEV}, {PICL_PERMDENIED, EPERM},

{PICL_NOSPACE, ENOMEM}, {PICL_INVALIDARG, EINVAL} };

static int

picl2errno(int piclerr)

{

int i;

for (i = 0; i < NUM_ERROR_CODES; i++) {

if (error_map[i][0] == piclerr)

return (error_map[i][1]);

CODE EXAMPLE 1-1

System Watchdog Node Management Code Example (Continued)