topo_pkg.c revision 9164eb65b5c2638abc35517e4302cf4c142c3855
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 <strings.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <sys/systeminfo.h>
#include <alloca.h>
#include <libtopo.h>
#include "topo_impl.h"
/*
* mod_filename_bindpath --
*
* Determine that path to a particular mod_filename. The path is determined
* using the module load path hierarchy for the machine obtained from the
* kernel via MODGETPATH modctl and kernel run mode information obtained from
* MODGETPATHSUFFIX - and searching for the module on this path. A match
* corresponds to the same path the kernel would use to load the module.
*
* This function returns a pointer to a malloced path. The caller
* must free this to avoid leaks.
*
* NOTE: this function is typically called for an unbound path
* (unloaded module, so MODINFO_MODPATH failed). We may however call
* this for a bound path (loaded module) if MODINFO_MODPATH returned
* path does not start with '/'. This situation may occur with
* primary modules loaded by OBP, like krtld.
*/
#define MOD_SEP " :"
static char *Moddirsave;
static char *Suffixdir;
static char *
mod_filename_bindpath(const char *mod_filename)
{
char *moddir;
char path[MAXPATHLEN];
char *ls;
int len;
/*
* On first call, initialize the string that describes the
* directories searched by the kernel to locate a module.
*/
if (Moddirsave == NULL) {
goto out;
goto out;
}
}
/*
* On first call, initialize architecture specific directory suffix.
*/
} else {
}
}
/* find the last '/' in mod_filename */
/* initialize for module path string breakup */
/* loop over the directories searched to locate a module */
/*
* break out of loop if we find the file.
* try the Suffixdir (e.g, "sparcv9") specific path first
*/
if (ls) {
/*
* split mod_filename into a path piece and a
* file piece, then interject our suffix
* between the pieces.
*
* and Suffixdir is determined to be sparcv9,
*/
*ls = 0;
*ls = '/';
break;
} else {
/* we don't have a '/' in path, Suffixdir goes first */
break;
}
/* try straight mod_filename. */
dir, mod_filename);
break;
}
return (NULL);
return (topo_strdup(path));
}
static int
{
int notfound = 1;
notfound = 0;
break;
}
}
return (notfound);
}
static nvlist_t *
{
int e;
if (errno != 0) {
goto fmrialeave;
}
e |= nvlist_add_string(a, FM_FMRI_MOD_DESC,
if (e != 0) {
goto fmrialeave;
}
return (a);
if (a != NULL)
nvlist_free(a);
return (NULL);
}
static nvlist_t *
{
char *token;
int e;
return (NULL);
}
}
goto fmrileave;
if (errno != 0) {
goto fmrileave;
}
if (e == 0)
goto fmrileave;
nvlist_free(f);
f = NULL;
return (f);
}
#define PKG_KEYPHRASE "Referenced by the following packages:"
/*
* topo_driver_fru -- Given a driver name, find the path that module,
* and then look up the package delivering that module to the
* system. Then construct a 'pkg' scheme FMRI that describes the
* package.
*/
static nvlist_t *
topo_driver_fru(const char *drvrname)
{
char *findpkgname;
char *path;
goto drvfrufail;
}
goto drvfrufail;
}
return (f);
}
/*
* topo_driver_asru -- Given a driver name, first create its FRU fmri
* and if that goes well, get the rest of the module information
* and put it in a 'mod' scheme FMRI describing the driver as an
* ASRU.
*/
nvlist_t *
{
int true = 1;
goto drvasrufail;
do {
break;
goto drvasrufail;
break;
}
} while (true);
*frup = f;
return (a);
if (f != NULL)
nvlist_free(f);
return (NULL);
}
void
topo_driver_fini(void)
{
if (Moddirsave != NULL) {
Moddirsave = NULL;
}
}
}