fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic ncall_node_t *getnodelist(int, int *, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext(" %s -d\n"), progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext(" %s -e\n"), progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext(" %s -h\n"), progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext(" %s -c [nodeid <nodeid>]\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext(" %s -i\n"), progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext(" %s -p <host>\n"), progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext(" -d disable ncall\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext(" -e enable ncall core\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext(" -h this help message\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext(" -c set or print ncall configuration\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext(" -i ncall information\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext(" -p ncall ping <host>\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (snprintf(hostid, sizeof (hostid), "%lx", gethostid()) >=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("%s: hostid %lx too large\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to access the configuration: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to lock the configuration: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to update the configuration: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get config from dscfg.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, "ncallcore.set1", buf, sizeof (buf)) >= 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("%s: ncall is using the SunCluster "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (rc < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("%s: ncall is using the default "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("%s: current configuration:\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* deliberately not i18n'd - "nodeid" is a keyword */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, "ncallcore.set1", buf, sizeof (buf)) >= 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* remove old config */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_put_cstring(cfg, "ncallcore.set1", NULL, 0) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to update the configuration: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (snprintf(buf, sizeof (buf), "%d", nodeid) >= sizeof (buf)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_put_cstring(cfg, "ncallcore", buf, sizeof (buf)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to update the configuration: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("%s: configuration set to:\n"), progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* deliberately not i18n'd - "nodeid" is a keyword */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("%s: unknown option\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(cflag || dflag || eflag || iflag || pflag)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cflag + dflag + eflag + iflag + pflag) > 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: multiple options are not supported\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ioctl stop into kernel */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (eflag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get node info */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to determine hostname: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * check that the nodeids from the cf file and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cluster match.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "(%d) != cluster nodeid (%d)\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (clnodeid > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ioctl node info into kernel and start ncall */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * determine which slot is the mirror node.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("Mirror Node Name: %s\n"), mname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("Mirror Node ID: %d\n"), mnode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See if we need to translate the node strings.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pnodestr = gettext("Node Name: %s\nNode ID: %d\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Don't print the mirror twice.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strlen(ping) >= sizeof (nodeinfo.nc_nodename)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* not self, so ask kernel */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* strlen(ping) checked above */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* model the ping messages on ping(1m) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (up > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("no answer from %s\n"), ping);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "(%d) != cluster nodeid (%d)\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return a pointer to a list of currently configured
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Return the number of nodes via the nodesizep pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Return the mirror nodeid via the mirrorp pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Return NULL on errors.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortegetnodelist(int ifd, int *nodesizep, int *mirrorp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get this host info and mirror nodeid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See if we need to allocate the buffer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fetch the node data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memcpy(nodelist, &thisnode, sizeof (*nodelist));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Although we know the mirror nodeid, there
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is no point in returning it as we have
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * no information about any other hosts.