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 Forte * Internal routine to fetch all the current nodes that are
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * considered 'up'.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns the number of ncall_info structures that are valid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * returned via the nodelist pointer, or -1 on an error.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If the call succeeds, then the memory returned via the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * nodelist pointer needs to be freed by the caller.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((size = ioctl(fd, NC_IOC_GETNETNODES, NULL)) < 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mynodelist = malloc(size * sizeof (*mynodelist));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* fixup return value for single node ioctl */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return the system id (the current value in the kernel
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * currently running).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * on error return -1 and set errno.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Return 0, not the mirror node id as returned
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * from the ioctl.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Runtime Solaris release checking.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Compare the build release to the runtime release to check for an
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * acceptable match.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Arguments:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * build_ver - the string Solaris build release (e.g. "5.8")
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * map - optional array of nsc_release_t defining
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * acceptable build release / runtime release
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * matches. If supplied, must end will a NULL
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * array element. See src/head/nsctl.h for info.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * reqd - used to return the required OS versions if the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return value is not -1. The returned string
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is readonly.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * TRUE - acceptable match
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * FALSE - no match (component should not continue to run)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * -1 - error (errno is set)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortensc_check_release(const char *build_rel, nsc_release_t *map, char **reqd)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* assume that build_rel is the required release for now */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* build release == runtime release is always acceptable */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (mp = map; mp->build != NULL && mp->runtime != NULL; mp++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * found an entry for this build release
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - search for a match in the runtime releases
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* reset reqd to this entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * operate on a copy of the string since strtok
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is destructive.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return the system id corresponding to name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * on error return -1 and set errno.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(name, nodes[slot].nc_nodename) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return the node name corresponding to system id
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * on error return -1 and set errno.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The returned string has been strdup() and needs
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to be freed by the caller.