scheme.c revision dd33c4e482cc902d14d3ad7f44931dc0e195a861
/*
* 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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <fm/fmd_fmri.h>
#include <libdevinfo.h>
#include <alloca.h>
#include <string.h>
/*
* buf_append -- Append str to buf (if it's non-NULL). Place prepend
* in buf in front of str and append behind it (if they're non-NULL).
* Continue to update size even if we run out of space to actually
* stuff characters in the buffer.
*/
static void
{
return;
left = 0;
else
}
{
int more_auth = 0;
int err;
return (fmd_fmri_set_errno(EINVAL));
/* Get authority, if present */
return (fmd_fmri_set_errno(err));
/* Get devid, if present */
return (fmd_fmri_set_errno(err));
/* There must be a device path present */
return (fmd_fmri_set_errno(EINVAL));
(void) nvlist_lookup_string(anvl,
(void) nvlist_lookup_string(anvl,
(void) nvlist_lookup_string(anvl,
(void) nvlist_lookup_string(anvl,
(void) nvlist_lookup_string(anvl,
more_auth++;
more_auth++;
more_auth++;
more_auth++;
more_auth++;
}
/* dev:// */
/* authority, if any */
NULL);
/* device-id part */
/* device-path part */
return (size);
}
/*
* callback routine for di_walk_minor()
*/
struct walkinfo {
int matched;
const char *path;
int len;
};
static int
{
/*
* found the match we were looking for, set matched
* flag and terminate the walk.
*/
return (DI_WALK_TERMINATE);
}
return (DI_WALK_CONTINUE);
}
/*
* For now we only check for the presence of the device in the device
* tree. This is somewhat unsophisticated, because a device may have
* been inserted into the same slot as the previous ASRU and we don't
* know how to tell them apart yet.
*/
int
{
char *parentpath;
char *cp;
return (fmd_fmri_set_errno(EINVAL));
return (fmd_fmri_set_errno(EINVAL));
/* strip off last component of path */
parentpath = "/";
else
*cp = '\0';
/* if the result is an empty path, start walk at "/" */
if (*parentpath == '\0')
parentpath = "/";
(void) di_walk_node(parent,
}
/*
* We presently don't have a good indication of the usability of an
* ASRU in the dev scheme, so we'll assume its usable.
*/
int
{
return (fmd_fmri_set_errno(EINVAL));
return (0);
}