int main(int argc, char **argv) { int c, bootflags; nodeid_t nid, hid; char *cp = ""; (void) setlocale(LC_ALL, ""); (void) textdomain(TEXT_DOMAIN); cmdname = argv[0]; /* put actual command name in messages */ if (_cladm(CL_INITIALIZE, CL_GET_BOOTFLAG, &bootflags) != 0) { errmsg("_cladm(CL_INITIALIZE, CL_GET_BOOTFLAG)"); return (1); } while ((c = getopt(argc, argv, "bnh")) != EOF) { switch (c) { case 'b': /* print boot flags */ (void) printf("%s%u\n", cp, bootflags); break; case 'n': /* print our node number */ if (_cladm(CL_CONFIG, CL_NODEID, &nid) != 0) { errmsg("node is not configured as part of a" "cluster"); return (1); } (void) printf("%s%u\n", cp, nid); break; case 'h': /* print the highest node number */ if (_cladm(CL_CONFIG, CL_HIGHEST_NODEID, &hid) != 0) { errmsg("node is not booted as part of a " "cluster"); return (1); } (void) printf("%s%u\n", cp, hid); break; default: usage(); return (1); } cp = " "; } /* * Return exit status of one (error) if not booted as a cluster. */ return (bootflags & CLUSTER_BOOTED ? 0 : 1); }
static int cluster_register(rcm_handle_t *hdl) { int bootflags; if (cluster_SUNW_os_registered) return (RCM_SUCCESS); if (_cladm(CL_INITIALIZE, CL_GET_BOOTFLAG, &bootflags) != 0) { rcm_log_message(RCM_ERROR, gettext("unable to check cluster status\n")); return (RCM_FAILURE); } /* attempt to determine if we are in cluster mode */ if (bootflags & CLUSTER_BOOTED) { if (rcm_register_interest(hdl, SUNW_OS, 0, NULL) != RCM_SUCCESS) { rcm_log_message(RCM_ERROR, gettext("failed to register\n")); return (RCM_FAILURE); } else { cluster_SUNW_os_registered = 1; rcm_log_message(RCM_DEBUG, "registered " SUNW_OS "\n"); } } return (RCM_SUCCESS); }