mirror of
https://github.com/opnsense/src.git
synced 2026-04-15 14:29:58 -04:00
Add linker_reference_module().
This function loads a module if required, otherwise bumps the reference count -- the opposite of linker_file_unload().
This commit is contained in:
parent
3f99abb8b6
commit
09dbb40410
2 changed files with 30 additions and 0 deletions
|
|
@ -331,6 +331,31 @@ out:
|
|||
return error;
|
||||
}
|
||||
|
||||
int
|
||||
linker_reference_module(const char *modname, linker_file_t *result)
|
||||
{
|
||||
char *pathname;
|
||||
int res;
|
||||
|
||||
/*
|
||||
* There will be a system to look up or guess a file name from
|
||||
* a module name.
|
||||
* For now we just try to load a file with the same name.
|
||||
*/
|
||||
if ((pathname = linker_search_path(modname)) == NULL)
|
||||
return (ENOENT);
|
||||
|
||||
/*
|
||||
* If the module is already loaded or built into the kernel,
|
||||
* linker_load_file() simply bumps it's refcount.
|
||||
*/
|
||||
res = linker_load_file(pathname, result);
|
||||
|
||||
free(pathname, M_LINKER);
|
||||
|
||||
return (res);
|
||||
}
|
||||
|
||||
linker_file_t
|
||||
linker_find_file_by_name(const char* filename)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -106,6 +106,11 @@ int linker_add_class(linker_class_t _cls);
|
|||
*/
|
||||
int linker_load_file(const char* _filename, linker_file_t* _result);
|
||||
|
||||
/*
|
||||
* Obtain a reference to a module, loading it if required.
|
||||
*/
|
||||
int linker_reference_module(const char* _modname, linker_file_t* _result);
|
||||
|
||||
/*
|
||||
* Find a currently loaded file given its filename.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue