topo_xml.c revision 7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fe
/*
* 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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <libxml/xinclude.h>
#include <assert.h>
#include <string.h>
#include <strings.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <unistd.h>
#include <fcntl.h>
#include <topo_mod.h>
#include <topo_subr.h>
#include <topo_alloc.h>
#include <topo_parse.h>
#include <topo_error.h>
const char * const Children = "children";
const char * const Dependents = "dependents";
const char * const FMRI = "fmri";
const char * const Grouping = "grouping";
const char * const Immutable = "immutable";
const char * const Instance = "instance";
const char * const Int32 = "int32";
const char * const Int64 = "int64";
const char * const Name = "name";
const char * const Path = "path";
const char * const Range = "range";
const char * const Scheme = "scheme";
const char * const Siblings = "siblings";
const char * const String = "string";
const char * const Topology = "topology";
const char * const Type = "type";
const char * const UInt32 = "uint32";
const char * const UInt64 = "uint64";
const char * const Value = "value";
const char * const Verify = "verify";
const char * const Version = "version";
const char * const Enum_meth = "enum-method";
const char * const Propgrp = "propgroup";
const char * const Propval = "propval";
const char * const Node = "node";
const char * const Hc = "hc";
const char * const True = "true";
const char * const False = "false";
const char * const Namestab = "name-stability";
const char * const Datastab = "data-stability";
const char * const Evolving = "Evolving";
const char * const External = "External";
const char * const Internal = "Internal";
const char * const Obsolete = "Obsolete";
const char * const Private = "Private";
const char * const Stable = "Stable";
const char * const Standard = "Standard";
const char * const Unstable = "Unstable";
static void
txml_dump(int g, xmlNodePtr p)
{
if (p && p->name) {
txml_dump(g + 1, p);
}
}
int
{
int rv = 0;
if (n == NULL) {
/* If there is no Stability defined, we default to private */
return (0);
}
} else {
}
return (rv);
}
int
{
/* no conversion was done */
}
return (0);
}
static int
{
int err;
&err) < 0)
return (-1);
return (0);
}
static topo_type_t
{
return (TOPO_TYPE_INVALID);
}
rv = TOPO_TYPE_FMRI;
} else {
return (TOPO_TYPE_INVALID);
}
return (rv);
}
static int
{
int e;
else
if (e != 0)
return (-1);
}
/* FMXXX stability of the property value */
return (-1);
if (e != 0)
return (-1);
switch (ptype) {
case TOPO_TYPE_INT32:
return (-1);
break;
case TOPO_TYPE_UINT32:
return (-1);
break;
case TOPO_TYPE_INT64:
return (-1);
break;
case TOPO_TYPE_UINT64:
return (-1);
break;
case TOPO_TYPE_FMRI:
return (-1);
break;
case TOPO_TYPE_STRING:
return (-1);
break;
default:
}
if (e != 0) {
}
return (0);
}
static int
{
int sibs = 0;
}
sibs++;
} else {
"Dependents have bogus grouping attribute");
}
/* Add processed dependents to the tail of the list */
}
"error within dependent .xml topology: "
return (-1);
}
else if (sibs == 1)
else
return (0);
}
static int
{
return (-1);
}
}
return (0);
}
static int
{
char *str;
int err, e;
switch (ptype) {
case TOPO_TYPE_INT32:
break;
case TOPO_TYPE_UINT32:
break;
case TOPO_TYPE_INT64:
break;
case TOPO_TYPE_UINT64:
break;
case TOPO_TYPE_FMRI:
break;
case TOPO_TYPE_STRING:
break;
default:
e = ETOPO_PRSR_BADTYPE;
}
if (e != 0) {
return (topo_mod_seterrno(mp, e));
}
switch (ptype) {
case TOPO_TYPE_INT32:
break;
case TOPO_TYPE_UINT32:
break;
case TOPO_TYPE_INT64:
break;
case TOPO_TYPE_UINT64:
break;
case TOPO_TYPE_FMRI:
break;
case TOPO_TYPE_STRING:
break;
}
if (e != 0) {
}
return (0);
}
static int
{
char *pnm;
int flag;
int pn;
int e;
if (e != 0) {
"props create lookup (%s) failure: %s",
INV_PNAME, topo_strerror(e));
}
if (e != 0) {
"props create lookup (%s) failure: %s",
INV_IMMUTE, topo_strerror(e));
}
if (e != 0) {
"props create lookup (%s) failure: %s",
INV_PVALTYPE, topo_strerror(e));
}
return (-1);
}
return (0);
}
static int
{
char *gnm;
int pg;
int e;
INV_PGRP_NAME, &gnm);
if (e != 0) {
}
INV_PGRP_STAB, &ui32);
if (e != 0) {
}
if (e != ETOPO_PROP_DEFD) {
"pgroups create failure: %s\n",
topo_strerror(e));
return (-1);
}
}
"warning: recorded number of props %d does not "
"match number of props recorded %d.\n",
}
return (-1);
}
return (0);
}
static nvlist_t *
{
return (NULL);
}
return (NULL);
}
return (NULL);
}
/* FMXXX stability of the property name */
return (NULL);
}
return (pnvl);
}
static int
{
int pcnt = 0;
int ai = 0;
int e;
}
pcnt++;
}
return (-1);
}
return (-1);
}
if (e != 0 ||
return (-1);
}
break;
}
ai++;
}
}
if (e != 0) {
return (-1);
}
return (0);
}
static int
{
int pi = 0;
return (-1);
}
}
return (0);
}
/*
* Process the property group and dependents xmlNode children of
* parent xmlNode pxn.
*/
static int
{
int pgcnt = 0;
int dcnt = 0;
dcnt++;
pgcnt++;
}
return (-1);
return (0);
if (pgcnt > 0) {
return (-1);
}
return (-1);
}
}
}
return (-1);
if ((*rpad)->tpad_pgcnt > 0)
return (-1);
return (0);
}
static int
{
int rv = -1;
goto nodedone;
goto nodedone;
goto nodedone;
goto nodedone;
}
goto nodedone;
}
goto nodedone;
rv = 0;
return (rv);
}
static tf_edata_t *
{
return (NULL);
}
goto enodedone;
}
goto enodedone;
}
goto enodedone;
/*
* FMXXX must deal with name-stability and apply-methods (which are
* child xmlNodes)
*/
return (einfo);
return (NULL);
}
static int
{
int e = -1;
/*
* first see if the module is already loaded
*/
char *skip;
int prepend = 0;
return (-1);
prepend = 1;
skip += 2;
}
"enum_run, load %s.\n", mostpath);
"mod_load of %s failed: %s.\n",
return (e);
}
}
/*
* We're live, so let's enumerate.
*/
if (e != 0) {
}
return (e);
}
int
{
/*
* The range may have several children xmlNodes, that may
* represent the enumeration method, property groups,
* dependents or nodes.
*/
int e;
e = topo_node_range_create(mp,
if (e != 0) {
return (-1);
}
break;
return (-1);
return (-1);
}
}
/* Now look for nodes, i.e., hard instances */
"node processing failed: %s.\n",
return (topo_mod_seterrno(mp,
}
}
/* Property groups and Dependencies */
/* Only care about instances within the range */
continue;
}
return (-1);
}
return (0);
}
static tf_rdata_t *
{
/*
* What we're interested in are children xmlNodes of croot tagged
* as 'ranges', these define topology nodes may exist, and need
* to be verified.
*/
continue;
}
continue;
}
return (NULL);
}
} else {
}
}
return (rr);
}
/*
* Convert parsed xml topology description into topology nodes
*/
int
{
return (-1);
}
"error within .xml topology: %s\n",
return (-1);
}
return (0);
}
/*
* Load an XML tree from filename and read it into a DOM parse tree.
*/
static tf_info_t *
{
int readflags = 0;
tf_info_t *r;
int e;
/*
* Since topologies can XInclude other topologies, and libxml2
* doesn't do DTD-based validation with XInclude, by default
* we don't validate topology files. One can force
* validation, though, by creating a TOPOXML_VALIDATE
* environment variable and creating a TOPO_DTD environment
* variable with the path to the DTD against which to validate.
*/
}
/*
* Splat warnings and errors related to parsing the topology
* file if the TOPOXML_PERROR environment variable exists.
*/
return (NULL);
}
/*
* Verify that this is a document type we understand.
*/
return (NULL);
}
"document DTD unknown; bad topology file?\n");
return (NULL);
}
return (NULL);
}
/*
* Make sure we're looking at a topology description in the
* expected scheme.
*/
"document is not a topology description.\n");
return (NULL);
}
return (NULL);
}
"topology in unrecognized scheme, %s, expecting %s\n",
return (NULL);
}
"Could not parse DTD \"%s\".\n",
dtdpath);
return (NULL);
}
}
"couldn't handle XInclude statements in document\n");
return (NULL);
}
return (NULL);
}
if (e == 0) {
return (NULL);
}
return (NULL);
/* txml_dump(0, cursor); */
return (r);
}
static int
{
int rfd;
return (rfd);
}
{
int fd;
return (NULL);
}
return (tip);
}