Logo Search packages:      
Sourcecode: virtualbox-ose version File versions

int kldrDyldGetPrerequisite ( const char *  pszDll,
const char *  pszPrefix,
const char *  pszSuffix,
KLDRDYLDSEARCH  enmSearch,
unsigned  fFlags,
PKLDRDYLDMOD  pDep,
PPKLDRDYLDMOD  ppMod 
)

Gets prerequisite module.

This will try load the requested module if necessary, returning it in the MAPPED state.

Returns:
0 on success.

KLDR_ERR_MODULE_NOT_FOUND or I/O error on failure.

Parameters:
pszDll The name of the dll to look for.
pszPrefix Prefix than can be used when searching.
pszSuffix Suffix than can be used when searching.
enmSearch Method to use when locating the module.
fFlags Flags, a combintation of the KLDRYDLD_LOAD_FLAGS_* #defines.
pDep The depentant module.
ppMod Where to put the module we get.

Definition at line 940 of file kLdrDyld.c.

References KLDRDYLDMOD::enmState, KLDR_ERR_PREREQUISITE_MODULE_INIT_FAILED, KLDR_ERR_PREREQUISITE_MODULE_TERMINATING, KLDRDYLD_ASSERT, kldrDyldFindExistingModule(), kldrDyldFindNewModule(), kldrDyldModAddDep(), kldrDyldModMap(), kldrDyldModReload(), KLDRSTATE_GOOD, KLDRSTATE_INITIALIZATION_FAILED, KLDRSTATE_INITIALIZING, KLDRSTATE_LOADED_PREREQUISITES, KLDRSTATE_MAPPED, KLDRSTATE_PENDING_GC, KLDRSTATE_PENDING_INITIALIZATION, KLDRSTATE_PENDING_TERMINATION, KLDRSTATE_RELOADED, KLDRSTATE_RELOADED_LOADED_PREREQUISITES, KLDRSTATE_TERMINATING, and NULL.

Referenced by kldrDyldModLoadPrerequisites().

{
    int             rc;
    PKLDRDYLDMOD    pMod;

    *ppMod = NULL;

    /*
     * Try find the module among the ones that's already loaded.
     *
     * This is very similar to the kldrDyldDoLoad code, except it has to deal with
     * a couple of additional states and occurs only during prerequisite loading
     * and the action taken is a little bit different.
     */
    rc = kldrDyldFindExistingModule(pszDll, pszPrefix, pszSuffix, enmSearch, fFlags, &pMod);
    if (!rc)
    {
        switch (pMod->enmState)
        {
            /*
             * These are good.
             */
            case KLDRSTATE_MAPPED:
            case KLDRSTATE_RELOADED:
            case KLDRSTATE_LOADED_PREREQUISITES:
            case KLDRSTATE_RELOADED_LOADED_PREREQUISITES:
            case KLDRSTATE_PENDING_INITIALIZATION:
            case KLDRSTATE_INITIALIZING:
            case KLDRSTATE_GOOD:
            case KLDRSTATE_PENDING_TERMINATION:
                break;

            /*
             * The module has been terminated so it need to be reloaded, have it's
             * prereqs loaded, fixed up and initialized before we can use it again.
             */
            case KLDRSTATE_PENDING_GC:
                rc = kldrDyldModReload(pMod);
                break;

            /*
             * The module can't be loaded because it failed to initialize already.
             */
            case KLDRSTATE_INITIALIZATION_FAILED:
                rc = KLDR_ERR_PREREQUISITE_MODULE_INIT_FAILED;
                break;

            /*
             * Forget it, no idea how to deal with re-initialization.
             */
            case KLDRSTATE_TERMINATING:
                return KLDR_ERR_PREREQUISITE_MODULE_TERMINATING;

            /*
             * Invalid state.
             */
            default:
                KLDRDYLD_ASSERT(!"invalid state");
                break;
        }
    }
    else
    {
        /*
         * We'll have to load it from file.
         */
        rc = kldrDyldFindNewModule(pszDll, pszPrefix, pszSuffix, enmSearch, fFlags, &pMod);
        if (!rc)
            rc = kldrDyldModMap(pMod);
    }

    /*
     * On success add dependency.
     */
    if (!rc)
    {
        kldrDyldModAddDep(pMod, pDep);
        *ppMod = pMod;
    }
    return rc;
}


Generated by  Doxygen 1.6.0   Back to index