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

Function sys_kldfind

freebsd/kern/kern_linker.c:1179–1210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1177}
1178
1179int
1180sys_kldfind(struct thread *td, struct kldfind_args *uap)
1181{
1182 char *pathname;
1183 const char *filename;
1184 linker_file_t lf;
1185 int error;
1186
1187#ifdef MAC
1188 error = mac_kld_check_stat(td->td_ucred);
1189 if (error)
1190 return (error);
1191#endif
1192
1193 td->td_retval[0] = -1;
1194
1195 pathname = malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
1196 if ((error = copyinstr(uap->file, pathname, MAXPATHLEN, NULL)) != 0)
1197 goto out;
1198
1199 filename = linker_basename(pathname);
1200 sx_xlock(&kld_sx);
1201 lf = linker_find_file_by_name(filename);
1202 if (lf)
1203 td->td_retval[0] = lf->id;
1204 else
1205 error = ENOENT;
1206 sx_xunlock(&kld_sx);
1207out:
1208 free(pathname, M_TEMP);
1209 return (error);
1210}
1211
1212int
1213sys_kldnext(struct thread *td, struct kldnext_args *uap)

Callers

nothing calls this directly

Calls 6

mac_kld_check_statFunction · 0.85
mallocFunction · 0.85
linker_basenameFunction · 0.85
linker_find_file_by_nameFunction · 0.85
freeFunction · 0.70
copyinstrFunction · 0.50

Tested by

no test coverage detected