File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,50 @@ bool ffKmodLoaded(const char* modName)
3131{
3232 return modfind (modName ) >= 0 ;
3333}
34+ #elif __NetBSD__
35+ #include "util/stringUtils.h"
36+
37+ #include <sys/module.h>
38+ #include <sys/param.h>
39+
40+ typedef struct FFNbsdModList
41+ {
42+ int len ;
43+ modstat_t mods [];
44+ } FFNbsdModList ;
45+
46+ bool ffKmodLoaded (const char * modName )
47+ {
48+ static FFNbsdModList * list = NULL ;
49+
50+ if (list == NULL )
51+ {
52+ struct iovec iov = {};
53+
54+ // 初始尝试分配的内存大小
55+ for (size_t len = 8192 ;; len = iov .iov_len )
56+ {
57+ iov .iov_len = len ;
58+ iov .iov_base = realloc (iov .iov_base , len );
59+ if (modctl (MODCTL_STAT , & iov ) < 0 )
60+ {
61+ free (iov .iov_base );
62+ return true; // ignore errors
63+ }
64+
65+ if (len >= iov .iov_len ) break ;
66+ }
67+ list = (FFNbsdModList * ) iov .iov_base ;
68+ }
69+
70+ for (int i = 0 ; i < list -> len ; i ++ )
71+ {
72+ if (ffStrEquals (list -> mods [i ].ms_name , modName ))
73+ return true;
74+ }
75+
76+ return false;
77+ }
3478#elif __APPLE__
3579#include "util/apple/cf_helpers.h"
3680#include <IOKit/kext/KextManager.h>
You can’t perform that action at this time.
0 commit comments