Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_linker.c
Show First 20 Lines • Show All 2,061 Lines • ▼ Show 20 Lines | |||||
* Find a file which contains given module and load it, if "parent" is not | * Find a file which contains given module and load it, if "parent" is not | ||||
* NULL, register a reference to it. | * NULL, register a reference to it. | ||||
*/ | */ | ||||
static int | static int | ||||
linker_load_module(const char *kldname, const char *modname, | linker_load_module(const char *kldname, const char *modname, | ||||
struct linker_file *parent, const struct mod_depend *verinfo, | struct linker_file *parent, const struct mod_depend *verinfo, | ||||
struct linker_file **lfpp) | struct linker_file **lfpp) | ||||
{ | { | ||||
struct proc *cp = curproc; | |||||
kib: No initialization in declaration. We usually name the single variable in function designated a… | |||||
linker_file_t lfdep; | linker_file_t lfdep; | ||||
const char *filename; | const char *filename; | ||||
char *pathname; | char *pathname; | ||||
int error; | int error; | ||||
sx_assert(&kld_sx, SA_XLOCKED); | sx_assert(&kld_sx, SA_XLOCKED); | ||||
if (modname == NULL) { | if (modname == NULL) { | ||||
/* | /* | ||||
* We have to load KLD | * We have to load KLD | ||||
*/ | */ | ||||
KASSERT(verinfo == NULL, ("linker_load_module: verinfo" | KASSERT(verinfo == NULL, ("linker_load_module: verinfo" | ||||
" is not NULL")); | " is not NULL")); | ||||
if (rootvnode == NULL) | /* check if root file system is not mounted */ | ||||
if (rootvnode == NULL || cp->p_fd == NULL || | |||||
kibUnsubmitted Done Inline Actionsp_fd == NULL check is not needed. kib: p_fd == NULL check is not needed. | |||||
cp->p_fd->fd_rdir == NULL) | |||||
return (ENXIO); | return (ENXIO); | ||||
pathname = linker_search_kld(kldname); | pathname = linker_search_kld(kldname); | ||||
} else { | } else { | ||||
if (modlist_lookup2(modname, verinfo) != NULL) | if (modlist_lookup2(modname, verinfo) != NULL) | ||||
return (EEXIST); | return (EEXIST); | ||||
if (rootvnode == NULL) | /* check if root file system is not mounted */ | ||||
if (rootvnode == NULL || cp->p_fd == NULL || | |||||
cp->p_fd->fd_rdir == NULL) | |||||
return (ENXIO); | return (ENXIO); | ||||
if (kldname != NULL) | if (kldname != NULL) | ||||
pathname = strdup(kldname, M_LINKER); | pathname = strdup(kldname, M_LINKER); | ||||
else | else | ||||
/* | /* | ||||
* Need to find a KLD with required module | * Need to find a KLD with required module | ||||
*/ | */ | ||||
pathname = linker_search_module(modname, | pathname = linker_search_module(modname, | ||||
▲ Show 20 Lines • Show All 161 Lines • Show Last 20 Lines |
No initialization in declaration. We usually name the single variable in function designated a process pointer 'p'.