/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <fcntl.h>
#include <unistd.h>
#include <stdarg.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "libnsctl.h"
#include <nsctl.h>
/*
* Internal routine to fetch all the current nodes that are
* considered 'up'.
* Returns the number of ncall_info structures that are valid
* returned via the nodelist pointer, or -1 on an error.
* If the call succeeds, then the memory returned via the
* nodelist pointer needs to be freed by the caller.
*/
static int
{
int size;
int fd;
int save_errno = 0;
int ioctlcmd;
return (-1);
}
return (-1);
}
size = 1;
} else {
}
if (mynodelist == NULL) {
save_errno = ENOMEM;
} else {
if (rc < 0) {
save_errno = errno;
} else {
/* fixup return value for single node ioctl */
if (ioctlcmd == NC_IOC_GETNODE)
rc = 1;
*nodelist = mynodelist;
}
}
errno = save_errno;
return (rc);
}
/*
* return the system id (the current value in the kernel
* currently running).
*
* on error return -1 and set errno.
*/
int
{
int rval = 0;
int save_errno = 0;
int fd;
*id = 0;
if (fd < 0)
return (-1);
if (rval < 0)
save_errno = errno;
else {
/*
* Return 0, not the mirror node id as returned
* from the ioctl.
*/
rval = 0;
}
errno = save_errno;
return (rval);
}
/*
* Runtime Solaris release checking.
*
* Compare the build release to the runtime release to check for an
* acceptable match.
*
* Arguments:
* build_ver - the string Solaris build release (e.g. "5.8")
* map - optional array of nsc_release_t defining
* acceptable build release / runtime release
* matches. If supplied, must end will a NULL
* reqd - used to return the required OS versions if the
* return value is not -1. The returned string
* is readonly.
*
* Returns:
* TRUE - acceptable match
* FALSE - no match (component should not continue to run)
* -1 - error (errno is set)
*/
int
{
int rc;
if (reqd)
return (-1);
}
/* assume that build_rel is the required release for now */
if (reqd)
return (-1);
/* build release == runtime release is always acceptable */
return (TRUE);
return (FALSE);
/*
* found an entry for this build release
* - search for a match in the runtime releases
*/
/* reset reqd to this entry */
if (reqd)
/*
* operate on a copy of the string since strtok
* is destructive.
*/
rc = -1;
break;
}
break;
}
}
break;
}
}
if (tofree)
return (rc);
}
/*
* return the system id corresponding to name
*
* on error return -1 and set errno.
*/
int
{
int rval = 0;
int nodecnt;
int slot;
*id = 0;
if (nodecnt < 0) {
rval = -1;
} else {
break;
}
}
rval = -1;
}
}
return (rval);
}
/*
* return the node name corresponding to system id
*
* on error return -1 and set errno.
* The returned string has been strdup() and needs
* to be freed by the caller.
*/
int
{
int rval = 0;
int nodecnt;
int slot;
char *foundname;
*name = 0;
if (nodecnt < 0) {
rval = -1;
} else {
if (foundname) {
} else {
rval = -1;
}
break;
}
}
rval = -1;
}
}
return (rval);
}