Changeset View
Changeset View
Standalone View
Standalone View
stand/common/module.c
Show All 35 Lines | |||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/linker.h> | #include <sys/linker.h> | ||||
#include <sys/module.h> | #include <sys/module.h> | ||||
#include <sys/queue.h> | #include <sys/queue.h> | ||||
#include <sys/stdint.h> | #include <sys/stdint.h> | ||||
#include "bootstrap.h" | #include "bootstrap.h" | ||||
#ifdef SECURE_BOOT | |||||
#include "verify.h" | |||||
#endif | |||||
#define MDIR_REMOVED 0x0001 | #define MDIR_REMOVED 0x0001 | ||||
#define MDIR_NOHINTS 0x0002 | #define MDIR_NOHINTS 0x0002 | ||||
struct moduledir { | struct moduledir { | ||||
char *d_path; /* path of modules directory */ | char *d_path; /* path of modules directory */ | ||||
u_char *d_hints; /* content of linker.hints file */ | u_char *d_hints; /* content of linker.hints file */ | ||||
int d_hintsz; /* size of hints data */ | int d_hintsz; /* size of hints data */ | ||||
int d_flags; | int d_flags; | ||||
▲ Show 20 Lines • Show All 371 Lines • ▼ Show 20 Lines | return(NULL); | ||||
/* locate the file on the load path */ | /* locate the file on the load path */ | ||||
name = file_search(fname, NULL); | name = file_search(fname, NULL); | ||||
if (name == NULL) { | if (name == NULL) { | ||||
snprintf(command_errbuf, sizeof(command_errbuf), | snprintf(command_errbuf, sizeof(command_errbuf), | ||||
"can't find '%s'", fname); | "can't find '%s'", fname); | ||||
return(NULL); | return(NULL); | ||||
} | } | ||||
#ifdef SECURE_BOOT | |||||
if (verify(name) != 0) | |||||
return (NULL); | |||||
#endif | |||||
if ((fd = open(name, O_RDONLY)) < 0) { | if ((fd = open(name, O_RDONLY)) < 0) { | ||||
snprintf(command_errbuf, sizeof(command_errbuf), | snprintf(command_errbuf, sizeof(command_errbuf), | ||||
"can't open '%s': %s", name, strerror(errno)); | "can't open '%s': %s", name, strerror(errno)); | ||||
free(name); | free(name); | ||||
return(NULL); | return(NULL); | ||||
} | } | ||||
if (archsw.arch_loadaddr != NULL) | if (archsw.arch_loadaddr != NULL) | ||||
▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | snprintf(command_errbuf, sizeof(command_errbuf), | ||||
"warning: KLD '%s' already loaded", filename); | "warning: KLD '%s' already loaded", filename); | ||||
free(filename); | free(filename); | ||||
return (0); | return (0); | ||||
} | } | ||||
for (last_file = preloaded_files; | for (last_file = preloaded_files; | ||||
last_file != NULL && last_file->f_next != NULL; | last_file != NULL && last_file->f_next != NULL; | ||||
last_file = last_file->f_next) | last_file = last_file->f_next) | ||||
; | ; | ||||
#ifdef SECURE_BOOT | |||||
err = verify(filename); | |||||
if (err != 0) | |||||
return (err); | |||||
#endif | |||||
do { | do { | ||||
err = file_load(filename, loadaddr, &fp); | err = file_load(filename, loadaddr, &fp); | ||||
if (err) | if (err) | ||||
break; | break; | ||||
fp->f_args = unargv(argc, argv); | fp->f_args = unargv(argc, argv); | ||||
loadaddr = fp->f_addr + fp->f_size; | loadaddr = fp->f_addr + fp->f_size; | ||||
file_insert_tail(fp); /* Add to the list of loaded files */ | file_insert_tail(fp); /* Add to the list of loaded files */ | ||||
▲ Show 20 Lines • Show All 534 Lines • Show Last 20 Lines |