Sun Microsystems CP2500 manual Code Example 1-1System Watchdog Node Management Code Example

Models: CP2500

1 74
Download 74 pages 27.58 Kb
Page 31
Image 31

CODE EXAMPLE 1-1System Watchdog Node Management Code Example (Continued)

print_errmsg(gettext(err_msg[EM_GETPVALBYNAME]), picl_strerror(err));

return (err);

}

/*

*check to see if the controller is of interest, otherwise

*move to the next controller.

*/

if (strcmp(cntrl_name, wd_arg->name) != 0) {

return (PICL_WALK_CONTINUE);

}

count++;

/* change the watchdog-controller’s WdOp property */ if ((err = wdadm_set_picl_prop(nodeh, WATCHDOG_OP,

wd_arg->op, strlen(wd_arg->op) + 1)) != PICL_SUCCESS) { (void) fprintf(stderr, "%s:Failed:%d\n", prog,

picl2errno(err));

}

return (err);

}

/*

*Function is used to disarm/arm the watchdog controller

*/

static int

control_wd(char *cntrl_name, char *op)

{

wdadm_args_t wd_arg; int err = PICL_SUCCESS;

if (cntrl_name == NULL op == NULL) {

(void) fprintf(stderr, "%s:Invalid arguments\n", prog); return (PICL_INVALIDARG);

}

wd_arg.name = cntrl_name; wd_arg.op = op; wd_arg.error_code = 1;

err = picl_walk_tree_by_class(rooth, PICL_WATCHDOG_CONTROLLER, (void *)&wd_arg, wd_change_state);

if (count == 0) {

(void) fprintf(stderr, "%s:Invalid controller name\n", prog);

return (PICL_NODENOTFOUND);

}

Chapter 1 Watchdog Timer 17

Page 31
Image 31
Sun Microsystems CP2500 manual Code Example 1-1System Watchdog Node Management Code Example