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

Function kld_isloaded

tools/libutil/kld.c:40–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38#include <string.h>
39
40int
41kld_isloaded(const char *name)
42{
43 struct kld_file_stat fstat;
44 struct module_stat mstat;
45 const char *ko;
46 int fid, mid;
47
48 for (fid = kldnext(0); fid > 0; fid = kldnext(fid)) {
49 fstat.version = sizeof(fstat);
50 if (kldstat(fid, &fstat) != 0)
51 continue;
52 /* check if the file name matches the supplied name */
53 if (strcmp(fstat.name, name) == 0)
54 return (1);
55 /* strip .ko and try again */
56 if ((ko = strstr(fstat.name, ".ko")) != NULL &&
57 strlen(name) == (size_t)(ko - fstat.name) &&
58 strncmp(fstat.name, name, ko - fstat.name) == 0)
59 return (1);
60 /* look for a matching module within the file */
61 for (mid = kldfirstmod(fid); mid > 0; mid = modfnext(mid)) {
62 mstat.version = sizeof(mstat);
63 if (modstat(mid, &mstat) != 0)
64 continue;
65 if (strcmp(mstat.name, name) == 0)
66 return (1);
67 }
68 }
69 return (0);
70}
71
72int
73kld_load(const char *name)

Callers

nothing calls this directly

Calls 3

strcmpFunction · 0.85
strstrFunction · 0.85
strncmpFunction · 0.85

Tested by

no test coverage detected