/*
* 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 <limits.h>
#include <stddef.h>
#include <unistd.h>
#include <dlfcn.h>
#include <fmd_alloc.h>
#include <fmd_error.h>
#include <fmd_subr.h>
#include <fmd_string.h>
#include <fmd_scheme.h>
#include <fmd_fmri.h>
#include <fmd_module.h>
#include <fmd.h>
/*
* The fmd resource scheme, used for fmd modules, must be implemented here for
*/
{
char *name;
return (fmd_fmri_set_errno(EINVAL));
}
static int
{
return (fmd_fmri_set_errno(EINVAL));
return (1);
}
return (rv);
}
static int
{
return (fmd_fmri_set_errno(EINVAL));
return (FMD_OBJ_STATE_UNKNOWN);
}
}
static int
{
char *name;
return (fmd_fmri_set_errno(EINVAL));
return (FMD_SERVICE_STATE_UNKNOWN);
}
}
static int
{
char *name;
return (fmd_fmri_set_errno(EINVAL));
return (0);
}
return (rv);
}
/*ARGSUSED*/
static nvlist_t *
{
return (fmri);
}
static long
fmd_scheme_notsup(void)
{
return (fmd_set_errno(EFMD_FMRI_NOTSUP));
}
static int
fmd_scheme_nop(void)
{
return (0);
}
/*
* Default values for the scheme ops. If a scheme function is not defined in
* the module, then this operation is implemented using the default function.
*/
(int (*)())fmd_scheme_nop, /* sop_init */
(void (*)())fmd_scheme_nop, /* sop_fini */
(int (*)())fmd_scheme_nop, /* sop_expand */
(int (*)())fmd_scheme_notsup, /* sop_present */
(int (*)())fmd_scheme_notsup, /* sop_replaced */
(int (*)())fmd_scheme_notsup, /* sop_service_state */
(int (*)())fmd_scheme_notsup, /* sop_unusable */
(int (*)())fmd_scheme_notsup, /* sop_contains */
fmd_scheme_notranslate /* sop_translate */
};
(int (*)())fmd_scheme_nop, /* sop_init */
(void (*)())fmd_scheme_nop, /* sop_fini */
fmd_scheme_fmd_nvl2str, /* sop_nvl2str */
(int (*)())fmd_scheme_nop, /* sop_expand */
fmd_scheme_fmd_present, /* sop_present */
fmd_scheme_fmd_replaced, /* sop_replaced */
fmd_scheme_fmd_service_state, /* sop_service_state */
fmd_scheme_fmd_unusable, /* sop_unusable */
(int (*)())fmd_scheme_notsup, /* sop_contains */
fmd_scheme_notranslate /* sop_translate */
};
/*
* Scheme ops descriptions. These names and offsets are used by the function
* fmd_scheme_rtld_init(), defined below, to load up a fmd_scheme_ops_t.
*/
{ NULL, 0 }
};
static fmd_scheme_t *
{
sp->sch_loaded = 0;
return (sp);
}
static void
{
}
}
{
return (shp);
}
void
{
uint_t i;
for (i = 0; i < shp->sch_hashlen; i++) {
}
}
}
void
{
uint_t i;
return; /* failed to acquire lock: just skip garbage collect */
for (i = 0; i < shp->sch_hashlen; i++) {
}
}
}
static int
{
void *p;
}
return (0);
}
{
break;
}
return (sp);
}
/*
* Lookup a scheme module by name and return with a reference placed on it. We
* use the scheme hash to cache "negative" entries (e.g. missing modules) as
* well so this function always returns successfully with a non-NULL scheme.
* The caller is responsible for applying fmd_scheme_hash_release() afterward.
*/
{
uint_t h;
/*
* Grab the hash lock as reader and look for the appropriate scheme.
* If the scheme isn't yet loaded, allocate a new scheme and grab the
* hash lock as writer to insert it (after checking again for it).
*/
} else {
}
}
/*
* Grab the scheme lock so it can't disappear and then drop the hash
* lock so that other lookups in the scheme hash can proceed.
*/
/*
* If we created the scheme, compute its path and try to load it. If
* we found an existing scheme, wait until its loaded bit is set. Once
* we're done with either operation, increment sch_refs and return.
*/
"failed to load fmri scheme %s: %s\n", path,
dlerror());
} else if (fmd_scheme_rtld_init(sp) != 0 ||
"failed to initialize fmri scheme %s", path);
}
} else {
while (!sp->sch_loaded)
}
return (sp);
}
/*
* Release the hold on a scheme obtained using fmd_scheme_hash_lookup().
* We take 'shp' for symmetry and in case we need to use it in future work.
*/
/*ARGSUSED*/
void
{
else
}