MCPcopy Create free account
hub / github.com/F-Stack/f-stack / module_register

Function module_register

freebsd/kern/kern_module.c:151–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149}
150
151int
152module_register(const moduledata_t *data, linker_file_t container)
153{
154 size_t namelen;
155 module_t newmod;
156
157 MOD_XLOCK;
158 newmod = module_lookupbyname(data->name);
159 if (newmod != NULL) {
160 MOD_XUNLOCK;
161 printf("%s: cannot register %s from %s; already loaded from %s\n",
162 __func__, data->name, container->filename, newmod->file->filename);
163 return (EEXIST);
164 }
165 namelen = strlen(data->name) + 1;
166 newmod = malloc(sizeof(struct module) + namelen, M_MODULE, M_WAITOK);
167 newmod->refs = 1;
168 newmod->id = nextid++;
169 newmod->name = (char *)(newmod + 1);
170 strcpy(newmod->name, data->name);
171 newmod->handler = data->evhand ? data->evhand : modevent_nop;
172 newmod->arg = data->priv;
173 bzero(&newmod->data, sizeof(newmod->data));
174 TAILQ_INSERT_TAIL(&modules, newmod, link);
175
176 if (container)
177 TAILQ_INSERT_TAIL(&container->modules, newmod, flink);
178 newmod->file = container;
179 MOD_XUNLOCK;
180 return (0);
181}
182
183void
184module_reference(module_t mod)

Callers 1

Calls 4

module_lookupbynameFunction · 0.85
mallocFunction · 0.85
bzeroFunction · 0.85
printfFunction · 0.70

Tested by

no test coverage detected