/*
* 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
*/
/*
*/
#include <libnvpair.h>
#include <fm/topo_mod.h>
#include <topo_method.h>
#include <topo_subr.h>
#include <sw.h>
{ NULL }
};
topo_instance_t, void *, void *);
{ sw_enum, sw_release };
int
{
if (getenv("TOPOSWDEBUG"))
if (version != SW_VERSION)
return (-1);
}
return (0);
}
void
{
}
static int
{
return (0);
} else {
}
}
static int
{
return (0);
} else {
*dest = -1;
}
}
static int
{
return (0);
} else {
}
}
static int
{
if (val)
else
return (0);
}
/*ARGSUSED*/
static int
{
int err = 0;
char **ctxt_stack;
if (version > TOPO_METH_FMRI_VERSION)
&ctxt_stackdepth) != 0) {
ctxt_stack = NULL;
else
err++;
}
if (err)
moderr = EMOD_NOMEM;
goto out;
}
/*
* Add standard FMRI members 'version' and 'scheme'.
*/
/*
* Build up the 'object' nvlist.
*/
if (obj_pkg)
/*
* Add 'object' to the fmri.
*/
if (err == 0)
if (err) {
moderr = EMOD_NOMEM;
goto out;
}
/*
* Do we have anything for a 'site' nvlist?
*/
goto context;
/*
* Allocate and build 'site' nvlist.
*/
moderr = EMOD_NOMEM;
goto out;
}
site_line != -1)
/*
* Add 'site' to the fmri.
*/
if (err == 0)
if (err) {
moderr = EMOD_NOMEM;
goto out;
}
/*
* Do we have anything for a 'context' nvlist?
*/
goto out;
/*
* Allocate and build 'context' nvlist.
*/
moderr = EMOD_NOMEM;
goto out;
}
if (ctxt_pid != -1)
if (ctxt_ctid != -1)
if (ctxt_stack != NULL)
/*
* Add 'context' to the fmri.
*/
if (err == 0)
out:
if (moderr == 0)
if (obj)
if (site)
if (ctxt)
}
/*ARGSUSED*/
static int
{
return (0);
}
static void
{
}
/*
* Lookup a string in an nvlist. Possible return values:
* if 'required' is B_TRUE:
* 1 = found
* 0 = not found
* if 'required' is B_FALSE:
* 1 = found
* 0 = not found, but some error other than ENOENT encountered
* -1 = not found, with ENOENT
*
* So 0 is an error condition in both cases.
*
* In all "not found" cases, *valp is NULLed.
*/
static int
{
int err;
/*
* A return value of 1 always means "found"
*/
if (err == 0)
return (1);
/*
* Failure to lookup for whatever reason NULLs valp
*/
/*
* Return 0 if not found but required, or optional but some error
* other than ENOENT was returned.
*/
return (0);
/*
* Return -1 if not found but was optional (and got ENOENT).
*/
return (-1);
}
/*ARGSUSED*/
static int
{
int linevalid = 0;
int pass;
int err;
if (version > TOPO_METH_NVL2STR_VERSION)
/* Get authority, if present */
/*
* The 'object' nvlist is required. It must include the path,
* but the root is optional.
*/
/* The 'site' nvlist is optional */
linevalid = 0;
/*
*/
B_FALSE) <= 0) {
/*
* If no token then try file, func, line - but
* func and line are meaningless without file.
*/
if (nvlist_lookup_int64(site,
FM_FMRI_SW_SITE_LINE, &line) == 0)
linevalid = 1;
}
}
}
/* On the first pass buf is NULL and size and buflen are 0 */
pass = 1;
/*
* sw://[<authority>]/
* [:root=<object.root]
* :path=<object.path>
* [#<fragment-identifier>]
*
* <fragment-identifier> is one of
*
* :token=<site.token>
* or
* :file=<site.file>[:func=<site.func>][:line=<site.line>]
*/
/* sw:// */
NULL, "://");
/* authority, if any */
continue;
}
}
/* separating slash */
/* :root=... */
if (root) {
}
/* :path=... */
if (token) {
/* #:token=... */
} else if (file) {
/* #:file=... */
/* :func=... */
if (func) {
}
/* :line=... */
if (linevalid) {
if (pass == 1)
"%lld", line);
}
}
size = 0;
pass = 2;
goto again;
}
/*
* Construct the nvlist to return as the result.
*/
}
}
return (0);
}