Pull out the module path from the loader. ie: if you boot from

/boot/kernel.foobar/* then that had better be in the path ahead of the
others.

Submitted by:  Daniel J. O'Connor <darius@dons.net.au>
PR: 23662
This commit is contained in:
peter 2000-12-28 08:14:58 +00:00
parent c032ffd66a
commit 66cf6a268c
2 changed files with 30 additions and 4 deletions

View File

@ -1171,11 +1171,15 @@ SYSINIT(preload, SI_SUB_KLD, SI_ORDER_MIDDLE, linker_preload, 0);
* character as a separator to be consistent with the bootloader.
*/
static char linker_path[MAXPATHLEN] = "/boot/modules/;/modules/;/boot/kernel/";
static char def_linker_path[] = "/boot/modules/;/modules/;/boot/kernel/";
static char linker_path[MAXPATHLEN] = "";
SYSCTL_STRING(_kern, OID_AUTO, module_path, CTLFLAG_RW, linker_path,
sizeof(linker_path), "module load search path");
TUNABLE_STR_DECL("module_path", def_linker_path, linker_path,
sizeof(linker_path));
static char *linker_ext_list[] = {
".ko",
"",
@ -1211,14 +1215,14 @@ linker_search_path(const char *name)
/* find the end of this component */
for (ep = cp; (*ep != 0) && (*ep != ';'); ep++)
;
result = malloc((len + (ep - cp) + extlen), M_LINKER, M_WAITOK);
result = malloc((len + (ep - cp) + extlen + 1), M_LINKER, M_WAITOK);
if (result == NULL) /* actually ENOMEM */
return(NULL);
for (cpp = linker_ext_list; *cpp; cpp++) {
strncpy(result, cp, ep - cp);
strcpy(result + (ep - cp), name);
strcpy(result + (ep - cp), "/");
strcat(result, name);
strcat(result, *cpp);
/*
* Attempt to open the file, and return the path if we succeed
* and it's a regular file.

View File

@ -265,6 +265,28 @@ SYSINIT(__Tunable_init_ ## var, SI_SUB_TUNABLES, SI_ORDER_MIDDLE, __Tunable_ ##
if (!getenv_int((path), &(var))) \
(var) = (defval);
#define TUNABLE_STR_DECL(path, defval, var, size) \
static void __Tunable_ ## var (void *ignored) \
{ \
char *tmp; \
tmp = getenv((path)); \
if (tmp == NULL) \
tmp = (defval); \
strncpy((var), tmp, (size)); \
(var)[(size)] = 0; \
} \
SYSINIT(__Tunable_init_ ## var, SI_SUB_TUNABLES, SI_ORDER_MIDDLE, __Tunable_ ## var , NULL);
#define TUNABLE_STR_FETCH(path, defval, var, size) \
static void __Tunable_ ## var (void *ignored) \
{ \
char *tmp; \
tmp = getenv((path)); \
if (tmp == NULL) \
tmp = (defval); \
strncpy((var), tmp, (size)); \
(var)[(size)] = 0; \
}
/*
* Compatibility. To be deprecated after LKM is removed.