topo_fmri.c revision 2cb5535af222653abf2eba5c180ded4a7b85d8b6
/*
* 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.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <string.h>
#include <limits.h>
#include <fm/topo_mod.h>
#include <topo_alloc.h>
#include <topo_error.h>
#include <topo_method.h>
#include <topo_subr.h>
#include <topo_string.h>
/*
* Topology node properties and method operations may be accessed by FMRI.
* The FMRI used to perform property look-ups and method operations is
* the FMRI contained in the matching topology node's protocol property
* grouping for the resource property. The full range of fmd(1M)
* scheme plugin operations are supported as long as a backend method is
* supplied by a scheme-specific enumerator or the enumerator module that
* created the matching topology node. Support for fmd scheme operations
* include:
*
* - expand
* - present
* - contains
* - unusable
* - nvl2str
*
* In addition, the following operations are supported per-FMRI:
*
* - str2nvl: convert string-based FMRI to nvlist
* - compare: compare two FMRIs
* - asru: lookup associated ASRU property by FMRI
* - fru: lookup associated FRU by FMRI
* - create: an FMRI nvlist by scheme type
* - propery lookup
*
* These routines may only be called by consumers of a topology snapshot.
* They may not be called by libtopo enumerator or method modules.
*/
/*ARGSUSED*/
static int
{
topo_strerror(err));
return (-1);
}
/*ARGSUSED*/
static nvlist_t *
{
topo_strerror(err));
return (NULL);
}
int
{
TOPO_METH_NVL2STR, out));
TOPO_METH_NVL2STR, out));
TOPO_METH_NVL2STR, out));
TOPO_METH_NVL2STR, out));
return (0);
}
int
int *err)
{
TOPO_METH_STR2NVL, in));
*f = '\0'; /* strip trailing FMRI path */
TOPO_METH_STR2NVL, in));
in));
in));
TOPO_METH_STR2NVL, out));
return (0);
}
int
{
char *scheme;
TOPO_METH_PRESENT, out));
TOPO_METH_PRESENT, out));
return (present);
}
return (present);
}
int
{
char *scheme;
NULL));
in));
out));
}
return (contains);
}
int
{
char *scheme;
return (unusable);
}
int
{
char *scheme;
TOPO_METH_EXPAND, out));
TOPO_METH_EXPAND, out));
return (0);
}
static int
int *err)
{
int rv;
char *scheme;
TOPO_METH_PROP_GET, in));
TOPO_METH_PROP_GET, in));
TOPO_METH_PROP_GET, in));
if (rv != 0)
TOPO_METH_PROP_GET, in));
if (rv != 0)
return (-1); /* *err is set for us */
return (0);
}
int
{
prop));
prop));
return (0);
}
int
{
prop));
prop));
return (0);
}
int
{
char *lp;
prop));
prop));
return (0);
}
int
{
char *sp;
prop));
"topo_fmri_serial", prop));
return (0);
}
int *err)
{
}
{
int rv;
char *scheme;
TOPO_METH_PROP_SET, in));
TOPO_METH_PROP_SET, in));
TOPO_METH_PROP_SET, in));
if (rv != 0)
TOPO_METH_PROP_SET, in));
/* no return values */
if (rv)
return (-1);
return (0);
}
int
{
int rv;
char *scheme;
TOPO_METH_PROP_GET, in));
TOPO_METH_PROP_GET, in));
TOPO_METH_PROP_GET, in));
if (rv != 0)
TOPO_METH_PROP_GET, in));
if (rv != 0)
return (-1); /* *err is set for us */
return (0);
}
int
{
return (0);
NULL));
in));
return (compare);
}
/*
* topo_fmri_create
*
* If possible, creates an FMRI of the requested version in the
* requested scheme. Args are passed as part of the inputs to the
* fmri-create method of the scheme.
*/
nvlist_t *
{
TOPO_METH_FMRI, NULL));
TOPO_METH_FMRI, NULL));
TOPO_METH_FMRI, ins));
}
TOPO_METH_FMRI, ins));
}
if (topo_method_invoke(rnode,
}
return (out);
}